Skip to content

✨(frontend) store and retrieve user token in sessionStorage#2724

Open
kernicPanel wants to merge 6 commits intomasterfrom
keycloak
Open

✨(frontend) store and retrieve user token in sessionStorage#2724
kernicPanel wants to merge 6 commits intomasterfrom
keycloak

Conversation

@kernicPanel
Copy link
Member

Purpose

Ensure the user's token is saved to sessionStorage during login and retrieved as needed. Improves token handling for authenticated API calls.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements token storage and retrieval functionality for the Keycloak authentication backend by adding an accessToken() method and storing the token in sessionStorage during user profile loading. However, there are critical issues with the token type being used.

Changes:

  • Added accessToken() method to retrieve token from sessionStorage
  • Token is now stored in sessionStorage when user profile is loaded
  • Added access_token field to the user object returned by me()

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/frontend/js/api/auth/keycloak.ts Implements token storage/retrieval using sessionStorage and adds accessToken method
src/frontend/js/api/auth/keycloak.spec.ts Adds test coverage for the new accessToken method and verifies token storage behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Ensure the user's token is saved to `sessionStorage` during login and retrieved
as needed. Improves token handling for authenticated API calls.
Keycloak account information retrieval and update link handling added to
SaleTunnel. Ensures proper verification flow in purchase steps.
Include `referrer` and encoded `referrer_uri` parameters
in the Keycloak account URL.
Ensures proper redirection when linking back to the application.
Update Keycloak configuration to use 'standard' flow with PKCE and 'check-sso'
on load. Add token refresh logic for improved user session handling.
Cleanup unused `AUTHENTICATION_KEYCLOAK_TOKEN` references from settings,
context processors, and tests.
Add logic to handle expired tokens by removing them from sessionStorage.
Improves reliability of authenticated API calls.
keycloakAccountLinkLabel: {
id: 'components.SaleTunnel.Information.keycloak.updateLinkLabel',
description: 'Label of the keycloak link to update account',
defaultMessage: 'please update your account',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultMessage: 'please update your account',
defaultMessage: 'Please update your account',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants