Move auth tokens from localStorage to httpOnly cookies #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Auth tokens and tenant identifiers are stored in
localStorage:lib/sdk/academy/api-courses.tsstoresauthTokenin localStoragelib/sdk/dsr/api-types.tsreadsX-User-IDandX-Tenant-IDfrom localStoragelocalStorageis accessible to any JavaScript running on the page. An XSS vulnerability anywhere in the app allows an attacker to exfiltrate tokens and impersonate users.Required Actions
authTokento an httpOnly, Secure, SameSite=Strict cookie set by the backend on loginX-User-IDfrom frontend entirely — derive from JWT on the backendX-Tenant-IDis no longer needed on the frontendallow_credentials=Truewith explicit originsAcceptance Criteria
localStoragecontains no token or tenant datadocument.cookiedoes not show the auth token (httpOnly flag)Authorizationheader