Skip to content

Interface: RoleGuardOptions<C> ​

Defined in: packages/elysia/src/guards.ts:73

The options every guard takes: the handlers plus guard (check in another guard, like spatie's role:admin,api).

Extends ​

Type Parameters ​

Type ParameterDefault type
CGuardHandlerContext

Properties ​

PropertyTypeDescriptionInherited fromDefined in
all?booleanRequire ALL of the roles (instead of any). Default: false.-packages/elysia/src/guards.ts:75
exposeRequirements?booleanInclude the required roles/permissions in the default 403 body. Default: false (like spatie's display_permission_in_exception).RouteGuardOptions.exposeRequirementspackages/elysia/src/guards.ts:59
guard?stringCheck in this guard instead of the request's (subject.withScope({ guard })). Default: the request's guard.RouteGuardOptions.guardpackages/elysia/src/guards.ts:65
onForbidden?GuardHandler<C>Called when the subject lacks access. Default: 403 JSON.RouteGuardOptions.onForbiddenpackages/elysia/src/guards.ts:54
onUnauthenticated?GuardHandler<C>Called when there is no subject (rbac is null). Default: 401 JSON.RouteGuardOptions.onUnauthenticatedpackages/elysia/src/guards.ts:52

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