Context
scopedAdminTokens.ts provides permission-scoped admin tokens with rotation support (Issue #723). Tokens are held in an in-memory Map.
Problem / Gap
Scoped tokens are not durable across restarts and cannot be shared across backend replicas. Token revocation and rotation state diverges per instance, creating auth inconsistencies in clustered deployments.
Proposed approach
- Add Prisma models for scoped admin tokens and rotation history.
- Hash secrets at rest; never persist plaintext token values.
- Migrate existing create/rotate/revoke/list endpoints to the repository layer.
- Emit admin audit events on rotation and revocation.
Acceptance criteria
Files/areas affected
backend/src/scopedAdminTokens.ts
backend/src/middleware/rbac.ts
backend/prisma/schema.prisma
Context
scopedAdminTokens.tsprovides permission-scoped admin tokens with rotation support (Issue #723). Tokens are held in an in-memoryMap.Problem / Gap
Scoped tokens are not durable across restarts and cannot be shared across backend replicas. Token revocation and rotation state diverges per instance, creating auth inconsistencies in clustered deployments.
Proposed approach
Acceptance criteria
keyIdaudit trail without exposing old secrets.Files/areas affected
backend/src/scopedAdminTokens.tsbackend/src/middleware/rbac.tsbackend/prisma/schema.prisma