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

时间:2014-07-17 14:09: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
...

我正在使用 Tomcat 7 上的严格传输安全(HSTS) Spring Security 的默认设置 > SSL 已启用。

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


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

3 个答案:

答案 0 :(得分:21)

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

SAMLContextProviderLB通常用于向Spring SAML公开告知反向代理或负载均衡器上使用的公共URL,但在这种情况下,您可以使用强制Spring SAML认为它使用HTTPS。您可以在Spring SAML manual 10.1高级配置章节中找到详细信息。

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

答案 1 :(得分:0)

我认为您的Application Server在负载均衡器后面!

对于在AWS Application Load Balancer后面运行的Apache Tomcat服务器,需要启用RemoteIPValue,以便基于 x-forwarded-proto 标头,Tomcat将覆盖方案(https)和端口(443)。

server.xml

<Valve className="org.apache.catalina.valves.RemoteIpValve" protocolHeader="X-Forwarded-Proto" internalProxies="10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|169\.254\.\d+\.\d+|127\.\d+\.\d+\.\d+|172\.(1[6-9]|2[0-9]|3[0-1])\.\d+\.\d+" />

答案 2 :(得分:0)

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

  @Bean
  public SAMLContextProviderImpl contextProvider() {
      return new SAMLContextProviderImpl();
  }

到SAMLContextProviderLB:

  @Bean
  public SAMLContextProviderLB contextProvider() {
    SAMLContextProviderLB samlContextProviderLB = new SAMLContextProviderLB();
    samlContextProviderLB.setScheme(scheme);
    samlContextProviderLB.setServerName(serverName);
    samlContextProviderLB.setContextPath(contextPath);
      return samlContextProviderLB;
  }
相关问题