blazor 服务器端 oidc 如何注销?

问题描述 投票:0回答:1

我有一些使用我们公司 oidc 的 blazor 服务器端应用程序

所以我有启动:

builder.Services.AddAuthentication(options =>
{
    options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
    options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
    options.ResponseType = OpenIdConnectResponseType.Code;
    options.Authority = "https://xx.yy.xx/dev";
    options.ClientId = "Dev";
    options.ClientSecret = "Secreeeet";
    options.SaveTokens = true;
    options.GetClaimsFromUserInfoEndpoint = true;
    options.Scope.Add("email");
    options.Scope.Remove("profile");
    options.TokenValidationParameters = new TokenValidationParameters
    {
        NameClaimType = "name"
    };
    options.SignOutScheme = OpenIdConnectDefaults.AuthenticationScheme;
});

这很简单...重定向到登录页面/重定向回来等等。好的

现在我需要一些“注销”按钮 我应该如何编写这个注销方法? 这不是 WebAssembly,因此没有“重定向登录/注销”等方法 那么这个logout应该如何处理呢?

感谢和问候;

c# asp.net-core blazor blazor-server-side logout
1个回答
0
投票

您可以使用以下

  <button href="MicrosoftIdentity/Account/SignOut">
     Logout
  </button>

这将带您注销会话,用户必须单击注销。

© www.soinside.com 2019 - 2024. All rights reserved.