【问题标题】:Using WIF In an existing site with FormsAuthentication通过 FormsAuthentication 在现有站点中使用 WIF
【发布时间】:2013-03-15 23:32:48
【问题描述】:

我们请求允许使用 AD FS 进行 SSO。我浏览了所有 SDK 示例,并让 RP 在独立站点中工作,指向我们域中的 AD FS。我可以让声明显示在 default.aspx 页面上。

这是我接下来想做的事情。我希望 WIF 页面作为子应用程序托管在我们的站点中,让该站点编写表单身份验证票,然后重定向到我们的主站点。我假设因为我从我的主站点继承了 Forms Auth 和 machinekey 设置,所以我在那里没有冲突。这是我所拥有的..

在我的 WIF 站点的 global.asax 中的 Application_PostAuthenticateRequest 事件中。(称为 WSFedAuthGate)可通过 https://fqdn.com/WSFedAuthGate/Default.aspx 访问

protected void Application_PostAuthenticateRequest(object sender, EventArgs e) {
    System.Web.HttpApplication app = sender as System.Web.HttpApplication;

    if (app.Request.IsAuthenticated && app.User != null && app.User.Identity != null) {
        string name = app.User.Identity.Name;
        FormsAuthentication.SetAuthCookie(name, false);
        // hard code for now..
        app.Response.Redirect("https://fqdn.com/home/asp_main.aspx");
    }

}

表单身份验证票已写入,我被重定向到主站点,但主站点无法识别表单身份验证票..即request.isAuthenticated 是假的..

这是来自主站点的网络配置部分..

<authentication mode="Forms">
  <forms loginUrl="/home/asp_main.aspx" name=".myauth" protection="All" timeout="120" enableCrossAppRedirects="true"/>
</authentication>

这是来自 WIF 子应用程序的身份验证..

<authentication mode="None" />
<authorization>
  <deny users="?" />
</authorization>

以后

<system.webServer>
  <validation validateIntegratedModeConfiguration="false" />
  <modules>
    <remove name="RefreshController" />
    <add name="WSFederationAuthenticationModule" type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
    <add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
  </modules>
    <defaultDocument>
        <files>
            <add value="Default.aspx" />
        </files>
    </defaultDocument>
</system.webServer>

我在这里遗漏了一些简单的东西,我只知道它..但我已经在网上淘了一天半了..

【问题讨论】:

    标签: asp.net forms-authentication wif


    【解决方案1】:

    事实证明,这很简单。在根应用程序的配置部分,validationKey 和 decryptionKey 属性都应用了 IsolateApps 修饰符。.aarrgg..

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-09
      • 1970-01-01
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多