하늘빛 광고 b2c에서 webapp을 로그 아웃하고 싶습니다. 나는이 샘플 https://www.janaks.com.np/azure-ad-identity-provider-in-aspnet-core-application/에서 제안 된 것과 같이 다음을 시도했다. Startup.cs에서 다음과 같은 구성으로Azure 광고 로그 아웃
if (HttpContext.User.Identity.IsAuthenticated)
{
await HttpContext.Authentication.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme);
await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
:
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
AuthenticationScheme = settings.SignInPolicyId,
AutomaticChallenge = true,
CallbackPath = settings.SignInCallbackPath,
ClientId = settings.ClientId,
MetadataAddress = string.Format(settings.AadInstance, settings.Tenant, settings.SignInPolicyId),
PostLogoutRedirectUri = settings.RedirectUri,
TokenValidationParameters = new TokenValidationParameters
{
NameClaimType = "name"
},
AutomaticAuthenticate = true,
Scope = { "openid" },
ResponseType = "id_token",
GetClaimsFromUserInfoEndpoint = true
});
하지만 던져 질 것이다 예외 다음과 같은 웹 애플리케이션에서 로그 아웃 할 때 :
InvalidOperationException: No authentication handler is configured to handle the scheme: OpenIdConnect
감사를 도와 . 당신은 어떻게 든이 컨트롤러에 정책 ID를 얻고 적절한 미들웨어를 식별하는 데 사용해야합니다
if (HttpContext.User.Identity.IsAuthenticated)
{
await HttpContext.Authentication.SignOutAsync(settings.SignInPolicyId);
await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
}
: