【发布时间】:2019-07-27 11:20:34
【问题描述】:
在我的应用 SP 和客户端 IdP 之间进行 SSO 时,我收到 'Caused by: org.opensaml.xml.security.SecurityException: SAML message intended destination endpoint did not match recipient endpoint' 异常。
服务器日志显示架构的差异,见下文:
Checking SAML message intended destination endpoint against receiver endpoint
2019-03-05 15:02:44.599 DEBUG [204 default task-41][BaseSAMLMessageDecoder] Intended message destination endpoint: https://my.app.com/app-gateway/saml/SSO
2019-03-05 15:02:44.599 DEBUG [204 default task-41][BaseSAMLMessageDecoder] Actual message receiver endpoint: http://my.app.com/app-gateway/saml/SSO
2019-03-05 15:02:44.600 ERROR [204 default task-41][BaseSAMLMessageDecoder] SAML message intended destination endpoint 'https://my.app.com/app-gateway/saml/SSO' did not match the recipient endpoint 'http://my.app.com/app-gateway/saml/SSO'
我的应用程序在 2 个实例上的 STG 上运行,前面有 LB,因此我使用 SAMLContextProviderLB 上下文提供程序而不是 SAMLContextProviderImpl:
<bean id="contextProvider" class="org.springframework.security.saml.context.SAMLContextProviderLB">
<property name="scheme" value="https"/>
<property name="serverName" value="my.app.com"/>
<property name="serverPort" value="443"/>
<property name="includeServerPortInRequestURL" value="false"/>
<property name="contextPath" value="/app-gateway"/>
</bean>
<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
<constructor-arg>
<bean class="org.springframework.security.saml.metadata.MetadataGenerator">
<property name="entityBaseURL" value="https://my.app.com/app-gateway1"/>
<property name="entityId" value="${cas.sso.entityId}"/>
<property name="includeDiscoveryExtension" value="false"/>
<property name="extendedMetadata" ref="extendedMetadata"/>
<property name="keyManager" ref="keyManager"/>
</bean>
</constructor-arg>
</bean>
在getActualReceiverEndpointURI 的源代码中,接收者端点URL 是从请求httpRequest obj 中获取的。 因此,我试图了解在哪一步设置了错误的 URL http://my.app.com/app-gateway/saml/SSO。谁能给我解释一下?
protected String getActualReceiverEndpointURI(SAMLMessageContext messageContext) throws MessageDecodingException {
InTransport inTransport = messageContext.getInboundMessageTransport();
if (! (inTransport instanceof HttpServletRequestAdapter)) {
log.error("Message context InTransport instance was an unsupported type: {}",
inTransport.getClass().getName());
throw new MessageDecodingException("Message context InTransport instance was an unsupported type");
}
HttpServletRequest httpRequest = ((HttpServletRequestAdapter)inTransport).getWrappedRequest();
StringBuffer urlBuilder = httpRequest.getRequestURL();
return urlBuilder.toString();
}
【问题讨论】:
-
你的应用服务器和你的LB之间的通信是如何完成的? Http,https,ajp,还有什么?
-
@SébastienPRAT,感谢您的评论。 LB(梭子鱼)通过http与应用程序通信。
-
问题是 TLS/SSL 卸载。 SAML 库使用“request.getScheme()”,这将返回“http”而不是“https”,因此收件人检查失败。使用哪个部署容器?
-
@BernhardThalmayr。感谢您的回答。 WildFly 10.1.0 Final 用作应用服务器。你知道,我怎样才能改变它并强制它使用https?
标签: spring spring-security saml saml-2.0 spring-saml