AuthOptionsinterface
import { AuthOptions } from '@mortar-kit/auth'
interface AuthOptions<User>Options for createAuth.
Properties
methods: readonly AuthMethod[]The ways to sign in, in the order the sign-in page lists them.
authorize: (input: AuthorizeInput) => User | Promise<User | null | undefined> | null | undefinedWho may use the admin: the user for this identity, or null if they may not. Runs when someone signs in and again on every guarded request, so removing someone takes effect at once; keep it quick (one lookup). The user is what
user()andrequire()return; keep it plain JSON if it goes to the browser.allowEmails([...])covers a fixed list.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?: 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.