CRASM-3443 Update token usage to cookie auth frontend and backend#1458
Open
CRASM-3443 Update token usage to cookie auth frontend and backend#1458
Conversation
ameliav
reviewed
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗣 Description
Improve Auth Flow and token usage accross application. Http only needed to be set after new auth flow changes to imporove security.
💭 Motivation and context
Backend changes (FastAPI/Django layer)
Shift authentication usage toward cookie-based auth instead of passing tokens around manually (core goal of the PR).
Update backend auth utilities and SAML auth handling (backend/src/xfd_django/xfd_api/auth.py, auth_saml.py).
Handle CSRF-protection edge cases more explicitly (backend code + tests)
Make cookie-name resolution more predictable (commit message: “Update getting cookie name more predictable”).
Cleanup / consistency improvements (remove unused logic + standardize header constant usage).
Frontend changes (React)
Update frontend API calling pattern to align with cookie auth (touches AuthContext, AuthContextProvider, and useApi).
Auth route/guard cleanup and simplification (changes to RouteGuard.tsx; removal/cleanup of AuthRoute usage).
Remove dead/commented code + remove unused AuthRoute exports (explicit commits: “Remove commented code…” and “Remove unused AuthRoute…”).
Test and tooling changes
Backend tests updated broadly to the new cookie-auth + CSRF-aware flow (many test modules updated: test_auth.py, test_api_key.py, test_organization.py, etc.).
Add/expand frontend unit tests around the updated auth + API hook behavior (useApi.test.ts, authContextProvider.test.tsx, routeGuard.test.tsx, plus test README).
Update Vite testing config (frontend/vite.config.mts).
Snapshot/test artifact cleanup (re-remove vulns snapshot).
🧪 Testing
Authenticate with application and confirm that token is no longer in local storage and instead is stored in id that is validated on backend (cookie management No actual usable token is stored in frontend or read hy Javascript.
Confirm functionality and API calls from frontend aren't breaking.
Confirm API key usage doesn't break.
Get feedback on group for auth flow changes and take suggestions/feedback.
Discuss Deployment potential issues and prepare for those scenarios.
✅ Pre-approval checklist