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 Redirection issue

See original GitHub issue

Core Library

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

Core Library Version

2.14.1

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

2.0.0-beta.5

Description

There is a mismatch about what the documentation says about the post logout redirection and what actually happens. I will try to elaborate. The documentation can be found here.

postLogoutRedirectUri is required in order for MSAL to be able to close the popup when signout is complete

If I don’t set the postLogoutRedirectUri, the popup still closes.

postLogoutRedirectUri will be opened in the popup window, not the main frame. If you need your top level app to be redirected after logout you can use the mainWindowRedirectUri parameter on the logout request.

If I set the postLogoutRedirectUri, I am not sure if the URI is opened in the popup window, but what I am experiencing is that it is opening in the main frame for sure. I can not find a difference between the postLogoutRedirectUri and the mainWindowRedirectUri inside of the logout request.

Error Message

No response

Msal Logs

No response

MSAL Configuration

{
  auth: {
    clientId: environment.AzureClientId,
    authority: b2cPolicies.authorities.signUpSignIn.authority,
    redirectUri: environment.FrontendBaseUrl,
    postLogoutRedirectUri: environment.FrontendBaseUrl,
    knownAuthorities: [environment.AzureB2CKnownAuthority],
  },
  cache: {
    cacheLocation: BrowserCacheLocation.LocalStorage,
    storeAuthStateInCookie: isIE, // set to true for IE 11
  },
}

Relevant Code Snippets

if (this.msalGuardConfig.interactionType === InteractionType.Popup) {
  return this.msal.logoutPopup({
    mainWindowRedirectUri: "/logout"
  });
} else {
  return this.msal.logoutRedirect();
}
if (this.msalGuardConfig.interactionType === InteractionType.Popup) {
  return this.msal.logoutPopup({
    postLogoutRedirectUri: "/logout"
  });
} else {
  return this.msal.logoutRedirect();
}

Both main frmes land in the /logout page.

Reproduction Steps

  1. Logout

Expected Behavior

I am not sure what the correct behavior should be, but either the docs or the behavior should be updated to match each other.

Identity Provider

Azure B2C Basic Policy

Browsers Affected (Select all that apply)

Edge

Regression

No response

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tnorlingcommented, May 10, 2021

@eluchsinger This was in reference to your first question about why the popup still closes despite not including postLogoutRedirectUri on the request object.

postLogoutRedirectUri -> navigated to in the popup window mainWindowRedirectUri -> navigated to in the main window

Can you please provide logs and/or a link to a minimal reproduction? The main window should not be redirecting at all if mainWindowRedirectUri is not set on the request.

0reactions
msftbot[bot]commented, Jun 7, 2021

@eluchsinger This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Issue with Redirection After Logout - Caspio Online Help
This article addresses an issue that you are always redirected to the root folder of your website after logout from your Caspio application....
Read more >
Logout Redirect issue - WordPress.org
Hi,. I do have the issue that the redirect after logout does not work. It always sends me to the main page instead...
Read more >
Logout Redirect Issue - Google Groups
I am working on upgrading our CAS instance from 6.1 to 6.5. I have been able to get everything working as expected except...
Read more >
Issues for Logout Redirect | Drupal.org
Title Status Priority Category Version Compo... Automated Drupal 10 compatibility fixes Needs review Normal Task 2.0.0 Code Automated Drupal 10 compatibility fixes Needs review Normal...
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