Context
Long-lived sessions increase the window of vulnerability if tokens are stolen. Current session management uses static refresh tokens.
Current Limitation/Problem
Access tokens expire after 15 minutes but refresh tokens are long-lived (30 days) and not rotated. A stolen refresh token grants prolonged access. There is no refresh token rotation.
Expected Outcome
Implement refresh token rotation: each refresh request issues a new refresh token and invalidates the old one. Automatic revocation of compromised token families.
Acceptance Criteria
- Rotate refresh token on every refresh request
- Maintain token family tree for abuse detection
- Auto-revoke entire token family if a rotated token is reused (indicates theft)
- Configurable: absolute token lifetime (max 30 days), sliding expiration (max 7 days inactivity)
- Store token hashes (not raw tokens) in database
- Token revocation API and admin dashboard
- Audit log for all token operations
- Rate limit token refresh endpoint (5 requests/minute)
- NIST SP 800-63B compliant session management
Technical Scope
backend/src/auth/token-rotation.ts - rotation logic
backend/src/middleware/token-auth.ts - enhanced token validation
- Prisma:
RefreshToken model with token family tracking
- Redis: token blacklist for immediate revocation
- Frontend: session management UI (active sessions, revoke)
- Edge cases: concurrent refresh requests (race condition), token family replay detection
Context
Long-lived sessions increase the window of vulnerability if tokens are stolen. Current session management uses static refresh tokens.
Current Limitation/Problem
Access tokens expire after 15 minutes but refresh tokens are long-lived (30 days) and not rotated. A stolen refresh token grants prolonged access. There is no refresh token rotation.
Expected Outcome
Implement refresh token rotation: each refresh request issues a new refresh token and invalidates the old one. Automatic revocation of compromised token families.
Acceptance Criteria
Technical Scope
backend/src/auth/token-rotation.ts- rotation logicbackend/src/middleware/token-auth.ts- enhanced token validationRefreshTokenmodel with token family tracking