收件人端点与SAML响应不匹配

vde*_*ris 11 spring spring-security saml saml-2.0 spring-saml

通常我的基于Spring SAML服务提供程序(SP)实现工作正常,但有时它会返回此错误:

[2014-07-17 16:00:58.767] boot - 1078 DEBUG [http-bio-80-exec-1] --- BaseMessageDecoder:     Successfully decoded message.
[2014-07-17 16:00:58.767] boot - 1078 DEBUG [http-bio-80-exec-1] --- BaseSAMLMessageDecoder: Checking SAML message intended destination endpoint against receiver endpoint
[2014-07-17 16:00:58.768] boot - 1078 DEBUG [http-bio-80-exec-1] --- BaseSAMLMessageDecoder: Intended message destination endpoint: https://prismasp.cloud.reply.eu:443/MIUR_PRISMA-2.1-WEBUI/saml/SSO/alias/defaultAlias
[2014-07-17 16:00:58.768] boot - 1078 DEBUG [http-bio-80-exec-1] --- BaseSAMLMessageDecoder: Actual message receiver endpoint: http://prismasp.cloud.reply.eu:443/MIUR_PRISMA-2.1-WEBUI/saml/SSO/alias/defaultAlias
[2014-07-17 16:00:58.768] boot - 1078 ERROR [http-bio-80-exec-1] --- BaseSAMLMessageDecoder: SAML message intended destination endpoint 'https://prismasp.cloud.reply.eu:443/MIUR_PRISMA-2.1-WEBUI/saml/SSO/alias/defaultAlias' did not match the recipient endpoint 'http://prismasp.cloud.reply.eu:443/MIUR_PRISMA-2.1-WEBUI/saml/SSO/alias/defaultAlias'
[2014-07-17 16:00:58.782] boot - 1078 DEBUG [http-bio-80-exec-1] --- SAMLProcessingFilter: Incoming SAML message is invalid
org.opensaml.xml.security.SecurityException: SAML message intended destination endpoint did not match recipient endpoint
...
Run Code Online (Sandbox Code Playgroud)

我正在使用(作为Spring Security的默认设置)启用了SSL的Tomcat 7上的HTTP严格传输安全性(HSTS).

有没有办法解决这个错误?


注意:示例源代码位于Github:vdenotaris/spring-boot-security-saml-sample.

Vla*_*fer 23

我不知道为什么你的问题是随机发生的,但至少有一种解决方法是配置SAMLContextProviderLB而不是你当前的问题SAMLContextProviderImpl.

SAMLContextProviderLB通常用于告诉Spring SAML公众有关在反向代理或负载平衡器使用的公共URL,但在这种情况下,你可以用它来力弹簧SAML认为它使用HTTPS.您可以在本章详细10.1高级配置的的春天SAML手册.

您还应该确保entityBaseURLMetadataGeneratorbean 上正确设置属性,因为如果不这样做,生成的元数据将取决于您是使用http还是https向应用程序发出第一个请求.同样,所有这些都记录在案.


小智 5

我在 Spring Security SAML 上遇到了同样的问题。所以我不得不从 SAMLContextProviderImpl 更改 contextProvider:

  @Bean
  public SAMLContextProviderImpl contextProvider() {
      return new SAMLContextProviderImpl();
  }
Run Code Online (Sandbox Code Playgroud)

到 SAMLContextProviderLB:

  @Bean
  public SAMLContextProviderLB contextProvider() {
    SAMLContextProviderLB samlContextProviderLB = new SAMLContextProviderLB();
    samlContextProviderLB.setScheme(scheme);
    samlContextProviderLB.setServerName(serverName);
    samlContextProviderLB.setContextPath(contextPath);
      return samlContextProviderLB;
  }
Run Code Online (Sandbox Code Playgroud)