Options for configuring authMiddleware().
These options control which routes are protected and how authentication and authorization failures are handled during request processing.
| Property | Type | Description |
|---|---|---|
groupsClaim? | string | Name of the claim in the user profile that contains group memberships. |
matchAll? | boolean | When true, the user must belong to all specified groups for authorization to succeed. Otherwise, membership in any one group is sufficient. |
onAccessDenied? | NextMiddlewareOnAccessDenied | Middleware handler invoked when the user is not authenticated. |
onError? | (req: NextRequest, evt: NextFetchEvent, error: Error) => void | NextResponse<unknown> | Promise<void | NextResponse<unknown>> | Error handler invoked when an error occurs during execution of authentication endpoints handled by the middleware. |
onGroupAccessDenied? | NextMiddlewareOnGroupAccessDenied | Middleware handler invoked when the user is authenticated but does not satisfy group authorization requirements. |
protectedRoutes? | ProtectedRoutes | Defines which routes require authentication. Accepts either an array of ProtectedRouteMatcher or a CustomProtectedRouteMatcher. If omitted, all routes matched by the middleware config are protected. If an empty array is provided, no routes are protected. |