feat: add admin static token as auth alternative#63
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughAdds optional static admin-token authentication alongside existing JWT-based admin login. New ChangesStatic Admin Token Authentication
sequenceDiagram
participant Client
participant Server
participant Config
participant JWTVerifier
Client->>Server: Request with Authorization: Bearer <token> (or cookie)
Server->>Config: Read runtimeConfig.adminToken
alt provided token equals configured adminToken
Server->>Server: getStaticAdminPayload -> static admin payload
Server-->>Client: 200 OK with user payload (static-token)
else not a static-token
Server->>JWTVerifier: Verify Bearer token (or cookie)
alt JWT valid
JWTVerifier-->>Server: decoded JWT payload
Server-->>Client: 200 OK with user payload (jwt)
else invalid
Server-->>Client: 401 Unauthorized
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/api.md (1)
46-50: 💤 Low valueConsider clarifying JWT availability for Bearer token usage.
The documentation states
Authorization: Bearer <token>accepts "A JWT created byPOST /api/auth/login". However, the login endpoint sets the JWT in an HTTP-only cookie and returns only{ success: true }in the response body—the JWT isn't directly accessible to JavaScript clients.For external software integration, the static token path (
NUXT_ADMIN_TOKEN) is the intended approach, which is correctly documented. Consider clarifying that the JWT mode is primarily for cookie-based browser sessions, while external software should use the static token.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/api.md` around lines 46 - 50, Update the "Authorization: Bearer <token>" docs to clarify that the JWT referenced from POST /api/auth/login is set as an HTTP-only cookie and is not returned in the response body (so it isn't accessible to JS clients), that this JWT mode is for browser cookie-based admin sessions, and that external software or API clients should use the exact static token configured in NUXT_ADMIN_TOKEN for Bearer header authentication instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/api.md`:
- Around line 46-50: Update the "Authorization: Bearer <token>" docs to clarify
that the JWT referenced from POST /api/auth/login is set as an HTTP-only cookie
and is not returned in the response body (so it isn't accessible to JS clients),
that this JWT mode is for browser cookie-based admin sessions, and that external
software or API clients should use the exact static token configured in
NUXT_ADMIN_TOKEN for Bearer header authentication instead.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 9ad448ae-839c-4946-82f3-127af8d5d09d
📒 Files selected for processing (6)
.env.exampledocs/api.mddocs/deployment-docker.mddocs/setup-production.mdnuxt.config.tsserver/utils/auth.ts
Summary by CodeRabbit
New Features
Documentation