Skip to content

Interface: PermissionGuardOptions<A> ​

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

The options every guard takes as its last argument: the handlers plus guard. They win over the defaults.

Extends ​

Type Parameters ​

Type ParameterDefault type
A extends AstroContextAstroContext

Properties ​

PropertyTypeDescriptionInherited fromDefined in
any?booleanPass when the subject has ANY of the permissions (instead of all). Default: false.-packages/astro/src/server.ts:106
exposeRequirements?booleanInclude the required roles/permissions in the default 403 body (required). Default: false (like spatie's display_permission_in_exception).RouteGuardOptions.exposeRequirementspackages/astro/src/server.ts:95
forbiddenRedirect?string | ((context) => string)Redirect users without access here (302) instead of the 403.RouteGuardOptions.forbiddenRedirectpackages/astro/src/server.ts:90
guard?stringCheck in this guard instead of the server's (subject.withScope({ guard })), like spatie's role:admin,api.RoleGuardOptions.guardpackages/astro/src/server.ts:101
onForbidden?GuardHandler<A>Called when the subject lacks access. Wins over forbiddenRedirect. Default: a 403 JSON Response.RouteGuardOptions.onForbiddenpackages/astro/src/server.ts:83
onUnauthenticated?GuardHandler<A>Called when there is no subject. Wins over unauthenticatedRedirect. Default: a 401 JSON Response.RouteGuardOptions.onUnauthenticatedpackages/astro/src/server.ts:81
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}``.RouteGuardOptions.unauthenticatedRedirectpackages/astro/src/server.ts:88

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