-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
1 / 11 of 1 issue completed
Copy link
Labels
enhancementNew feature or requestNew feature or requestsecuritySecurity-related changes or vulnerabilitiesSecurity-related changes or vulnerabilities
Description
🗺️ EPIC: httpOnly Cookie Authentication Migration
Original Issue: Closes #205
Priority: High
Area: Authentication, Security
Goal
Replace insecure localStorage token storage with httpOnly cookie-based authentication using Laravel Sanctum SPA mode to protect against XSS attacks.
Sub-Issues & Work Plan
Backend (api repo)
- Backend PR-1: Sanctum SPA Configuration & CORS Setup api#209 - Backend PR-1: Sanctum SPA Configuration & CORS Setup
- Backend PR-2: CSRF Token Endpoint & Security Hardening api#210 - Backend PR-2: CSRF Token Endpoint & Security Hardening
- Backend PR-3: Tests & API Documentation Update api#208 - Backend PR-3: Tests & API Documentation Update
Frontend (frontend repo)
- Frontend PR-1: localStorage Removal & httpOnly Cookie Migration #210 - Frontend PR-1: localStorage Removal & httpOnly Cookie Migration
- Frontend PR-2: CSRF Token Handling & Request Interceptor #211 - Frontend PR-2: CSRF Token Handling & Request Interceptor
- Frontend PR-3: Integration Tests & Developer Documentation (Closes Epic) #212 - Frontend PR-3: Integration Tests & Developer Documentation (Closes Epic)
Technical Context
Current State (Insecure):
// Frontend stores token in localStorage
localStorage.setItem('auth_token', token);
// Vulnerable to XSS attacksTarget State (Secure):
// Backend sends httpOnly cookie
// Frontend uses credentials: 'include'
fetch(url, { credentials: 'include' });
// Token inaccessible to JavaScriptDependencies
Backend must implement first:
- Laravel Sanctum SPA authentication mode
SANCTUM_STATEFUL_DOMAINSconfiguration- CORS configuration with
credentials: true - CSRF token endpoint (
/sanctum/csrf-cookie)
Frontend follows:
- Remove localStorage token storage
- Update fetch calls to use
credentials: 'include' - Add CSRF token handling
- Update AuthContext
Acceptance Criteria
- Backend: Sanctum SPA mode configured
- Backend: CORS allows credentials from frontend domain
- Backend: CSRF protection enabled
- Frontend: No token accessible via JavaScript
- Frontend: All auth requests include cookies
- Tests: Auth flow works end-to-end
- Tests: CSRF protection validated
- Docs: Migration guide for developers
References
- Laravel Sanctum SPA Authentication
- OWASP: Token Storage Security
- Original issue: Security: Migrate authentication from localStorage to httpOnly cookies #205
Non-Goals
- Mobile app authentication (different flow)
- API token management (separate concern)
- Session storage (using Sanctum cookies)
Sub-issues
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestsecuritySecurity-related changes or vulnerabilitiesSecurity-related changes or vulnerabilities
Type
Projects
Status
✅ Done