You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Security 2.5.0 SAML API弃用后RelyingPartyRegistration配置咨询

适配Spring Security 5.5.0的SAML配置解决方案

完整适配代码

// 原有凭证获取逻辑无需修改
Saml2X509Credential signingCredential = getSigningCredential();
Saml2X509Credential idpVerificationCertificate = getVerificationCertificate();
// ACS地址模板和旧版写法完全一致
String acsLocation = "{baseUrl}" + Saml2WebSsoAuthenticationFilter.DEFAULT_FILTER_PROCESSES_URI;

return RelyingPartyRegistration.withRegistrationId(registrationId)
        // 原localEntityIdTemplate替换为entityIdTemplate
        .entityIdTemplate(localEntityIdTemplate)
        // 原assertionConsumerServiceUrlTemplate替换为assertionConsumerServiceLocation,参数规则不变
        .assertionConsumerServiceLocation(acsLocation)
        // SP本地签名、解密凭证配置逻辑不变
        .credentials(c -> c.add(signingCredential))
        // IDP相关配置统一迁移到assertingPartyDetails配置块
        .assertingPartyDetails(party -> party
                // 原remoteIdpEntityId替换为entityId
                .entityId(idpEntityId)
                // 原idpWebSsoUrl替换为singleSignOnServiceLocation
                .singleSignOnServiceLocation(webSsoEndpoint)
                // IDP签名校验凭证放到断言方配置的credentials中
                .credentials(c -> c.add(idpVerificationCertificate))
        )
        .build();

参数说明

  • assertionConsumerServiceLocation的入参规则和旧版assertionConsumerServiceUrlTemplate完全一致,原生支持{baseUrl}(运行时自动替换为当前应用的访问根地址)、{registrationId}(自动替换为当前SAML注册ID)两个占位符,不需要手动拼接实际部署域名,沿用你之前的模板写法即可。
  • 如果业务需要自定义ACS路径,也可以直接传入固定的绝对路径,例如https://你的业务域名/自定义/saml/回调路径。
  • 所有原IDP侧的配置项都需要迁移到assertingPartyDetails的回调方法中,旧版顶层的IDP配置方法已全部弃用。

内容的提问来源于stack exchange,提问作者PatPanda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.18 11:45:07