feat: Move tokens to local storage (M2-11055) - #2249
Open
sricharan-varanasi wants to merge 6 commits into
Open
Conversation
17 tasks
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
🔗 Jira Ticket M2-11055
Tokens live in
sessionStorage, which is per tab. So a new tab always shows the login page even when a session is live next door, closing the tab ends the session, and the tokens sit in DevTools as readable JWTs.This moves them to
react-secure-storagealready a dependency, already used for language and library paths. One session per browser, shared by every tab, encrypted at rest.Changes include:
lastActivityAtmoves to plain localStorage . it is a timestamp, not a secret, and it has to stay readable live because the encrypted store answers reads from a snapshot taken at page loadsessionStoragesessionStorage.clear()no longer reaches the tokens, so leaving it alone would leave a signed-in session behind🪤 Peer Testing
Sign in, then open a new tab
Expected outcome: already signed in, no login page
Log out, check Application → Storage, then open a new tab
Expected outcome: no tokens in either store, and the new tab shows the login page
Change the language, log out, log back in
Expected outcome: language is preserved
Sign in on
develop, switch to this branch, reloadExpected outcome: still signed in, and the old
accessToken/refreshTokenkeys are gone from sessionStorageSet
REACT_APP_IDLE_TIMEOUT_MIN=1, quit the browser, reopen straight awayExpected outcome: still signed in
Let the access token expire, then click something
Expected outcome: the 401 refresh still works transparently
Log out from the account menu with unsaved changes in the builder
Expected outcome: the save/discard prompt still appears and the logout completes
Open two tabs and sign in as a different user in each
Expected outcome: they converge on one user. This is the intended change, not a bug — see Notes
✏️ Notes
session-keep-aliveenableSessionKeepAlive.- Rolling back logs users out once. Their tokens would be in the new store and the reverted code looks in the old one. Rolling forward is covered by the migration; rolling back is not.✅ Checklist
Functionality
Testing
Security & Data Privacy
react-secure-storagewas already in use.Logging/Monitoring
Performance
Readability
Change Safety
Backend changes are backwards compatible with old clients, or it is well known they are not and a deployment/rollout plan is in place. This include backend changes being compatible with old mobile app versions, as well as applet versioning within Curious.Destructive database migrations are rolled out in stages. For example, renaming a column means adding a new column and migrating the existing data to that columns in one deployment. Then monitoring to ensure that field isn’t used, and finally removing that old column in a separate deployment.