Reputation: 11
Working on an app that will log internal users through AD and external users through B2C. We're using openid. The login process works great for both. Logging out of AD works fine. Logging out of B2C hangs up. Here's the method I'm using to log out:
[Authorize]
public IActionResult LogoutAsync()
{
var scheme = User.Claims.FirstOrDefault(c => c.Type == ".AuthScheme").Value;
return new SignOutResult(new[] { CookieAuthenticationDefaults.AuthenticationScheme, scheme });
}
I get https://localhost:44320/signout-oidc?state=XXXXXXXXXXXXXXXXXXXXX in the URL. Any clues as to what is happening??
Is my only option to use the logoff endpoint, like this (obviously with my information and redirect)? https://{tenant}.b2clogin.com/{tenant}.onmicrosoft.com/{policy}/oauth2/v2.0/logout?post_logout_redirect_uri=https%3A%2F%2Fjwt.ms%2F]
Upvotes: 0
Views: 229
Reputation: 61
I had the same issue and it was because of missing support of Razor pages. The default Microsoft.Identity.Web.UI
SignOut
action uses /Account/SignedOut
Razor page as callback URL.
var callbackUrl = Url.Page("/Account/SignedOut", pageHandler: null, values: null, protocol: Request.Scheme);
I added Razor support in my ASP.NET Core web app, and it fixed the issue:
services.AddRazorPages();
and
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapRazorPages();
});
Alternatively, you can use your own logout endpoint, which can use any action as the signed out callback URL.
Upvotes: 1