Work
Option 2 Option 3
KB
doc-updater · main 2 active
Refactor auth module to JWT
$3.23
Blocked — network Action
feat/jwt-auth · Claude Code · 34m
Generate OpenAPI docs for REST endpoints
$5.91
Paused 3h
docs/openapi-spec · Claude Code
FA
frontend-app · feat/dashboard 1 active
Add dark mode toggle to settings
$3.23
Running 2h
feat/dark-mode · Claude Code
AG
api-gateway · develop 1 active
Fix memory leak in WebSocket handler
$1.00
Waiting for input Action
fix/ws-memory-leak · Codex · 45m
Refactor authentication module to use JWT tokens
Needs input — network blocked
Your prompt
Refactor the authentication module to use JWT tokens instead of session-based auth. Update the middleware and all related handlers.
Plan
3 / 5
Analyze existing auth handler and middleware done
Refactor auth handler to use JWT signing done
Update middleware for Bearer token verification done
Add refresh token endpoint with rotation blocked
Update route handlers and add tests queued
Analyzed the existing authentication setup to understand the current session-based implementation.
Read src/auth/handler.ts done
export class AuthHandler { private sessionStore: SessionStore; async login(req: Request): Promise<Response> { const session = await this.sessionStore.create(req.body); return res.cookie('sid', session.id); } }
Read src/middleware/auth.ts done
Read src/routes/api.ts done
Replaced session-based login with JWT token signing. Added jwtSecret and tokenExpiry configuration.
src/auth/handler.ts +6-3
- private sessionStore: SessionStore;
+ private jwtSecret: string;
+ private tokenExpiry: string = '24h';
- const session = await this.sessionStore.create(req.body);
- return res.cookie('sid', session.id);
+ const user = await this.validateCredentials(req.body);
+ const token = jwt.sign({ sub: user.id }, this.jwtSecret, {
+ expiresIn: this.tokenExpiry
+ });
+ return res.json({ token });
Updated the auth middleware to verify JWT tokens from the Authorization: Bearer header instead of reading session cookies.
Edited src/middleware/auth.ts done
Follow-up
Good, but also add refresh token support with a separate endpoint.
Adding refresh token support with a dedicated /auth/refresh endpoint. To validate tokens securely, I need to fetch the JWKS public keys from the identity provider...
Created src/auth/refresh.ts done
GET https://auth.example.com/.well-known/jwks.json blocked
Network request blocked just now
The agent attempted to reach auth.example.com but the request was denied by the workspace network policy.
Request GET https://auth.example.com/.well-known/jwks.json
Purpose Fetch JWKS public keys for JWT token verification
Policy Deny mode — host not in allowed list
Workspace doc-updater · main
Type @ to attach context · Enter to send
Claude Sonnet 4.6