我正在asp.net核心应用程序中使用login.gov。我使用Identity Server 4进行设置,允许用户使用Azure AD,Google和Login.gov登录。我可以全部登录/注销,但是loging.gov需要调用以下URL https://idp.int.identitysandbox.gov/openid_connect/logout?带有查询字符串参数
id_token_hintpost_logout_redirect_uri状态
在Identity Server的注销过程中,如何捕获这些其他参数?
当前,使用它正在执行的快速入门之一
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);
}
我已经为该外部提供程序连接了启动类
options.Events = new OpenIdConnectEvents
{
OnRedirectToIdentityProviderForSignOut = context =>
{
string tokenHint = context.ProtocolMessage.IdTokenHint;
var postLogoutUri = context.Properties.RedirectUri;
if (!string.IsNullOrEmpty(postLogoutUri))
{
if (postLogoutUri.StartsWith("/"))
{
// transform to absolute
var request = context.Request;
//postLogoutUri = request.Scheme + "://" + request.Host + request.PathBase + postLogoutUri;
postLogoutUri = request.Scheme + "://" + request.Host + postLogoutUri;
}
}
var logoutUri = $"{appConfig.LoginGov.Domain}/openid_connect/logout?id_token_hint={tokenHint}&post_logout_redirect_uri={postLogoutUri}&state={state}";
context.Response.Redirect(logoutUri);
context.HandleResponse();
return Task.CompletedTask;
}
};
这将执行,但是我无法捕获id_token_hint和状态参数。想法?
我认为我可以在Logout方法中捕获并作为身份验证参数发送,但我也无法在其中捕获它。
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
请参阅此文档:https://identityserver4.readthedocs.io/en/release/endpoints/endsession.html?highlight=id_token_hint
[用户登录后,身份服务器发送id_token,即id_token_hint。如果id_token_hint有效,则显示注销确认页面。如果endsession具有正确的post_logout_redirect_uri,则它直接注销用户,并使用endsession请求中发送的状态参数重定向回post_logout_redirect_uri。