简体   繁体   中英

Azure B2C Logout implementation in ASP.NET Core?

I'm working on a project that requires a B2C implementation and it's my first time using or even hearing about it so bear with me. How do I implement logging out or session invalidation with this Azure service?

I got the sign in and up policy working, but currently I can't find any documentation on how to implement logging out other than this https://docs.microsoft.com/en-us/azure/active-directory-b2c/session-behavior?pivots=b2c-user-flow , which I don't understand for the life of me.

What's the easiest and best practice way of implementing B2C sign out functionality with an ASP.NET Core web app. Help is much appreciated. I don't have any code to offer because not one thing I've tried has worked. I understand that in older version you could just call a tenant customised URL to logout off a session, but I can't find this documented anywhere and I can't tell whether it's legacy or not.

Add an account controller to get more control https://docs.microsoft.com/en-us/azure/active-directory-b2c/enable-authentication-web-application-options#add-the-account-controller

Then add the sign out path in account controller

[HttpGet("{scheme?}")]
public async Task<IActionResult> SignOutAsync([FromRoute] string scheme)
{
    scheme ??= OpenIdConnectDefaults.AuthenticationScheme;
    return SignOut(properties,CookieAuthenticationDefaults.AuthenticationScheme,scheme);
}

This document explains how to send a sign out request manually: https://docs.microsoft.com/en-us/azure/active-directory-b2c/openid-connect#send-a-sign-out-request

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM