【问题标题】:How to enable signing of SAML2 AuthNRequest如何启用 SAML2 AuthNRequest 的签名
【发布时间】:2022-02-07 12:00:57
【问题描述】:

我们有一个配置了 Saml2 以进行身份​​验证的 Spring Boot 应用程序。

我们很难配置 Saml2 AuthNRequest 的签名,因为这个原因在 IDP(即 ADFS,不知道它的版本)中被拒绝。我们尝试禁用签名要求,并且我们的应用程序运行良好。但是,此禁用只是为了测试我们是否已准备就绪。

现在缺少的只是 AuthNRequest 的签名。这个链接似乎有同样的问题:Spring Security SAML: Getting <Signature> block to appear in <AuthnRequest>。它的解决方案似乎是创建WebSSOProfileOptions 并将绑定设置为SAMLConstants.SAML2_POST_BINDING_URI

但似乎存在某种版本不匹配之类的问题。我们根本无法从我们的类路径中找到这个 WebSSPProfileOptions 类。我对这一切都很陌生,包括 gradle,但我们的 gradle 将它作为这样的依赖项:

+--- org.springframework.security:spring-security-saml2-service-provider -> 5.4.7
|    +--- org.opensaml:opensaml-core:3.4.6

我真的希望有办法在配置中说,签名是在 AuthNRequest 消息上完成的。

spring:
  security:
    saml2:
      relyingparty:
        registration:
          my-sp:
            decryption.credentials:
              - private-key-location: "classpath:credentials/my_private_key" 
                certificate-location: "classpath:credentials/my_cert"
            signing.credentials:
              - private-key-location: "classpath:credentials/my_private_key"
                certificate-location: "classpath:credentials/my_cert"
            identityprovider:
              entity-id: http://idp.....
              verification.credentials:
                  - certificate-location: "classpath:credentials/idp......crt"
              singlesignon:
                sign-request: true
                url: https://idp......
              metadata-uri: https://.....

如果无法通过配置强制执行 AuthnRequest 的签名,那么正确的做法是什么。

将这个 WebSSPProfileOptions 降级到类路径中感觉有点苛刻。 spring-security-saml2-core-1.0.10.RELEASE.jar 似乎有它。网页https://spring.io/projects/spring-security-saml 说它正在被https://docs.spring.io/spring-security/site/docs/5.2.1.RELEASE/reference/htmlsingle/#saml2 取代。

简而言之,我们如何使用 spring-security-saml2-service-provider 版本 5.4.7 强制签署 AuthnRequest

【问题讨论】:

  • 旧的 Spring Security SAML 扩展项目已被弃用,取而代之的是 Spring Security 核心中的 spring-security-saml2-service-provider。我不太明白你的问题到底是什么。如果要更改绑定,可以使用singlesignon.binding: "POST"
  • 感谢马库斯的努力。我试图将这个 singlesignon.binding 更改为“POST”,但它只更改为用于 POST 的 HTTP 方法。但是,AuthnRequest 中仍然没有签名。我想知道,究竟是什么触发了 AuthnRequest 的签名。当它失败时,有某种原因的指示会很有用......也许是日志?但我在日志上也看不到任何东西。
  • 您可以调试OpenSamlAuthenticationRequestResolver::resolve 以查看它是如何签署请求的。您是否已将日志级别更改为 TRACE 以便查看日志?

标签: spring-boot spring-security saml-2.0 spring-saml


【解决方案1】:

我会回答我自己的问题,因为我认为我们已经解决了。可能还有一种方法可以在春季强制签署,这确实是我最初的问题的全部内容。

问题是,spring 实现似乎正在寻找 WantAuthnRequestsSigned="true",而我们的 IDP 元数据中缺少它。

  <EntityDescriptor xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
        entityID="http://idp......">
    <IDPSSODescriptor xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
        protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol"
        WantAuthnRequestsSigned="true">

我们设法解决了这个问题,方法是下载 IDP 元数据、添加上述属性并将固定元数据存储在 spring 可以访问的位置。不是一个完美的解决方案,但这是我们目前能做的最好的。

基于这一发现,我认为 IDP 或 spring 代码中存在错误。如果默认值为“true”,则 bug 为 spring。如果为“false”,则该错误在 IDP 中。如果未指定默认行为,那么对每个人来说都是不幸的。

如果我发现了关于这个主题的更多信息,我会在这里更新。

【讨论】:

    猜你喜欢
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 2015-12-03
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多