ACS 不处理子应用程序中的 SAML 响应

ACS doesn't process SAML response in a sub-application

我正在努力寻找这种行为的原因。我有一个简单的 MVC 应用程序,其中配置了 SustainSys 包。我已经尝试为我们的内部 SecureAuth 服务器和 https://stubidp.sustainsys.com 测试服务器配置它。

当它是我们内部 IIS 服务器的根应用程序时,这一切都适用于本地主机。

当我将它放在 IIS 子应用程序文件夹中时,它重定向到 sso 服务器登录,返回到带有身份验证信息的 ~/Saml2/Acs 路由(我在 fiddler2 中看到它),但是Acs 似乎当时没有处理它,我仍然没有经过身份验证,因此它返回到登录页面,我开始循环。

我知道子应用程序 web.config 继承,所以我什至从根目录中删除了 web.config,这样就不会与子应用程序中的应用程序发生冲突。我玩过 returnURL 参数没有效果(包括或不包括 sudirectory)。

IIS 中的应用程序(root 和子应用程序)的身份验证配置相同。

我 运行 没有想法可以测试。有人有什么想法吗?

<sustainsys.saml2 entityId="https://apps.xxxxx.com" returnUrl="https://apps.xxxxx.com/yyyyy">
    <identityProviders>
        <add entityId="https://sso.xxxxx.com/SecureAuthXX" signOnUrl="https://sso.xxxxx.com/SecureAuthXX" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect">
            <signingCertificate fileName="~/App_Data/SecureAuth03VM.xxxxx.com.cer" />
        </add>
    </identityProviders>
    <federations>
        <add metadataLocation="https://apps.xxxxx.com/Federation" allowUnsolicitedAuthnResponse="true" />
    </federations>
</sustainsys.saml2>
<system.identityModel.services>
    <federationConfiguration>
        <cookieHandler requireSsl="true" name="CookieAuth" />
    </federationConfiguration>
</system.identityModel.services>

有两个步骤我认为可能会出错:

  1. 生成的 AuthnRequest 中的 Acs Url 不正确。请检查 StubIdp 上显示的 XML 内容是否正确反映了子应用程序目录。如果没有,这是 Sustainsys 中的一个 bug/missing 功能。Saml2.Mvc 包。
  2. 应用程序在部署到子目录时未正确调用嵌入在 Sustainsys.Mvc 包中的 MVC 控制器。您可以通过点击 http://yoursite.com/SubDir/Saml2 来测试它 - 如果它有效,它应该 return 元数据 XML。如果是这种情况,您需要检查应用程序中的路由配置,以确保路径正确路由到 MVC 包中的控制器。

我解决了这个问题,我想 post 是什么解决了它,因为也许有一天它可能会帮助其他人。

问题不在于 SAML 响应或 Sustainsys 库,而是 web.config 中缺少的属性。将 "path='/'" 添加到联合配置中的 cookiehandler 元素后(见下文),它开始在 System.Security.Principal 中保留授权状态,现在在根应用程序和所有子应用程序中都能完美运行。

<system.identityModel.services>
    <federationConfiguration>
        <cookieHandler requireSsl="true" name="FedAuth" path="/" />
    </federationConfiguration>
</system.identityModel.services>