3

在 IIS Express 中,使用 Saml2AuthenticationModule(来自SAML2 协议的 WIF 扩展)会产生以下应用程序流程:

  1. 用户转到调用Saml2AuthenticationModule.Current.SignIn(args) 的服务提供者 URL;
  2. 该模块将请求路由到身份提供者。
  3. 根据 SP 的 AssertionConsumerService 元数据,IdP 将 SSO 响应发送回 SP。在我目前的测试中,这个 URL 是“{rootdomain}/ ServiceProvider/saml/post/ac”。据我所知,这个 URL 是不可配置的。
  4. 模块截获此响应,配置 IClaimsIdentity,然后将流重定向回 SP 应用程序(在步骤 1 中传递的参数)。

当针对 Windows Azure 模拟器而不是 IIS Express 时,我将 web.config 更改为指向不同的 SP 元数据文件,并使用适合模拟器 URL 的不同 AssertionConsumerService:

<md:AssertionConsumerService index="1" 
    Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" 
    Location="https://127.0.0.1/ServiceProvider/saml/post/ac" />

在 azure 计算模拟器中进行调试时,流程会在步骤 #3 之后停止。当它到达第 4 步时,我最终会查看此 URL 的 404 页面:

https://127.0.0.1/ServiceProvider/saml/post/ac

这里发生了什么?模块不应该拦截这个 URL 并处理 SAML 响应吗?为什么这在 IIS Express 中有效,但在 azure 计算模拟器中无效?

这是 SAML 内容的 web.config:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
        <add name="Saml2AuthenticationModule" 
            type="Microsoft.IdentityModel.Web.Saml2AuthenticationModule"/>
        <add name="SessionAuthenticationModule" 
            type="Microsoft.IdentityModel.Web.SessionAuthenticationModule"/>
    </modules>
    ...
</system.webServer>

...

<microsoft.identityModel>
    <service>
        <audienceUris>
            <add value="https://www.mydomain.com/saml2/development/azure"/>
        </audienceUris>
        <certificateValidation certificateValidationMode="None"/>
        <issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry">
            <!-- The set of trusted issuers. -->
            <trustedIssuers>
                <add name="urn:samples:identityprovider" thumbprint="59 fc 9a da 58 86 31 8d 1d d5 f8 a6 0f 9a 53 f8 09 fc 0e 63"/>
            </trustedIssuers>
        </issuerNameRegistry>
        <serviceTokenResolver type="Samples.Saml.Utilities.SampleServiceProviderSecurityTokenResolver"/>
        <!-- Enable saveBootstrapTokens so the token visualizer can show the raw SAML assertion. -->
        <securityTokenHandlers>
            <securityTokenHandlerConfiguration saveBootstrapTokens="true">
            </securityTokenHandlerConfiguration>
        </securityTokenHandlers>
        <federatedAuthentication>
            <cookieHandler requireSsl="true"/>
        </federatedAuthentication>
    </service>
</microsoft.identityModel>

...

<microsoft.identityModel.saml metadata="saml2-azure.xml">
    <identityProviders>
        <metadata file="identityprovider.xml"/>
    </identityProviders>
</microsoft.identityModel.saml>

saml2-azure 中的 entityID 是https://www.mydomain.com/saml2/development/azure,具有上述 AssertionConsumerService URL,并且在测试中的 SP 和 IdP 中。

4

0 回答 0