带有Adfs 2016 OpenId的Aspnet Core无法注销 [英] Aspnet Core with Adfs 2016 OpenId can't sign out
问题描述
我用针对Net461的Aspnet Core设置了一个MVC项目。身份验证配置为使用Windows Server 2016系统中的Adfs。我设法使登录正常工作,但是,当我单击退出时,出现页面无法显示错误。浏览回主页URL显示该用户也仍在登录。有什么建议么?
I setup an MVC project with Aspnet Core targeting Net461. Authentication is configured to use Adfs from a Windows Server 2016 system. I managed to get sign in working, however, when I click sign out I am given a page cannot be displayed error. Browsing back to the home url shows that the user is still logged in also. Any suggestions?
推荐答案
您可能会发现此示例有用(即使它适用于Azure ADFS,也适用于本地安装):< a href = https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-aspnetcore rel = nofollow noreferrer> https://github.com/Azure-Samples/active-directory -dotnet-webapp-openidconnect-aspnetcore
You might find this sample useful (even though it is for Azure ADFS, it works for local installs as well): https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect-aspnetcore
像下面这样的注销操作方法在我的情况下效果很好:
The logout action method like the following work well in my case:
[HttpGet]
public IActionResult SignOut()
{
var callbackUrl = Url.Action(nameof(SignedOut), "Account", values: null, protocol: Request.Scheme);
return SignOut(
new AuthenticationProperties { RedirectUri = callbackUrl },
CookieAuthenticationDefaults.AuthenticationScheme,
OpenIdConnectDefaults.AuthenticationScheme);
}
这会将您重定向到 / Account / SignedOut
完成后,您还需要为客户端注册 / signout-callback-oidc
端点。该端点(默认情况下)由OIDC ASP.NET Core中间件使用。
This will redirect you to the /Account/SignedOut
after it completes and you need to register your /signout-callback-oidc
endpoint for your client as well. This endpoint is used (by default) by the OIDC ASP.NET Core middleware.
这篇关于带有Adfs 2016 OpenId的Aspnet Core无法注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!