Spring Security SAML2 服务提供者 - RelyingPartyRegistration.entityId() vs RelyingPartyRegistration.assert

Posted

技术标签:

【中文标题】Spring Security SAML2 服务提供者 - RelyingPartyRegistration.entityId() vs RelyingPartyRegistration.assertingPartyDetails(c -> c.entityId())【英文标题】:Spring Security SAML2 service provider - RelyingPartyRegistration.entityId() vs RelyingPartyRegistration.assertingPartyDetails(c -> c.entityId()) 【发布时间】:2021-09-04 06:52:55 【问题描述】:

请教关于 Spring Security SAML2 的小问题。

为了缩小范围,问题是:

 <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-saml2-service-provider</artifactId>
<version>5.5.0</version>
        </dependency>

我来自旧版本,其中 API 已弃用。

新版的RelyingPartyRegistration好像有两个entityId,有点迷惑,请问哪个是哪个?

      return RelyingPartyRegistration.withRegistrationId(registrationId)
                .entityId(entityId)
                .assertingPartyDetails(details -> details.entityId(entityId)).build();

查看这段代码,entityId 出现了两次。

请问有什么区别?

谢谢

【问题讨论】:

一个是依赖方(您的 Spring 应用程序)的实体 ID,另一个是断言方的实体 ID。您可能会发现此 SAML 图很有用docs.spring.io/spring-security/site/docs/current/reference/… 【参考方案1】:

RelyingPartyRegistration.withRegistrationId(registrationId) .entityId(entityId)

表示在身​​份提供者上注册的实体id。它是身份提供者知道您的应用的标识符。

.assertingPartyDetails(details -&gt; details.entityId(entityId))是实体提供者网站的url。

【讨论】:

以上是关于Spring Security SAML2 服务提供者 - RelyingPartyRegistration.entityId() vs RelyingPartyRegistration.assert的主要内容,如果未能解决你的问题,请参考以下文章