Infrastructure low complexity backend
1
Dependencies
0
Dependents
6
Entities
0
Integrations

Description

Backend middleware (Next.js API route middleware) that intercepts all write requests and validates that the association_id in the request body or header belongs to the authenticated user's list of memberships. Rejects requests with a 403 if the user attempts to write data to an association they are not a member of, preventing unauthorized data attribution.

Feature: Member Multi-Association Membership

association-context-middleware

Responsibilities

  • Extract association_id from incoming API requests
  • Verify the authenticated user has a valid membership in the specified association
  • Reject unauthorized association access with a structured 403 error
  • Pass validated context to downstream API handlers

Interfaces

validateAssociationAccess(req: NextApiRequest, res: NextApiResponse, next: Function): Promise<void>
extractAssociationId(req: NextApiRequest): String?
checkUserMembership(userId: String, associationId: String): Promise<bool>
buildUnauthorizedResponse(reason: String): ErrorResponse

Relationships

Dependencies (1)

Components this component depends on