During the comprehensive documentation audit—including a direct review of the codebase—several critical implementation gaps and bugs were identified. These represent technical debt and missing features that must be addressed in upcoming sprints.
1. Dynamic PBAC Permission Synchronization ✅ FIXED
- Fix Applied: Created a centralized
PERMISSION_CATALOGUEinpackages/core-access/src/permission-catalogue.tsas the single source of truth. AddedGET /manager/permissions/catalogendpoint. Both frontend UIs (Role Builder inmembers/page.tsxand API Key Dialog increate-key-dialog.tsx) now fetch permissions dynamically instead of hardcoding them. Adding a new permission only requires editing one file.
2. API Key Creation Schema Mismatch ✅ FIXED
- Fix Applied: Updated
createKeySchemainapps/manager/src/routes/api-keys.ts—permissionsnow expectsz.array(z.string())(flat PBAC strings like["blog:posts.read"]) instead of the old object format.
3. Missing role in Issued JWTs ✅ FIXED
role in Issued JWTs- Fix Applied: Injected
role: roleIdintosignAccessTokenpayloads across all 5 JWT-issuing routes:register.ts,login.ts,oauth.ts,mfa.ts, andsession.ts(token refresh). Also addedrole: RoleIdto theJWTClaimstype inpackages/core-types/src/auth.ts.
4. Timing Attack Vulnerability in Login ✅ FIXED
- Fix Applied: Added a dummy
verifyPasswordcall inlogin.tswhen no user is found, ensuring the response latency is constant regardless of whether the email exists.
5. PBAC Permission Standardization ✅ FIXED
- Fix Applied: Standardized all 32+ permission strings across the entire codebase to follow the strict
service:resource.actionnaming convention. Eliminated legacy bare formats (blog:write,media:read,apikeys:manage, etc.) from code, comments, documentation, and seed files. Final grep scan confirms zero stale references remain.
6. Extract Duplicate SHA-256 Logic ✅ FIXED
- Fix Applied: Created
packages/core-auth/src/api-key.tswithgenerateSecureToken()andhashSHA256()using Web Standard Crypto API. Both the Gateway middleware (api-key.middleware.ts) and the Manager route (api-keys.ts) now import from@repo/core-authinstead of maintaining separate implementations.
7. Rate Limiting on API Key Validation
- Current State: The Gateway's
api-key.middleware.tsperforms a SHA-256 hash and database sub-query for everyx-api-keyprovided. There is currently no protection against brute-force key guessing. - Action Required: Implement Redis or Cloudflare Workers KV/Rate-Limiting on the Gateway to limit requests per IP for
/manager/api-keysendpoints, and globally throttle invalid API key attempt bursts.
8. API Keys Missing from CORS
- Current State: While API keys can be passed as
Authorization: Bearer <key>, thex-api-keyheader itself is not currently exposed via the explicit CORSAccess-Control-Allow-Headersconfiguration. - Action Required: Update the Cloudflare Gateway global CORS configuration to explicitly allow the
x-api-keyheader for browser SDK usage scenarios.
9. Audit Logging for Auth Events
- Current State: We have an
audit_log_spec.mdspecification, but key lifecycle events (creation, revocation) and user auth events (login, MFA toggle, workspace invite) are not currently broadcasting an event to be logged. - Action Required: Implement the
EventDispatcherwithin the relevant Manager auth and team routes to push events into the Kafka/Redis stream for the audit logging consumer.