【问题标题】:WIF Based Authentication Does Not Contact STS Issuer基于 WIF 的身份验证不联系 STS 发行者
【发布时间】:2021-10-08 19:56:47
【问题描述】:

我正在尝试使用基于声明的身份验证对我们的内部 STS 服务器构建一个 asp.net 4.7 (v4.5 WIF)。我们有较旧的工作 .Net 应用程序 (

问题在于新应用从不联系 STS 服务器。


我推测失败在于我如何设置联合 web.config 与旧版本。这是我最新的配置,不工作,然后是使用旧身份进程 (WIF 3.5) 工作的配置。

V4.0 WIF web.config(新 4.7 项目)
<system.identityModel>
    <identityConfiguration>
        <audienceUris>
            <add value="urn:jabberwocky" />
        </audienceUris>
        <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <trustedIssuers>
                <add thumbprint="{MyThumbprint}" name="https://{MyIssuerURL}" />
            </trustedIssuers>
        </issuerNameRegistry>
        <certificateValidation certificateValidationMode="None" />
    </identityConfiguration>
</system.identityModel>
<system.identityModel.services>
    <federationConfiguration>
        <cookieHandler requireSsl="false" />
        <wsFederation passiveRedirectEnabled="true"
                        issuer="https://{MySTSUrl}"
                        realm="urn:jabberwocky"
                        reply="http://localhost:44301/"
                        requireHttps="true" />
    </federationConfiguration>
</system.identityModel.services>
V3.5 WIF web.config(旧 4.0 项目)
<microsoft.identityModel>
  <service>
    <audienceUris>
      <add value="urn:Jabberwocky" />
    </audienceUris>
    <certificateValidation certificateValidationMode="None" />
    <claimsAuthenticationManager type="{Namespace}.MyAuthenticationManager, {Namespace}" />
    <federatedAuthentication>
      <wsFederation passiveRedirectEnabled="true" 
                    issuer="https://{MySTSUrl}" 
                    requireHttps="true" 
                    realm="urn:Jabberwocky" />
      <cookieHandler requireSsl="true" />
    </federatedAuthentication>
    <issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <trustedIssuers>
        <add thumbprint="{MyThumbprint}" name="https://{MyIssuerURL}" />
      </trustedIssuers>
    </issuerNameRegistry>
  </service>
</microsoft.identityModel>

  • 我知道它不会命中 STS 服务器,因为我使用了无效的 audienceUris 值作为测试,而且我不会像在旧项目中那样被服务器拒绝。
  • 我感觉这与旧版本中缺少 federatedAuthentication 值有关,但在新版本中找不到。

【问题讨论】:

  • 如果你想控制正在发生的事情,我建议切换到程序化方法。看看我的教程wiktorzychla.com/2014/11/…至于你当前的配置,确保SAM和FAM模块也都在那里。
  • @WiktorZychla 将该建议作为答案,我会这样标记它。正如我在您的网站上所指出的,我需要 FAM 和 SAM。
  • 至于您在我的博客条目下的评论,如果您遵循我的编程方法,则 web.config 中不需要 FAM。它只需要在 web.config 中用于静态、声明性方法,就像你的一样。
  • 知道了,只有在非程序化的情况下才有意义。

标签: c# wif .net-4.7.2 sts claims-authentication


【解决方案1】:

至于您当前的配置,请确保 SAM 和 FAM 模块都在那里。


如果您想控制正在发生的事情,我建议切换到程序化方法。看看my tutorial

【讨论】:

  • 您是否尝试过将 WIF WS-Fed 作为 OWIN 操作?
  • 您的意思是 .AddWsFederation(...)?还是写一个自定义的中间件?
  • 是的,我尝试了 OWIN 操作,但必须恢复到 WIF。
  • 我们主要有多租户应用程序,其中每个租户都有自己的 wsfed 配置。这对wif来说是轻而易举的事。然而,尽管进行了两次尝试,在这种情况下我们仍然在切换到 owin 时遇到了一些问题。我们现在坚持使用 wif,我考虑有一天需要编写自己的 owin 中间件,但仍然存在问题。
【解决方案2】:

我最终在我的 web.config 中有这个

<system.webServer>
    <modules>
        <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
        <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    </modules>
</system.webServer> 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    相关资源
    最近更新 更多