← @mortar-kit/auth

AuthFromEnvOptionsinterface

import { AuthFromEnvOptions } from '@mortar-kit/auth'

interface AuthFromEnvOptions<User> extends Partial<Omit<AuthOptions<User>, "methods">>

Options for authFromEnv.

Properties

authorize?: (input: AuthorizeInput) => User | Promise<User | null | undefined> | null | undefined
secret?: string | readonly string[]

Signs the session cookie and the OAuth state, and keys token hashes: at least 32 characters, from the environment, never in code. Several keys rotate: the first signs, all are accepted.

basePath?: string

Where the auth routes live. Default /admin/auth.

signInPath?: string

The app's sign-in page (a route rendering <SignIn> from @mortar-kit/admin). Default /admin/sign-in.

protect?: readonly string[]

Paths (prefixes) that need a signed-in user; handle redirects (GET) or refuses (401) the rest. Default ['/admin'].

home?: string

Where to go after signing in when no returnTo was given. Default /admin.

maxAge?: number

How long a session lasts, in seconds. Default 14 days.

cookieName?: string

The session cookie's name. Default mortar_session.

baseUrl?: string

The site's public origin, e.g. https://example.com: OAuth redirect URIs, email links and the same-origin check use it. Set it behind a proxy, where the request's own URL may be http://localhost:3000. Default: the origin of each request.

store?: ContentStore

Keeps pending email sign-ins. Without it there is no email sign-in. With the JSON-file store, use a folder outside your content and git (createJsonFileStore({ dir: '.data' })).

mailer?: Mailer

Sends sign-in emails. Default: Resend when RESEND_API_KEY and MORTAR_EMAIL_FROM are set, else (in development only) the console.

siteName?: string

The site's name in sign-in emails.

methods?: readonly AuthMethod[]

Methods to offer after the ones from the environment.

env?: Readonly<Record<string, string | undefined>>

Where to read variables. Default process.env.

dev?: boolean

Development mode: a fixed secret, [email protected] as the admin and emails printed to the console when nothing else is set. Default Vite's import.meta.env.DEV, so a production build never falls back.