【问题标题】:Configure ASP.NET MVC 4 web app to use Identity Server 4配置 ASP.NET MVC 4 Web 应用程序以使用 Identity Server 4
【发布时间】:2019-09-20 04:39:13
【问题描述】:

我不太了解如何使现有的旧 ASP.NET MVC 4 应用程序(基于声明的身份验证、Windows 身份基础、ws-federation、旧 thinktecture 身份服务器)使用新的 带有 WS-Federation 插件的 Identity Server 4。 是否需要如here 所述用 OWIN 中间件替换 WIF 的 Authentication 和 Session 模块,还是两者都使用?

这是来自 web.config 的配置:

        <httpModules>
      <add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      <add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </httpModules>
...
<microsoft.identityModel>
    <service>
      <audienceUris>
        <add value="https://localhost/" />
      </audienceUris>
      <federatedAuthentication>
        <wsFederation passiveRedirectEnabled="true" issuer="https://localhost/LoginEndpoint/issue/wsfed" realm="https://localhost/" requireHttps="false" />
        <cookieHandler requireSsl="true" hideFromScript="true" />
      </federatedAuthentication>
      <applicationService>
        <claimTypeRequired>
          <claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" optional="true" />
          <claimType type="http://schemas.microsoft.com/ws/2008/06/identity/claims/role" optional="true" />
        </claimTypeRequired>
      </applicationService>
      <issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
        <trustedIssuers>
          <add thumbprint="XXXXXXXXXXXX" name="https://localhost/LoginEndpoint/" />
        </trustedIssuers>
      </issuerNameRegistry>
      <certificateValidation certificateValidationMode="None" />
      <serviceCertificate>
        <!--Needed for cookie encyption in web-farm environment. -->
        <certificateReference x509FindType="FindByThumbprint" findValue="XXXXXXXXXXXXXXXXX" />
      </serviceCertificate>
    </service>
  </microsoft.identityModel>

任何帮助将不胜感激!甚至建议是否有更好的框架或方法适用于旧的 ASP.NET MVC 4 客户端的现代 SSO 解决方案。

【问题讨论】:

    标签: asp.net-mvc-4 identityserver4 wif ws-federation thinktecture-ident-server


    【解决方案1】:

    在客户端,您可以使用OWIN stack

    请注意,这是 .NET Core,但原理相同。

    如果您愿意,您仍然可以使用 WIF。您只需要更改 IDP URL 和 wtrealm 参数即可。

    在服务器端,您需要 Rock Solid Knowledge WS-Fed 插件。

    关注这个approach

    另一种方法是更改​​为 idsrv4 开箱即用支持的 OpenID Connect。

    这里有一个很好的walk-through

    【讨论】:

    • ADFS 让我很困惑。就我而言,身份验证与 AD 无关。
    • 如果我要在客户端使用Idsrv4和owin中间件,使用WIF的目的是什么?我应该删除之前所有与身份验证相关的代码,如 SessionAuthenticationModule 和 WSFederationAuthenticationModule,因为 owin 会完成他们的工作,对吗?
    • 是的 - 您不需要使用 ADFS。这只是一个展示如何配置 idsrv4 参数的示例。
    • 如果你走 OWIN 路线,WS-Fed 就是内置的。所以不需要WIF。是的 - 您可以删除这些模块。
    • 是的——两者都差不多。如果您想要更新的东西,请使用 OpenID Connect。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-07-28
    • 1970-01-01
    • 2017-10-26
    • 2012-03-11
    • 2019-04-26
    • 2019-04-11
    • 1970-01-01
    相关资源
    最近更新 更多