Infrastructure low complexity Shared Component backend
0
Dependencies
0
Dependents
16
Entities
0
Integrations

Description

Next.js middleware applied to all admin user management API routes. Validates the incoming JWT, resolves the requesting admin's organization scope, and rejects cross-organization access for org admins while permitting global admins to operate across all organizations.

Feature: User CRUD

org-scoped-auth-guard

Responsibilities

  • Validate JWT bearer token and extract admin identity with role and org context
  • Reject requests where the target resource belongs to a different organization (for org-admin callers)
  • Attach resolved org context to the request object for downstream route handlers

Interfaces

withOrgAuth(handler)
resolveAdminScope(token)
isGlobalAdmin(adminId)