AzureAD / microsoft-identity-web

Helps creating protected web apps and web APIs with Microsoft identity platform and Azure AD B2C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Signout stays on MicrosoftIdentity/Account/SignedOut instead of redirecting to login or index page (Blazor server webApp, B2C)

chamchum opened this issue · comments

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

2.18.0

Web app

Sign-in users and call web APIs

Web API

Protected web APIs (validating scopes/roles)

Token cache serialization

In-memory caches

Description

Updating Microsoft.Identity.Web.UI to latest (2.18.0 as for now down to at least 2.17.0) breaks a signout flow in web app.

Reproduction steps

  1. Get sample solution at https://github.com/Azure-Samples/ms-identity-blazor-server/tree/main/WebApp-your-API/B2C. (Commit at that time: 8d993867b67a0c1f790e1c92dee99121320ce1cf) It has "Microsoft.Identity.Web.UI" Version="2.6.1".
  2. Update Microsoft.Identity.Web and Microsoft.Identity.Web.UI to 2.17.0 or 2.18.0.
  3. Run blazorserver-client project.
  4. Signup/Signin. Everything works perfect.
  5. Signout. User stays on https://localhost:xxxxx/MicrosoftIdentity/Account/SignedOut. Although it should redirect to login page or localhost index.

Error message

No response

Id Web logs

No response

Relevant code snippets

1. Get sample solution at [https://github.com/Azure-Samples/ms-identity-blazor-server/tree/main/WebApp-your-API/B2C](url). (Commit at that time: 8d993867b67a0c1f790e1c92dee99121320ce1cf)
2. Update Microsoft.Identity.Web and Microsoft.Identity.Web.UI to 2.17.0 or 2.18.0.

Regression

2.6.1

Expected behavior

After signout user should be redirected back to signup/signin as required by Index.razor page which requires authentication using user flow from Azure.

This helps:
https://github.com/AzureAD/microsoft-identity-web/wiki/Customization#ui-customization

But I think there should be easier and more obvious way to do it. There is attached closed issue discussion. Not sure why it is closed.

As it was recommended

  1. I added SignedOut.cshtml to project under Areas/MicrosoftIdentity/Pages/Account;
  2. Added following to the page:
@page "/MicrosoftIdentity/Account/SignedOut"
@model <ProjectNamespace>.Areas.MicrosoftIdentity.Pages.Account.IndexModel
@{
    Response.Redirect($"{Request.PathBase}/"); // To navigate to route of the webApp. Place whatever you want here.
}
  1. [Optional] Made SignedOut page anonymous.
builder.Services.AddRazorPages(options =>
    options.Conventions.AllowAnonymousToAreaPage("MicrosoftIdentity", "/Account/SignedOut"));