首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >net core / IdentityServer :无法注销

net core / IdentityServer :无法注销
EN

Stack Overflow用户
提问于 2019-12-26 16:58:39
回答 2查看 997关注 0票数 1

在我的Blazor应用程序中,我使用身份服务器(identityserver.io)作为外部服务来管理授权。

登录工作正常,但当我尝试注销,然后尝试登录时,我直接登录,而不要求任何用户名/密码!我已经找了一个星期了,没有找到任何解决方案!

我使用以下代码:

代码语言:javascript
复制
    var props = (returnUrl is null) ? null : new AuthenticationProperties()
    {
        RedirectUri = returnUrl
    };

    await HttpContext.SignOutAsync("Cookies");
    await HttpContext.SignOutAsync("oidc", props);

我也试着删除所有的cookie,但HttpContext.Request.Cookies没有cookie!

我还检查了以下链接:https://mcguirev10.com/2018/01/26/signoutasync-and-identity-server-cookies.html,但我没有看到任何有帮助的东西!

仅供参考,下面是我如何设置的:

代码语言:javascript
复制
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
        {
            context.Services.AddAuthentication(options =>
                {
                    options.DefaultScheme = "Cookies";
                    options.DefaultChallengeScheme = "oidc";
                })
                .AddCookie("Cookies", options =>
                {
                    options.ExpireTimeSpan = TimeSpan.FromDays(365);
                    //options.Cookie.Name = ".MyApp";
                })
                .AddOpenIdConnect("oidc", options =>
                {
                    options.Authority = configuration["AuthServer:Authority"];
                    options.RequireHttpsMetadata = true;
                    options.ResponseType = OpenIdConnectResponseType.CodeIdToken;

                    options.ClientId = configuration["AuthServer:ClientId"];
                    options.ClientSecret = configuration["AuthServer:ClientSecret"];

                    options.SaveTokens = true;
                    options.GetClaimsFromUserInfoEndpoint = true;

                    options.Scope.Add("role");
                    options.Scope.Add("email");
                    options.Scope.Add("phone");
                    options.Scope.Add("MyApp");

                    options.ClaimActions.MapAbpClaimTypes();
                });
        }
EN

回答 2

Stack Overflow用户

发布于 2019-12-30 15:11:17

要通过单击链接Click here to return to the Interactive client ....从IDS4注销后重定向回客户端应用程序,您应该在客户端配置中设置正确的PostLogoutRedirectUris

代码语言:javascript
复制
new Client
{
    ....

    // where to redirect to after logout
    PostLogoutRedirectUris = { "http://localhost:5002/signout-callback-oidc" },

     ....
}, 

在@McGuireV10的文章中,他使用身份服务器的演示服务器进行测试,并且使用interactive.confidential.short客户端,您不能设置该客户端的PostLogoutRedirectUris,因此它将默认为https://localhost:5001/signout-callback-oidc。您可以设置自己的身份服务器来测试该方案。

票数 2
EN

Stack Overflow用户

发布于 2022-01-19 18:28:40

对于SignOut,您可以尝试这种方式。应该能行得通。

代码语言:javascript
复制
public class LogoutModel : PageModel
    {
        public async Task<IActionResult> OnGetAsync()
        {
            return SignOut(
                new AuthenticationProperties
                {
                    RedirectUri = "/"
                },
                OpenIdConnectDefaults.AuthenticationScheme,
                CookieAuthenticationDefaults.AuthenticationScheme);
        }
    }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59486045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档