SAML DNS解决方案问题

时间:2014-11-14 21:23:11

标签: java spring-security spring-saml

我们有一个使用Spring SAML Extension的应用程序,我们将其设置为一个SP,可以在localhost上运行SSOCircle。我们现在已经部署在客户的测试环境中,我们正努力让它与我们客户的IDP合作。

我们向IDP提供了元数据,用http://myapp-test.acme.com:8080/myapp/saml/SSO代替http://localhost:8080/myapp/saml/SSO

验证后,我们会在日志中看到这一点:

o.s.s.s.m.MetadataGeneratorFilter - 根据第一个服务器请求中的值生成默认实体基本URL http://someappserver.acme.com:8080/myapp

org.opensaml.common.SAMLException:预期目的地 http://myapp-test.acme.com:8080/myapp/saml/SSO与配置文件urn的任何端点网址都不匹配:oasis:names:tc:SAML:2.0:profiles:SSO:browser

在浏览器窗口中,我们看到请求转到http://someappserver.acme.com:8080/myapp/saml/SSO

所以http://myapp-test.acme.com:8080/myapp/saml/SSO解析为

http://someappserver.acme.com:8080/myapp/saml/SSO

我们如何更改我们的代码/配置来处理这个问题?我认为我们不应该将元数据硬编码到应用服务器。

1 个答案:

答案 0 :(得分:3)

服务提供商元数据中的URL必须与服务提供商从IDP接收SAML消息的真实URL相对应。在这种情况下,两者不同。

您可以通过提供具有正确网址的属性securityContext.xml来更新您的metadataGeneratorFilter和更改bean entityBaseURL,例如:

<bean id="metadataGeneratorFilter" class="org.springframework.security.saml.metadata.MetadataGeneratorFilter">
    <constructor-arg>
        <bean class="org.springframework.security.saml.metadata.MetadataGenerator">
            <property name="entityBaseURL" value="http://myapp-test.acme.com:8080/myapp"/>
        </bean>
    </constructor-arg>
</bean>

不设置此属性,Spring SAML定义entityBaseURL并根据收到的第一个请求生成元数据。如果您的应用程序在多个URL上可用,这当然可以是与您的IDP实际发送消息的URL不同的URL。

如果应用程序服务器看到的内部URL与调用者使用的URL不同(在DNS解析的情况下),则可以通过更改bean强制Spring SAML认为它部署在特定公共URL后面contextProvider来:

<bean id="contextProvider" class="org.springframework.security.saml.context.SAMLContextProviderLB">
    <property name="scheme" value="http"/>
    <property name="serverName" value="myapp-test.acme.com"/>
    <property name="serverPort" value="8080"/>
    <property name="includeServerPortInRequestURL" value="true"/>
    <property name="contextPath" value="/myapp"/>
</bean>

您可以在Spring SAML手册章节Reverse proxies and load balancers中找到更多详细信息。