当用户注销 IdentityServer并且他们使用外部身份提供程序登录时,可能会将其重定向到注销外部提供程序。并非所有外部提供商都支持注销,因为它取决于它们支持的协议和功能。

要检测是否必须将用户重定向到外部身份提供程序以进行注销通常是通过使用idp在IdentityServer中发布到cookie中的声明来完成的。设置到此声明中的值是AuthenticationScheme相应的身份验证中间件。在签出时,咨询此声明以了解是否需要外部签出。

由于正常注销工作流程已经需要清理和状态管理,因此将用户重定向到外部身份提供商是有问题的。然后,在IdentityServer完成正常注销和清理过程的唯一方法是从外部身份提供程序请求在注销后将用户重定向回IdentityServer。并非所有外部提供商都支持退出后重定向,因为它取决于它们支持的协议和功能。

然后,注销的工作流程将撤消IdentityServer的身份验证cookie,然后重定向到请求注销后重定向的外部提供程序。退出后重定向应保持此处描述的必要签出状态(即logoutId参数值)。要在外部提供程序注销后重定向回IdentityServer,RedirectUri应该AuthenticationProperties在使用ASP.NET Core的SignOutAsyncAPI 时使用,例如:

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout(LogoutInputModel model)
{
// build a model so the logged out page knows what to display
var vm = await _account.BuildLoggedOutViewModelAsync(model.LogoutId); var user = HttpContext.User;
if (user?.Identity.IsAuthenticated == true)
{
// delete local authentication cookie
await HttpContext.SignOutAsync(); // raise the logout event
await _events.RaiseAsync(new UserLogoutSuccessEvent(user.GetSubjectId(), user.GetName()));
} // 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);
} return View("LoggedOut", vm);
}

一旦用户退出外部提供程序然后重定向回来,IdentityServer的正常注销处理应该执行,这涉及处理logoutId和执行所有必要的清理。

github地址

第25章 退出外部身份提供商 - Identity Server 4 中文文档(v1.0.0)的更多相关文章

  1. 第17章 社区快速入门和模板 - Identity Server 4 中文文档(v1.0.0)

    IdentityServer组织不维护这些示例.IdentityServer组织愉快地链接到社区模板,但不能对模板做出任何保证.请直接与作者联系. 17.1 各种ASP.NET核心安全样本 https ...

  2. 第12章 添加对外部认证的支持 - Identity Server 4 中文文档(v1.0.0)

    注意 对于任何先决条件(例如模板),首先要查看概述. 接下来,我们将添加对外部认证的支持.这非常简单,因为您真正需要的是ASP.NET Core兼容的身份验证处理程序. ASP.NET Core本身支 ...

  3. 第9章 使用客户端凭据保护API - Identity Server 4 中文文档(v1.0.0)

    快速入门介绍了使用IdentityServer保护API的最基本方案. 我们将定义一个API和一个想要访问它的客户端. 客户端将通过提供ClientCredentials在IdentityServer ...

  4. 第59章 IdentityServer交互服务 - Identity Server 4 中文文档(v1.0.0)

    IIdentityServerInteractionService接口旨在提供用户界面用于与IdentityServer通信的服务,主要与用户交互有关.它可以从依赖注入系统获得,通常作为构造函数参数注 ...

  5. 第27章 联合网关 - Identity Server 4 中文文档(v1.0.0)

    通用架构是所谓的联合网关.在此方法中,IdentityServer充当一个或多个外部身份提供商的网关. 该架构具有以下优点: 您的应用程序只需要了解一个令牌服务(网关),并且屏蔽了有关连接到外部提供程 ...

  6. 第26章 联合注销 - Identity Server 4 中文文档(v1.0.0)

    联合注销是指用户使用外部身份提供程序登录IdentityServer,然后用户通过IdentityServer未知的工作流程注销该外部身份提供程序的情况.当用户注销时,对IdentityServer进 ...

  7. 第65章 博客帖子 - Identity Server 4 中文文档(v1.0.0)

    第65章 博客帖子 65.1 团队帖子 65.1.1 2019 IdentityServer中的范围和声明设计 尝试使用IdentityServer4的设备流程 OAuth2中隐含流的状态 另一种保护 ...

  8. 第2章 术语 - Identity Server 4 中文文档(v1.0.0)

    规范.文档和对象模型等都使用特定的术语来表述. 2.1 IdentityServer IdentityServer是OpenID Connect提供程序 - 它实现OpenID Connect和OAu ...

  9. 第22章 使用外部身份提供商登录 - Identity Server 4 中文文档(v1.0.0)

    ASP.NET Core有一种灵活的方式来处理外部身份验证.这涉及几个步骤. 注意 如果您使用的是ASP.NET Identity,则会隐藏许多基础技术细节.建议您还阅读Microsoft 文档并执行 ...

随机推荐

  1. position属性sticky和fixed的区别比较

    position属性之fixed fixed总是以body为定位时的对象,总是根据浏览器窗口来进行元素的定位,通过left,right,top,bottom属性进行定位. <!DOCTYPE h ...

  2. Android完全退出应用的方法

    退出程序 public static void exitApp(Context context){ ActivityManager activityManager = (ActivityManager ...

  3. CentOS 编译安装 Redis (实测 笔记 Centos 7.3 + redis 3.2.8)

    环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) 系统版本:CentOS-7.0-1406-x86_64-DVD.iso 安装步骤: 1.准备 1.1 显示系统版 ...

  4. Hadoop集群搭建-HA高可用(手动切换模式)(四)

    步骤和集群规划 1)保存完全分布式模式配置 2)在full配置的基础上修改为高可用HA 3)第一次启动HA 4)常规启动HA 5)运行wordcount 集群规划: centos虚拟机:node-00 ...

  5. node.js Setup Wizard ended prematurely 安装失败

    解决: 1. 按照管理员权限运行. 2.安装时禁用掉node 运行环境中的performance counters 和 ETW,或者可以尝试先禁用performance counters .

  6. 在Linux上要安装SSH协议

    学习准备:博客园.CSDN.51CTO,注意问问题去CSDN.注意还有一种就是自己搭建博客,自己搭建博客相当于写一个网站:http://pyshell.cn;github:是一个代码仓库是别人的.有些 ...

  7. Unity进阶----AssetBundle_03(2018/11/07)

    1. 为啥有AB包? 因为资源需要更新, 避免更新一次打包一次 动态修改. 2. AB包注意啥? 依赖关系 找依赖关系应该找到对应的平台!!! 3. 打包策略是分场景打包 若文件被文件夹包含打包出来的 ...

  8. CMS使用对应版本当作新项目。

    document.form1 整体替换document.forms[0] document.Templetslist 整体替换document.forms[0] document.f_Upload整体 ...

  9. 【RL-TCPnet网络教程】第26章 RL-TCPnet之DHCP应用

    第26章     RL-TCPnet之DHCP应用 本章节为大家讲解RL-TCPnet的DHCP应用,学习本章节前,务必要优先学习第25章的DHCP基础知识.有了这些基础知识之后,再搞本章节会有事半功 ...

  10. 高性能网络服务器编程:为什么linux下epoll是最好,Netty要比NIO.2好?

    基本的IO编程过程(包括网络IO和文件IO)是,打开文件描述符(windows是handler,java是stream或channel),多路捕获(Multiplexe,即select和poll和ep ...