【发布时间】: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