Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Power Apps Portals
Answered

Dynamics 365/PowerApps Portal Azure AD B2C logout issue

(0) ShareShare
ReportReport
Posted on by 12

I have a Microsoft hosted Portal configured with a Dynamics 365 CE instance. 

The authentication is configured to use Azure AD B2C and this is working properly.

 

The issue I have is when a user chooses the "sign out" link their session is ended but the user is not redirected to the page they were on when the logged off (the returnUrl specified in the query string)

/en-US/Account/Login/LogOff?returnUrl=%2test%2F

From tracking the flow using Fiddler it looks like the portal is not passing the return URL to B2C and is instead passing the root URL. This process does work if I use a portal "local account" so it seems to be related to how the portal calls the logoff for B2C.

 

From /_services/about the version is 9.2.4.66

 

Does anyone have a workaround for this or is this a bug in the portal?

 

Thanks

  • zebra1024 Profile Picture
    12 on at
    Re: Dynamics 365/PowerApps Portal Azure AD B2C logout issue

    I added this to the Microsoft ideas site at https://experience.dynamics.com/ideas/idea/?ideaid=f5cda878-3c9c-ea11-8b71-0003ff688f7a 

  • Verified answer
    zebra1024 Profile Picture
    12 on at
    Re: Dynamics 365/PowerApps Portal Azure AD B2C logout issue

    I worked this issue with Microsoft support.

     

    The solution was to set the portal setting "Authentication/OpenIdConnect/B2C/ExternalLogoutEnabled" to false. This will redirect the user on logout. What it changes is that the user is not logged out of Azure AD B2C so if they immediately try to sign back in they will not have to authenticate with Azure AD B2C. I believe this could be fixed by Microsoft in the Portal code if they properly set the  "post_logout_redirect_uri" in the logout call to B2C to the current URL.

     

    Authentication/OpenIdConnect/[Federation-Name]/ExternalLogoutEnabled

    Enables or disables federated sign-out. When set to true, users are redirected to the federated sign-out user experience when they sign out from the portal. When set to false, users are signed out from the portal only. By default, it is set to false.

    For reference: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/azure-ad-b2c

  • zebra1024 Profile Picture
    12 on at
    Re: Dynamics 365/PowerApps Portal Azure AD B2C logout issue

    Thanks for your detailed reply.

    I am using Azure AD B2C for authentication - you mention Azure AD in your reply.

     

    In Fiddler this seems to be the flow:

    I start on the page /en-US/FieldService/

    1) When I click "Sign Off" I am navigated to the following URL which looks good (returnUrl is set properly to the deep link)

    Get https://xxx.microsoftcrmportals.com/en-US/Account/Login/LogOff?returnUrl=%2Fen-US%2FFieldService%2F

    2) This returns a 302 with the following redirect URL

     https://login.microsoftonline.com/te/{id}/b2c_1_signuporsignin/oauth2/v2.0/logout?post_logout_redirect_uri=https%3A%2F%2xxx.microsoftcrmportals.com&redirect_uri=https%3A%2F%2xxx.microsoftcrmportals.com%2Fsignin-b2c

    3) B2C does the logout and returns JavaScript code that does a window.location.replace using the URL https://xxx.microsoftcrmportals.com/ which does not include the path

     

    The issue seems to be in step 2 the Portal is not properly setting the post_logout_redirect_uri using the passed returnUrl query string parameter (/en-US/FieldService/).

  • v-siky-msft Profile Picture
    on at
    Re: Dynamics 365/PowerApps Portal Azure AD B2C logout issue

    Hi @zebra1024 ,

     

    I made a test on my portal logged in via Azure AD authentication, but the redirection works correctly when logging off, the ReturnURL always links to the previous page properly.

    Snipaste_2020-05-04_14-38-16.png

    Here are some suggestions:

    1. deactivate AzureAD Authentication and re-active it again.

    2. clear all browser cookies and cache or change another browser

    3. Check the Web Template called "Header" to see if the logout section in source control is changed.

     <a role="menuitem" aria-label="{{ snippets["links/logout"] | default:resx["Sign_Out"] | h | escape }}" href="{% if homeurl%}/{{ homeurl }}{% endif %}{{ website.sign_out_url_substitution }}" title="{{ snippets["links/logout"] | default:resx["Sign_Out"] | h | escape }}">
     {{ snippets["links/logout"] | default:resx["Sign_Out"] | h | escape }}

    Snipaste_2020-05-04_14-59-17.png

    Hope this helps.

    Sik

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Lucas001 Profile Picture

Lucas001 60 Super User 2025 Season 1

#2
Fubar Profile Picture

Fubar 55 Super User 2025 Season 1

#3
surya narayanan Profile Picture

surya narayanan 35