Interface: RoleGuardOptions<Req>
Defined in: packages/express/src/guards.ts:81
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 | Request |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
all? | boolean | Require ALL of the roles (instead of any). Default: false. | - | packages/express/src/guards.ts:83 |
exposeRequirements? | boolean | Include the required roles/permissions in the default 403 body. Default: false (like spatie's display_permission_in_exception). | RouteGuardOptions.exposeRequirements | packages/express/src/guards.ts:58 |
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/express/src/guards.ts:73 |
onForbidden? | GuardHandler<Req> | Called when the subject lacks access. Default: 403 JSON. | RouteGuardOptions.onForbidden | packages/express/src/guards.ts:53 |
onUnauthenticated? | GuardHandler<Req> | Called when there is no subject (req.rbac is null). Default: 401 JSON. | RouteGuardOptions.onUnauthenticated | packages/express/src/guards.ts:51 |
