question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Logout redirecting 3 or more times

See original GitHub issue

Core Library

MSAL.js v2 (@azure/msal-browser)

Core Library Version

2.21.0

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.1.0

Description

When I call the msalService.logoutRedirect({ postLogoutRedirectUrl: …appurl }) the msal library goes between the Azure B2C logout route and my app 3 or more times before finally routing to the login screen. I know this redirect needs to happen at least once based on B2C’s current functionality. I verified that when I call the logout function that localStorage is getting cleared out with all the Azure B2C token information. Also I’m using the MSAL redirect component, and I have it in my index.html file.

Error Message

No response

Msal Logs

No response

MSAL Configuration

{
    auth: {
      clientId: environment.clientIdMS, // This is your client ID
      authority: environment.authorityMS, // This is your tenant ID
      knownAuthorities: [B2C Tenant],
      redirectUri: environment.redirectUriMS // This is your redirect URI
    },
    cache: {
      cacheLocation: 'localStorage',
      storeAuthStateInCookie: isIE, // Set to true for Internet Explorer 11
    },
    system: {
       loggerOptions: {
        loggerCallback,
        logLevel: LogLevel.Info,
        piiLoggingEnabled: false
      }
    }
  }

Relevant Code Snippets

// Guard config
{
    interactionType: InteractionType.Redirect,
    authRequest: {
      scopes: ['openid', 'profile',
        API Scope],
      extraQueryParameters: {
        test: 'test'
      }
    }
  }

// Listener to check if user is logged in
this.msalBroadcast.inProgress$
      .pipe(
        filter((status: InteractionStatus) => status === InteractionStatus.None),
        takeUntil(this._destroying$)
      )
      .subscribe((result) => {
        // const payload = result.payload as AuthenticationResult;
        this.loggedIn = this.msalService.instance.getAllAccounts().length > 0;
        if (this.loggedIn)
          this.checkAccount();
      });

// Logout function
this.msalService.logoutRedirect({
    postLogoutRedirectUri: environment.redirectUriMS,
    account: this.msalService.instance.getActiveAccount() // I've tried it with and without this line
});

Reproduction Steps

  1. Call the logoutRedirect call

Expected Behavior

To be redirected once and then back to the login page

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari, Internet Explorer

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
pkanher617commented, Mar 23, 2022

Thanks @DerekJDev I got it, reviewing today and will get as soon as I can!

1reaction
msftbot[bot]commented, Mar 8, 2022

This issue requires attention from the MSAL.js team and has not seen activity in 5 days. @pkanher617 please follow up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular MSAL and Azure B2C logout redirecting 3 or more times
I know this redirect needs to happen at least once based on B2C's current functionality.
Read more >
Redirect Users After Logout - Auth0
You can redirect users to a specific URL after they logout. You will need to register the redirect URL in your tenant or...
Read more >
ServiceNow SSO Logout Error (redirects to logout page)
When integrating any SSO with ServiceNow, its very common that the first test of the integration always redirects to logout successful page, I ......
Read more >
Logout endpoint - Amazon Cognito - AWS Documentation
The /logout endpoint signs the user out and redirects either to an authorized sign-out URL for your app client, or to the /login...
Read more >
Dynamic redirect URL after logout from Experience Cloud
Meanwhile I found a workaround to that. One crucial Idea was missing to me at that time. It's that when you remove the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found