【发布时间】:2023-01-31 01:10:00
【问题描述】:
我们有一个 .NET Core 6 Blazor 服务器应用程序。我们使用 OIDC 使用我们自己的身份提供者登录。我们在注销时遇到问题。
我们使用以下代码块设置了身份验证。
builder.Services
.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddCookie()
.AddOpenIdConnect(opts => {
opts.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
opts.RequireHttpsMetadata = !isDebug;
opts.ClientId = "user-accounts-app";
opts.CallbackPath = "/signin-oidc";
opts.ResponseType = OpenIdConnectResponseType.Code;
opts.Authority = authority;
opts.ClientSecret = builder.Configuration["CLIENT_SECRET"];
var scopes = new List<string>() {
"openid", "profile", "email", "phone", "offline_access"
};
foreach(var s in scopes)
{
opts.Scope.Add(s);
}
});
发现文档确实包含一个end_session_endpoint;但是,端点永远不会被击中。我们尝试从剃刀页面注销
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
// This line does not work
await HttpContext.SignOutAsync(OpenIdConnectDefaults.AuthenticationScheme, new AuthenticationProperties
{
RedirectUri = "http://mydomainhere.com/our/path/here",
});
运行第二个SignOutAsync 似乎什么也没做。身份提供者未在结束会话端点命中,我们的注销页面上没有任何反应。我们的会话没有从 IDP 中清除。
此外,我们的 blazor 应用程序 cookie 并未完全清除。我们有大量挥之不去的.AspNetCorrelation.hash<hash-here>,路径为/signin-oidc(试图获取屏幕截图,但现在服务器出现错误)。但是 .AspNetCore cookie 被第一个 SignOutAsync 调用成功清除。
我不确定第二个 SignOutAsync 的行为应该是什么。它会将用户重定向到 IDP 的注销 url 吗?还是它在后台执行此操作?我们在调用 AddOpenIdConnect() 以处理注销时是否缺少某些配置?
【问题讨论】:
-
服务器还是 WASM?身份验证提供者在哪里/谁
-
这事有进一步更新吗?
标签: c# asp.net-core authentication blazor openid-connect