【发布时间】:2019-06-06 11:57:51
【问题描述】:
我想在用户从该客户端注销后将其重定向到同一客户端。因此,如果我在一台身份服务器上有 5 个客户端,我希望用户能够从一个客户端注销并在同一客户端上但已注销。
我尝试过的一件事是在快速入门的 AccountController 中使用 PostLogoutRedirectUri,但该值始终为空。我发现的解决方法是手动设置 PostLogoutRedirectUri,如果您在服务器上只有一个客户端,它可以正常工作,但如果我有多个客户端,则效果不佳。有没有办法知道哪个客户端被“注销”了?
public async Task<IActionResult> Logout(LogoutInputModel model)
{
// build a model so the logged out page knows what to display
var vm = await BuildLoggedOutViewModelAsync(model.LogoutId);
if (User?.Identity.IsAuthenticated == true)
{
// delete local authentication cookie
await HttpContext.SignOutAsync();
// raise the logout event
await _events.RaiseAsync(new UserLogoutSuccessEvent(User.GetSubjectId(), User.GetDisplayName()));
}
// check if we need to trigger sign-out at an upstream identity provider
if (vm.TriggerExternalSignout)
{
// build a return URL so the upstream provider will redirect back
// to us after the user has logged out. this allows us to then
// complete our single sign-out processing.
string url = Url.Action("Logout", new { logoutId = vm.LogoutId });
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}
vm.PostLogoutRedirectUri = "http://localhost:56582";
return Redirect(vm.PostLogoutRedirectUri);
}
我的客户
new Client
{
ClientId = "openIdConnectClient",
ClientName = "Implicit Client Application Name",
AllowedGrantTypes = GrantTypes.Implicit,
AllowedScopes = new List<string>
{
IdentityServerConstants.StandardScopes.OpenId,
IdentityServerConstants.StandardScopes.Profile,
IdentityServerConstants.StandardScopes.Email,
"role",
"customAPI.write"
},
RedirectUris = new List<string>{ "http://localhost:56582/signin-oidc" },
PostLogoutRedirectUris = new List<string>{ "http://localhost:56582" },
// FrontChannelLogoutUri = "http://localhost:56582/signout-oidc"
}
【问题讨论】:
-
PostLogoutRedirectUri 是你为每个客户端配置的东西,如果你配置它不应该为空。您没有显示您的代码如何设置您的客户端。
-
我已经用客户端代码更新了信息
-
我有一个与 IdServer here 的开源集成,它在注销后会正确重定向。 source code here 我的 idserver 注销操作接受我与 IIdentityServerInteractionService.GetLogoutContext(logoutid) 一起使用的 logoutId,它为我返回客户端 PostLogoutRedirectUri。
-
为什么我的 postlogoutredirecturi 在我的客户端中设置为空?
标签: c# asp.net-core identityserver4