此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Security 6.5.0spring-doc.cadn.net.cn

SAML 2.0 扩展迁移

本文档包含将 SAML 2.0 服务提供商从 Spring Security SAML 扩展 1.x 移动到 Spring Security 的指南由于 Spring Security 不提供身份提供程序支持,因此迁移 Spring Security SAML 扩展身份提供程序超出了本文档的范围。spring-doc.cadn.net.cn

由于这两种方法彼此不同,因此本文档将更多地介绍模式,而不是精确的搜索和替换步骤。spring-doc.cadn.net.cn

登录和注销

方法的变化

Spring Security 在几个值得注意的方面与 Spring Security SAML 扩展的方法略有不同。spring-doc.cadn.net.cn

简化的启用

Spring Security SAML 扩展对服务提供商的支持由一系列过滤器提供,这些过滤器通过以正确的顺序手动将每个过滤器添加到各种 Spring Security 过滤器链中来启用。spring-doc.cadn.net.cn

Spring Security 的 SAML 2.0 服务提供商支持是通过 Spring Security DSL 方法启用的:saml2Login,saml2Logoutsaml2Metadata.它选择要添加的正确过滤器,并将它们放在过滤器链中的适当位置。spring-doc.cadn.net.cn

更强的封装

与 Spring Security SAML 扩展一样,Spring Security 的 SAML 支持基于 OpenSAML。扩展项目通过公共接口公开 OpenSAML,模糊了两个项目之间的界限,实际上需要 OpenSAML,并使升级到更高版本的 OpenSAML 变得更加复杂。spring-doc.cadn.net.cn

Spring Security 提供了更强的封装。没有公共接口公开 OpenSAML 组件,任何在其公共 API 中公开 OpenSAML 的类都以OpenSaml前缀以更加清晰。spring-doc.cadn.net.cn

开箱即用的多租户

Spring Security SAML 扩展提供了一些轻量级支持,用于声明多个身份提供者并在登录时使用idprequest 参数。就运行时更改内容而言,这是有限制的,并且也不允许依赖方和断言方之间存在多对多关系。spring-doc.cadn.net.cn

Spring Security 以RelyingPartyRegistration.此组件充当依赖方的元数据和断言方的元数据之间的链接,所有对都可在RelyingPartyRegistrationRepository.每个 URL 都表示要检索的唯一注册对。spring-doc.cadn.net.cn

无论是 AuthnRequests、Responses、LogoutRequests、LogoutResponses 还是 EntityDescriptors,每个过滤器都基于RelyingPartyRegistrationRepository从根本上说,多租户也是如此。spring-doc.cadn.net.cn

示例矩阵

Spring Security 和 Spring Security SAML 扩展都有有关如何配置服务提供者的示例:spring-doc.cadn.net.cn

用例 Spring Security Spring Security SAML 扩展

登录和注销spring-doc.cadn.net.cn

样本spring-doc.cadn.net.cn

样本spring-doc.cadn.net.cn

使用 SAML 扩展 URL 登录spring-doc.cadn.net.cn

样本spring-doc.cadn.net.cn

-spring-doc.cadn.net.cn

元数据支持spring-doc.cadn.net.cn

样本spring-doc.cadn.net.cn

-spring-doc.cadn.net.cn

您还可以在 Spring Security SAML Extension 的 GitHub 项目中看到一个展示示例。spring-doc.cadn.net.cn

Spring Security 不支持 SAML 2.0 响应的 HTTP 重定向绑定。 根据 SAML 规范,由于 URL 长度和签名限制,不允许 SAML 响应使用 HTTP-Redirect 绑定。尝试使用此绑定可能会导致意外错误。 在配置身份提供商时,请改用 HTTP-POST 绑定。spring-doc.cadn.net.cn

未移植的功能

有一些功能尚未移植,目前还没有这样做的计划:spring-doc.cadn.net.cn