Skip to content

Interface: RbacServerOptions<T, G, A> ​

Defined in: packages/astro/src/server.ts:187

Extends ​

Type Parameters ​

Type ParameterDefault type
T extends RbacTypeConfigDefaultRbacTypes
G extends stringDefaultGuardName<T>
A extends AstroContextAstroContext

Properties ​

PropertyTypeDescriptionInherited fromDefined in
exposeRequirements?booleanInclude the required roles/permissions in the default 403 body (required). Default: false (like spatie's display_permission_in_exception).GuardHandlers.exposeRequirementspackages/astro/src/server.ts:95
forbiddenRedirect?string | ((context) => string)Redirect users without access here (302) instead of the 403.GuardHandlers.forbiddenRedirectpackages/astro/src/server.ts:90
getSubject(context) => MaybePromise<Subject | null | undefined>Resolves the authenticated subject of the request (locals.user set by your auth middleware, a session cookie...). Return null / undefined for guests.-packages/astro/src/server.ts:198
guard?GGuard name (e.g. web or api). Defaults to the engine's defaultGuard.-packages/astro/src/server.ts:200
onForbidden?GuardHandler<A>Called when the subject lacks access. Wins over forbiddenRedirect. Default: a 403 JSON Response.GuardHandlers.onForbiddenpackages/astro/src/server.ts:83
onUnauthenticated?GuardHandler<A>Called when there is no subject. Wins over unauthenticatedRedirect. Default: a 401 JSON Response.GuardHandlers.onUnauthenticatedpackages/astro/src/server.ts:81
rbacRbac<T>The RBAC engine created with createRbac(...). Its typed names flow into the guards.-packages/astro/src/server.ts:193
team?(context) => MaybePromise<TeamId | undefined>Resolves the current team (only when the engine was created with teams: true).-packages/astro/src/server.ts:202
unauthenticatedRedirect?string | ((context) => string)Redirect guests here (302) instead of the 401. Handy for pages: '/login'. A function gets the context, e.g. to keep the page: ({ url }) => /login?redirectTo=${url.pathname}``.GuardHandlers.unauthenticatedRedirectpackages/astro/src/server.ts:88

Released under the MIT License. Inspired by spatie/laravel-permission.