Interface: RoleGuardOptions<Req>
Defined in: packages/fastify/src/guards.ts:86
The options every guard takes: the handlers plus guard.
guard is per guard only (like spatie's role:admin,api), not a createGuards() default: the defaults are about handlers, and the request's guard is set on the middleware. With per-guard names, tell the types which guard the requests have with createGuards<AppRbac, 'api'>().
Extends
RouteGuardOptions<Req>
Type Parameters
| Type Parameter | Default type |
|---|---|
Req | FastifyRequest |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
all? | boolean | Require ALL of the roles (instead of any). Default: false. | - | packages/fastify/src/guards.ts:88 |
exposeRequirements? | boolean | Include the required roles/permissions in the default 403 body. Default: false (like spatie's display_permission_in_exception). | RouteGuardOptions.exposeRequirements | packages/fastify/src/guards.ts:63 |
guard? | string | Check in this guard instead of the request's (subject.withScope({ guard })), like spatie's role:admin,api. Default: the guard of the request's subject. | RouteGuardOptions.guard | packages/fastify/src/guards.ts:78 |
onForbidden? | GuardHandler<Req> | Called when the subject lacks access. Default: 403 JSON. | RouteGuardOptions.onForbidden | packages/fastify/src/guards.ts:58 |
onUnauthenticated? | GuardHandler<Req> | Called when there is no subject (request.rbac is null). Default: 401 JSON. | RouteGuardOptions.onUnauthenticated | packages/fastify/src/guards.ts:56 |
