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 | undefinedsecret?: 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?: stringWhere the auth routes live. Default
/admin/auth.signInPath?: stringThe 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;
handleredirects (GET) or refuses (401) the rest. Default['/admin'].home?: stringWhere to go after signing in when no
returnTowas given. Default/admin.maxAge?: numberHow long a session lasts, in seconds. Default 14 days.
cookieName?: stringThe session cookie's name. Default
mortar_session.baseUrl?: stringThe 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 behttp://localhost:3000. Default: the origin of each request.store?: ContentStoreKeeps 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?: MailerSends sign-in emails. Default: Resend when RESEND_API_KEY and MORTAR_EMAIL_FROM are set, else (in development only) the console.
siteName?: stringThe 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?: booleanDevelopment mode: a fixed secret,
[email protected]as the admin and emails printed to the console when nothing else is set. Default Vite'simport.meta.env.DEV, so a production build never falls back.