MsalInterceptor uses wrong account after logging out #7525
Labels
bug-unconfirmed
A reported bug that needs to be investigated and confirmed
msal-angular
Related to @azure/msal-angular package
msal-browser
Related to msal-browser package
Needs: Attention 👋
Awaiting response from the MSAL.js team
public-client
Issues regarding PublicClientApplications
question
Customer is asking for a clarification, use case or information.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
3.28.1
Wrapper Library
MSAL Angular (@azure/msal-angular)
Wrapper Library Version
3.1.0
Public or Confidential Client?
Public
Description
Hello!
I'm using Angular 18 and @azure/msal-angular 3.1.0 in my project. I'm using MS Entra ID authentication and should support multiple accounts at the same time (signing in with different account, switching between multiple accounts, logging out of specific account etc).
I have the following problem:
I'm logged in with 2 accounts.
I log out of my first account.
First, I'm redirected to my application, and if REST request fails (that should be the case after logging out), I should be redirected to login page.
But, MsalInterceptor starts using token from my second account in Authorization header (instead of not using token at all).
As a result, redirect to login form is not working, because my REST requests pass (with the token from another account) and I'm not redirected from my application to login form.
I think this code is problematic, especially command: account = this.authService.instance.getAllAccounts()[0];:
In my opinion, interceptor shouldn't set account at all. If there is no active account, interceptor shouldn't set Authorization header.
Error Message
No response
MSAL Logs
No response
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Chrome, Firefox, Edge, Safari, Other
Regression
No response
The text was updated successfully, but these errors were encountered: