You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue [Security] Add authentication guard to POST /users endpoint
Tier: 🟡 Medium
Description:
Problem: The POST /users route in src/modules/users/users.routes.ts lines 27-31 calls createUserController without any requireAuth or requireRole middleware. This means any unauthenticated user can create new user accounts in the system. Per AGENTS.md: "Every new route MUST use requireAuth and requireRole unless there is an explicit requirement for public access." User creation should be restricted to administrators.
Implementation: Add requireAuth and requireRole([UserRole.SUPER_ADMIN, UserRole.ADMIN]) middleware to the POST /users route. Ensure the controller reads organizationId from the authenticated user's token payload rather than relying on request body.
Dependencies:
Depends on None
Acceptance Criteria:
POST /users route includes requireAuth middleware.
POST /users route includes requireRole restricting to SUPER_ADMIN and ADMIN.
Domain: Identity
Issue [Security] Add authentication guard to
POST /usersendpointTier: 🟡 Medium
Description:
POST /usersroute insrc/modules/users/users.routes.tslines 27-31 callscreateUserControllerwithout anyrequireAuthorrequireRolemiddleware. This means any unauthenticated user can create new user accounts in the system. Per AGENTS.md: "Every new route MUST userequireAuthandrequireRoleunless there is an explicit requirement for public access." User creation should be restricted to administrators.requireAuthandrequireRole([UserRole.SUPER_ADMIN, UserRole.ADMIN])middleware to thePOST /usersroute. Ensure the controller readsorganizationIdfrom the authenticated user's token payload rather than relying on request body.Dependencies:
Acceptance Criteria:
POST /usersroute includesrequireAuthmiddleware.POST /usersroute includesrequireRolerestricting toSUPER_ADMINandADMIN.Testing Requirements:
POST /usersreturns 401.POST /usersreturns 403.POST /userscreates user successfully.PR Checklist:
security/issue-47-users-auth-guard).npm run lintandnpm run buildpass with zero warnings.