-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session not persisting on page reload #6608
Comments
We are having the same problem in our application |
I'm using MSAL for Angular and having similar problem. Each time page refresh OR open in a new tab, there's a redirection to authorize/ endpoint and back, which makes browser url 'blink' for the user and also slows down a bit the load of the page as it re-authenticates the user. Could this be related? |
Thanks for bringing this up and apologies for the incontinence. I am investigating it right now. |
I tried using claimsBasedCachingEnabled, but seems it's not helping at all. It still re-take auth information from scratch ignoring the one stored in localStorage :( |
Can confirm the issue, downgrading to msal-browser 3.2.0 seems to solve the issue. |
@baseloncohost Can you please check if cleaning up the local cache helps to fix the issue? I am not able to repro it with MSAL react/angular samples. Trying to narrow down the potential causes. |
@konstantin-msft My scenario seems to be reproducible using sample application. I still not sure that my scenario is related to the authors @baseloncohost post. If not, please let me know so I can create separate issue. I've created blank angular app, and made necessary changes to replicate sample for Angular 16 (copy/paste code)
In the past when I used v2 it works using token from the cache, but now it overwrites it each refresh of the page. |
@konstantin-msft sure thing, there you go |
We're having the same problem. I've noticed that |
Running the sample typescript app with the configurations gives same behavior, refresh page will ask for login again. I did clear cache. Installed packages:
However, locking the @azure/msal-browser to version 3.2.0 seems to solve the problem and the expected behaviour of session persisting is observed. |
We are having this issue using @msal-browser": "3.3.0" in React. On page refresh user is forced to sign in again. Reverted to version 3.2.0 and refresh works fine again |
@konstantin-msft for info, I was able to reproduce it on the following versions: @azure/msal-angular: "^3.0.4 |
@konstantin-msft same experience with latest bits. Downgraded to msal-browser 3.2.0 fixes this. Any chance this has something to do with how the Application has to be instantiated? |
I also experience the same issue, downgrading MSAL Browser to 3.2.0 solved it |
I don't think it's related since the demo already has a call for msalInstance.initialize() =>
|
@baseloncohost could you try adding your |
I can confirm the suggested workaround does indeed work correctly, tested on both the sample project and my private project. versions install:
For now I will be using @azure/msal-browser@3.2.0 to mitigate the additional HTTP request upon initialization. |
@baseloncohost one more test, I think I was able to repro your use-case. Can you make sure your knownAuthorities value is correct? I see you have the same value (which I assume is the entire authority URL) for the authority and the knownAuthorities, but knownAuthorities should only include the domain: |
I see what you mean, but it was probably a bad copy paste by me on the original post.. my current config is as follows:
|
@baseloncohost that's odd, if you're using an AAD authority then even before endpoints are resolved MSAL should be able to match the ID token because AAD authorities are included in the hardcoded metadata shipped with MSAL. I'll keep looking into it and update the thread when I know more. |
Ok, I see the issue. Tenanted authorities won't find a match in hardcoded metadata, which is why even AAD authorities are failing in this case. We'll figure out a fix and update this thread when the PR is ready. Thanks everyone. |
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
3.3.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
2.0.5
Public or Confidential Client?
Public
Description
After login, no matter what the config is, whenever you hit reload or open new tab/window the session will not persist and will ask the user to login again.
Downgrading to msal-browser 3.2.0 and msal-react 2.0.4 seems to solve the issue.
Error Message
N/A
Msal Logs
N/A
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
Session should persist through refresh and or opening new tab/window
Identity Provider
Azure B2C Custom Policy
Browsers Affected (Select all that apply)
Chrome, Firefox, Edge, Safari
Regression
@azure/msal-browser@3.2.0
Source
Internal (Microsoft)
The text was updated successfully, but these errors were encountered: