-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Labels
Description
Description
Switch authentication token storage from browser localStorage to HttpOnly, Secure cookies.
Goals
- Prevent XSS attacks from accessing authentication tokens.
- Simplify token management by leveraging browser cookie handling.
- Ensure seamless login, logout, and token refresh flows.
Implementation Details
-
Backend:
- Modify
loginandrefreshendpoints to setaccessTokenandrefreshTokeninHttpOnly,Secure,SameSite=Strictcookies with appropriate expiration. - Implement
logoutendpoint to clear authentication cookies. - Update server CORS settings to allow credentialed requests and specify cookie domains.
- Modify
-
Frontend:
- Remove all
localStorage.getItem,setItem, andremoveItemcalls for tokens. - Configure HTTP client (Axios/fetch) to include credentials:
withCredentials: true. - Update authentication service to rely on cookies for token presence; remove manual header insertion.
- Adapt error handling to detect 401 responses and call refresh endpoint.
- Remove all
Tech Skills Needed
JWT, Security
Mentor(s)
Complexity
Medium
Category
API