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

问题描述 投票:11回答:1

通常我的基于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
...

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

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


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

spring spring-security saml saml-2.0 spring-saml
1个回答
22
投票

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

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

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


0
投票

我认为您的Application Server支持负载均衡器!

对于在AWS Application负载均衡器后面运行的Apache Tomcat服务器,需要启用RemoteIPValue,以便基于x-forwarded-proto标头,Tomcat将相应地覆盖scheme(https)和port(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+" />
© www.soinside.com 2019 - 2024. All rights reserved.