Shibboleth ACS URL 与 http 和 https 不匹配

Shibboleth ACS URL mismatch with http and https

我的 ACS URL 正在从 https://foo.com/ to http://foo.com/ 重写,这导致了以下异常。

Microsoft.IdentityServer.Service.Policy.PolicyServer.Engine.AssertionConsumerServiceUrlDoesNotMatchPolicyException: MSIS3200: No AssertionConsumerService is configured on the relying party trust 'foo-shibboleth-sp' that is a prefix match of the AssertionConsumerService URL 'http://foo/Shibboleth.sso/SAML2/POST' specified by the request.

日志消息反映身份验证请求也是作为 http 发送的:

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" 
AssertionConsumerServiceURL="http://foo/Shibboleth.sso/SAML2/POST" 
Destination="https://bar/adfs/ls/" 
ID="_12345ID" IssueInstant="2017-08-08T22:24:28Z" 
ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 
Version="2.0"><saml:Issuerxmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">foo-shibboleth-sp</saml:Issuer><samlp:NameIDPolicy AllowCreate="1"/></samlp:AuthnRequest>
2017-08-08 22:24:28 DEBUG OpenSAML.MessageEncoder.SAML2Redirect [1]: message encoded, sending redirect to client

我在下面包含了我的配置。

我在 IDP 中配置的 SP 元数据具有正确的 URL 和 https,但正在下游某处更改为 http,并且可以在 samlp 身份验证请求的 Shibboleth 日志中看到。

如果我将 handlerSSL 切换为 TRUE,samlp 身份验证请求中的 ACS URL 将显示 https。但是,当它设置为 TRUE 时,/Shibboleth.sso/ 路径中的任何内容(例如 /Status 或 /SAML2/POST 都是 404ing。

我还应该指出,这实际上是一个站点迁移,这一切都在数据中心的 windows 上,现在它在 AWS 上 Linux 上。我们终止 SSL 的负载均衡器可能存在问题,但无法对其进行调试。

在提供给 IDP 的 SP 元数据中,我指定了 https /SAML2/POST url。这里有一堆配置,但我试图突出相关的东西。

<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" ID="_97e389f1c212...." entityID="foo-shibboleth-sp">

...

<init:RequestInitiator xmlns:init="urn:oasis:names:tc:SAML:profiles:SSO:request-init" Binding="urn:oasis:names:tc:SAML:profiles:SSO:request-init" Location="https://foo/Shibboleth.sso/Login"/>

....

<md:AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://foo/Shibboleth.sso/SAML2/POST" index="10"/>

然后,在我的 SP 上的 shibboleth2.xml 中,我有以下应用程序覆盖配置:

        <ApplicationOverride id="lms" entityID="foo-shibboleth-sp"
                         homeURL="/path/to/sso/location">

        <Sessions lifetime="28800" timeout="3600" checkAddress="false"
            handlerURL="/Shibboleth.sso" handlerSSL="false"
            exportLocation="https://foo/Shibboleth.sso/GetAssertion" exportACL="127.0.0.1"
            idpHistory="false" idpHistoryDays="7">

            <!-- Default example directs to a specific IdP's SSO service (favoring SAML 2 over Shib 1). -->
            <SessionInitiator type="Chaining" Location="/Login" isDefault="true" id="Intranet"
                    relayState="cookie" entityID="http://bar/adfs/services/trust">
                <SessionInitiator type="SAML2" acsIndex="1" template="bindingTemplate.html"/>
                <SessionInitiator type="Shib1" acsIndex="5"/>
            </SessionInitiator>
        </Sessions>

        <MetadataProvider type="XML" file="/etc/shibboleth/metadata-sp.xml"/>

        <!-- Map to extract attributes from SAML assertions. -->
        <AttributeExtractor type="XML" validate="true" path="/etc/shibboleth/attribute-map.xml"/>

    </ApplicationOverride>

最后,我确定可能导致问题的唯一另一部分是此处的 IDP 元数据:

<EntityDescriptor xmlns="urn:oasis:names:tc:SAML:2.0:metadata" ID="_1234-..." entityID="http://bar/adfs/services/trust">
...
      <AssertionConsumerService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://bar/adfs/ls/" index="0" isDefault="true" />
....
      <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" Location="https://bar/adfs/ls/" />
  <SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" Location="https://bar/adfs/ls/" />

还有 apache 配置,虽然它看起来很千篇一律

<Location />
  ShibRequestSetting applicationId lms
</Location>
<Location /path/to/sso/location>
  ShibRequestSetting applicationId lms
  AuthType shibboleth
  ShibRequestSetting requireSession 1
  require valid-user
</Location>

问题最终与 AWS 负载均衡器的 SSL 卸载有关。因为我们在 ELB 处终止,所以我们需要在 Apache 配置中的 ServerName 指令上设置 https://,以便它生成 https 自引用 url。

http://httpd.apache.org/docs/2.2/mod/core.html#servername