【问题标题】:Issues while integrating ADFS with Spring SAML Extension将 ADFS 与 Spring SAML 扩展集成时的问题
【发布时间】:2014-11-25 21:32:28
【问题描述】:

我正在努力将 Spring SAML 扩展集成到我们的应用程序中,并将 SSO 与我们客户的 ADFS2.0 之一作为 IDP 我们从我们的应用程序生成服务提供商元数据并将 ADFS 元数据导入我们的应用程序。当我选择客户端 idp 并单击开始单点登录并提供正确的客户端凭据,我们看到 SAML 响应如下:

Saml 响应。

<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"  Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"  
Destination="https://sso.spire2grow.com:8443/<our application>/saml/SSO" ID="_d7fa7cb7-a858-4d4e-aa4c-bf7a5d11e485" 
InResponseTo="a2icei36d347di68gi33534cc13fd1" IssueInstant="2014-09-30T14:17:21.819Z" Version="2.0"><Issuer 
xmlns="urn:oasis:names:tc:SAML:2.0:assertion"><Clients ADFS trust services URL></Issuer><samlp:Status><samlp:StatusCode 
Value="urn:oasis:names:tc:SAML:2.0:status:Responder"></samlp:StatusCode></samlp:Status></samlp:Response>

但我也看到由于服务提供商无法验证消息而引发以下异常。

异常信息:

[351545]2014-09-30 19:47:21,714 DEBUG - SAML message intended destination endpoint matched recipient endpoint
[351545]2014-09-30 19:47:21,714 DEBUG - Authentication attempt using org.springframework.security.saml.SAMLAuthenticationProvider
[351545]2014-09-30 19:47:21,715 DEBUG - Error validating SAML message
org.opensaml.common.SAMLException: Response has invalid status code urn:oasis:names:tc:SAML:2.0:status:Responder, status message is null
    at org.springframework.security.saml.websso.WebSSOProfileConsumerImpl.processAuthenticationResponse(WebSSOProfileConsumerImpl.java:113)
    at org.springframework.security.saml.SAMLAuthenticationProvider.authenticate(SAMLAuthenticationProvider.java:82)
    at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
    at org.springframework.security.saml.SAMLProcessingFilter.attemptAuthentication(SAMLProcessingFilter.java:84)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:195)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)

如果我在这里遗漏任何东西,请任何人指出。

更新:

在看到为这个问题提供的答案后 我从 ADFS 中看到了以下错误。

Microsoft.IdentityServer.Protocols.Saml.SamlProtocolSignatureAlgorithmMismatchException: MSIS7093: The message is not signed with expected signature algorithm. Message is signed with signature algorithm http://www.w3.org/2000/09/xmldsig#rsa-sha1. Expected signature algorithm http://www.w3.org/2001/04/xmldsig-more#rsa-sha256. at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolManager.ValidateSignatureRequirements(SamlMessage samlMessage) at Microsoft.IdentityServer.Web.Protocols.Saml.SamlProtocolManager.Issue(HttpSamlRequestMessage httpSamlRequestMessage, SecurityTokenElement onBehalfOf, String sessionState, String relayState, String& newSamlSession, String& samlpAuthenticationProvider, Boolean isUrlTranslationNeeded, WrappedHttpListenerContext context, Boolean isKmsiRequested)

但是在看到这个之后,我们确实将依赖信任方的签名算法更改为 rsa-sha256,但仍然显示相同的消息。

我们需要 rsa-sha256 的正版证书吗?自签名证书会正常工作吗?

【问题讨论】:

    标签: adfs2.0 spring-saml


    【解决方案1】:

    来自 ADFS 的异常抱怨 SAML 消息未使用它所期望的 RSA-SHA256 签名,而是使用 RSA-SHA1。

    确保将 ADFS 中 Spring SAML 中继方的签名算法设置为 SHA-1。您可以在http://docs.spring.io/autorepo/docs/spring-security-saml/1.0.x-SNAPSHOT/reference/htmlsingle/#chapter-idp-guide-adfs-sp的最后一个要点中找到详细信息

    【讨论】:

    • 知道为什么 spring-security-saml 不能处理 ADFS SHA-256 签名吗?
    • 默认情况下 ADFS 需要 SHA-256,但默认情况下 OpenSAML/Spring-Security-SAML 使用 SHA-1。您必须更改其中一个以使它们匹配。更好的选择是使用 SHA-256,因此您必须像这样更改您的实现:stackoverflow.com/questions/25982093/…
    【解决方案2】:

    Value="urn:oasis:names:tc:SAML:2.0:status:Responder"

    请参阅 SAML 核心规范。它说:

    urn:oasis:names:tc:SAML:2.0:status:Responder 由于 SAML 的错误,请求无法执行 响应者或 SAML 授权。

    即ADFS 服务器无法解释或回答请求。 IdP 应该告诉您问题所在。

    【讨论】:

      【解决方案3】:

      Spring Security SAML 扩展默认不支持 SHA-256。您可以扩展 org.springframework.security.saml.SAMLBootstrap 类以提供 SHA-256。

      覆盖postProcessBeanFactory 方法

      public class Bootstrap extends SAMLBootstrap {
      
          @Override
          public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
              super.postProcessBeanFactory(beanFactory);
              BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration
                      .getGlobalSecurityConfiguration();
              config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256);
              config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256);
          }
      

      【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-23
      • 2015-02-28
      • 2016-08-31
      • 2016-08-06
      • 2023-03-26
      • 2015-04-19
      • 2016-12-03
      • 2014-11-10
      相关资源
      最近更新 更多