OptionalgroupsName of the claim in the user profile that contains group memberships.
OptionalmatchWhen true, the user must belong to all specified groups for authorization to succeed. Otherwise, membership in any one group is sufficient.
OptionalonMiddleware handler invoked when the user is not authenticated.
OptionalonError handler invoked when an error occurs during execution of authentication endpoints handled by the middleware.
The incoming Next.js request.
The associated Next.js fetch event.
The error thrown during execution.
Returns a response to continue the middleware chain, or void.
OptionalonMiddleware handler invoked when the user is authenticated but does not satisfy group authorization requirements.
OptionalprotectedDefines 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.
Options for configuring authMiddleware().
These options control which routes are protected and how authentication and authorization failures are handled during request processing.