Interface: RoleGuardOptions<C>
Defined in: packages/hono/src/guards.ts:84
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
Type Parameters
| Type Parameter | Default type |
|---|---|
C | Context |
Properties
| Property | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|
all? | boolean | Require ALL of the roles (instead of any). Default: false. | - | packages/hono/src/guards.ts:86 |
exposeRequirements? | boolean | Include the required roles/permissions in the default 403 body. Default: false (like spatie's display_permission_in_exception). | RouteGuardOptions.exposeRequirements | packages/hono/src/guards.ts:61 |
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/hono/src/guards.ts:76 |
onForbidden? | GuardHandler<C> | Called when the subject lacks access. Default: 403 JSON. | RouteGuardOptions.onForbidden | packages/hono/src/guards.ts:56 |
onUnauthenticated? | GuardHandler<C> | Called when there is no subject (c.var.rbac is null). Default: 401 JSON. | RouteGuardOptions.onUnauthenticated | packages/hono/src/guards.ts:54 |
