AuthConfig
AuthConfig =
object
Defined in: packages/auth/src/types.ts:61
Configuration for createAuth.
Defines authentication methods, session behavior, role management rules,
and integration with @cfast/permissions.
Properties
Section titled “Properties”anonymousRoles?
Section titled “anonymousRoles?”
optionalanonymousRoles:string[]
Defined in: packages/auth/src/types.ts:91
Roles assigned to unauthenticated (anonymous) requests for permission resolution.
defaultRoles?
Section titled “defaultRoles?”
optionaldefaultRoles:string[]
Defined in: packages/auth/src/types.ts:93
Default roles assigned to authenticated users who have no explicit role assignments. Defaults to ["reader"].
impersonation?
Section titled “impersonation?”
optionalimpersonation:object
Defined in: packages/auth/src/types.ts:99
Impersonation feature configuration.
allowedRoles?
Section titled “allowedRoles?”
optionalallowedRoles:string[]
Roles permitted to impersonate other users. Defaults to ["admin"].
magicLink?
Section titled “magicLink?”
optionalmagicLink:object
Defined in: packages/auth/src/types.ts:74
Magic link email configuration. Required to enable magic link authentication.
sendMagicLink()
Section titled “sendMagicLink()”sendMagicLink: (
params) =>Promise<void>
Callback to send the magic link email. Receives the user’s email and the login URL.
Parameters
Section titled “Parameters”params
Section titled “params”string
string
Returns
Section titled “Returns”Promise<void>
passkeys?
Section titled “passkeys?”
optionalpasskeys:object
Defined in: packages/auth/src/types.ts:67
WebAuthn passkey configuration. Required to enable passkey authentication.
rpId:
string
Relying party identifier, typically the app’s domain (e.g., "myapp.com").
rpName
Section titled “rpName”rpName:
string
Relying party display name shown during WebAuthn registration.
permissions
Section titled “permissions”permissions:
Permissions
Defined in: packages/auth/src/types.ts:63
The permissions config from definePermissions(). Roles are inferred from this.
redirects?
Section titled “redirects?”
optionalredirects:object
Defined in: packages/auth/src/types.ts:84
Redirect paths for the authentication flow.
afterLogin?
Section titled “afterLogin?”
optionalafterLogin:string
Where to redirect after successful login. Defaults to "/".
loginPath?
Section titled “loginPath?”
optionalloginPath:string
Where to send unauthenticated users. Defaults to "/login".
roleGrants?
Section titled “roleGrants?”
optionalroleGrants:Record<string,string[]>
Defined in: packages/auth/src/types.ts:97
Maps each role to the set of roles it is allowed to assign. Controls who can promote whom.
roleTableName?
Section titled “roleTableName?”
optionalroleTableName:string
Defined in: packages/auth/src/types.ts:95
Custom table name for storing role assignments. Defaults to "roles".
schema?
Section titled “schema?”
optionalschema:Record<string,unknown>
Defined in: packages/auth/src/types.ts:65
Optional Drizzle schema override for the Better Auth database adapter.
session?
Section titled “session?”
optionalsession:object
Defined in: packages/auth/src/types.ts:79
Session lifetime configuration.
expiresIn?
Section titled “expiresIn?”
optionalexpiresIn:string
How long sessions last before expiring (e.g., "30d", "12h", "60m"). Defaults to "30d".
templates?
Section titled “templates?”
optionaltemplates:object
Defined in: packages/auth/src/types.ts:104
Custom email template functions.
magicLink()?
Section titled “magicLink()?”
optionalmagicLink: (props) =>string
Returns an HTML string for the magic link email. Receives the login URL and recipient email.
Parameters
Section titled “Parameters”string
string
Returns
Section titled “Returns”string