当您处于回调页面并且用户想要取消注册时如何从外部提供商注销
How to signout from external provider while you are in callback page and the user want to cancel register
当您处于回调页面并且用户想要取消注册时如何从 Saml 外部提供商注销
注意:用户尚未注册,他只是输入外部提供者凭据并重定向到我的 IDP 以输入附加数据,我想添加操作以能够注销和取消注册过程。
注销代码
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", "Account", new { Area = "Identity", logoutId = vm.LogoutId });
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}
return RedirectToPage("Login");
如果我对你的问题的理解正确,这发生在你使用外部身份登录的 ExternalLoginCallback
中,而不是主应用程序身份。
要注销外部身份,请使用示例中的 SignOut 调用:
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url },
vm.ExternalAuthenticationScheme);
如果这只是本地注销或包括重定向到 Idp 的联合注销,则适用 Saml2 的通常规则。
答案只是在当前上下文中设置用户,saml2 可以读取所需的数据进行重定向
Request.HttpContext.User = info.Principal;
当您处于回调页面并且用户想要取消注册时如何从 Saml 外部提供商注销
注意:用户尚未注册,他只是输入外部提供者凭据并重定向到我的 IDP 以输入附加数据,我想添加操作以能够注销和取消注册过程。
注销代码
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", "Account", new { Area = "Identity", logoutId = vm.LogoutId });
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url }, vm.ExternalAuthenticationScheme);
}
return RedirectToPage("Login");
如果我对你的问题的理解正确,这发生在你使用外部身份登录的 ExternalLoginCallback
中,而不是主应用程序身份。
要注销外部身份,请使用示例中的 SignOut 调用:
// this triggers a redirect to the external provider for sign-out
return SignOut(new AuthenticationProperties { RedirectUri = url },
vm.ExternalAuthenticationScheme);
如果这只是本地注销或包括重定向到 Idp 的联合注销,则适用 Saml2 的通常规则。
答案只是在当前上下文中设置用户,saml2 可以读取所需的数据进行重定向
Request.HttpContext.User = info.Principal;