MonoCloud Authentication SDK
    Preparing search index...

    Interface MonoCloudMiddlewareOptions

    Options for configuring authMiddleware().

    These options control which routes are protected and how authentication and authorization failures are handled during request processing.

    interface MonoCloudMiddlewareOptions {
        groupsClaim?: string;
        matchAll?: boolean;
        onAccessDenied?: NextMiddlewareOnAccessDenied;
        onError?: (
            req: NextRequest,
            evt: NextFetchEvent,
            error: Error,
        ) => void | NextResponse<unknown> | Promise<void | NextResponse<unknown>>;
        onGroupAccessDenied?: NextMiddlewareOnGroupAccessDenied;
        protectedRoutes?: ProtectedRoutes;
    }
    Index

    Properties

    groupsClaim?: string

    Name of the claim in the user profile that contains group memberships.

    'groups'
    
    matchAll?: boolean

    When true, the user must belong to all specified groups for authorization to succeed. Otherwise, membership in any one group is sufficient.

    false
    

    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.

    Type Declaration

      • (
            req: NextRequest,
            evt: NextFetchEvent,
            error: Error,
        ): void | NextResponse<unknown> | Promise<void | NextResponse<unknown>>
      • Parameters

        • req: NextRequest

          The incoming Next.js request.

        • evt: NextFetchEvent

          The associated Next.js fetch event.

        • error: Error

          The error thrown during execution.

        Returns void | NextResponse<unknown> | Promise<void | NextResponse<unknown>>

        Returns a response to continue the middleware chain, or void.

    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.