我试图让 IdentityServer4 在新的 .NET Core 2.1 应用程序中工作(它在 .NET Core 2.0 应用程序中完美运行)。我尝试了以下方法:
1)下载这个项目,即IdentityServer4应用:https : //github.com/ghstahl/IdentityServer4-Asp.Net-2.1-Identity-Examples/tree/e0aeeff7e078aa082c8e16029dd2c220acc77d7b
2)下载这个项目,它是使用Identity Server4应用的MVC应用:https : //github.com/IdentityServer/IdentityServer4.Samples/tree/dev/Quickstarts/6_AspNetIdentity/src/MvcClient。
3) 将两个项目添加到同一个解决方案中。MVC项目使用IdentityServer项目进行认证;授权等
我必须进行以下更改:
1) 更改 IdentityServer 应用程序中包含的 Startup(AddIdentityServer 现在接受一个参数):
services.AddIdentityServer(options =>
{
options.UserInteraction.LoginUrl = "/Identity/Account/Login";
options.UserInteraction.LogoutUrl = "/Identity/Account/Logout";
})
2) 将 IdentityServer 应用程序配置为侦听端口 5000 并在身份服务器上禁用 SSL。
除了注销功能外,一切都按预期开箱即用。当我在 MVC 应用程序中单击注销时;在 MVC 应用程序中调用以下代码:
public async Task Logout()
{
await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("oidc");
}
然后将用户重定向到 IdentityServer 应用程序中的 Logout.cshtml。但是,他们必须再次单击注销(在 IdentityServer 应用程序上)才能实际注销,即他们在 MVC 应用程序中单击注销(第二点),然后在 IdentityServer 中注销(第一点)。
为什么最终用户必须注销两次?
喵喔喔
www说
繁花不似锦
相关分类