【问题标题】:SharePoint 2010 trusted identity provider, switching from HTTP to HTTPS causes loopingSharePoint 2010 受信任的身份提供程序,从 HTTP 切换到 HTTPS 会导致循环
【发布时间】:2013-12-20 17:45:14
【问题描述】:

我有一个 SharePoint 2010 网站,它针对我的安全令牌服务使用受信任的身份提供程序和自定义声明提供程序。当我一直使用 HTTP 时,这很棒。当我一直使用 HTTPS 时,这很棒。但是当我从 HTTP 切换到 HTTPS 时,我被重定向到 STS,并且在 STS 和 mysite/_trust 之间开始了一个循环。

看起来从 HTTP 使用的 FedAuth cookie 与 HTTPS 所需的 FedAuth cookie 不匹配,但 STS 看到您已登录并且不会颁发新证书。

关于如何使领域 http:mysite.site.com 和 https://mysite.site.com 正常工作的任何想法。

更新: 经过大量调试和代码更改,这似乎是 cookie 的客户端问题。如果我登录 HTTP 并切换到 HTTPS,它可以正常传输。但是如果我从 HTTPS 转到 HTTP,它就会进入循环。我相信这是因为 cookie 设置为“安全”。我认为 HTTP 站点无法读取 cookie。我的答案可能是找出如何使 cookie 不“安全”,以便双方都可以使用。

【问题讨论】:

    标签: sharepoint sharepoint-2010 single-sign-on


    【解决方案1】:

    有两种方法可以解决此问题。问题是 FedAuth cookie 被标记为安全和 HTTPOnly。因此,当您从 HTTPS 切换到 HTTP 时,SharePoint /_trust/ 无法读取 cookie

    我采用的方法是修改 _login 目录中的 default.aspx。可以在这里找到 C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\template\identitymodel\login\

    我用这个 default.aspx 页面替换了现有的 default.aspx

    <%@ Assembly Name="Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharepointIdentity" Namespace="Microsoft.SharePoint.IdentityModel" Assembly="Microsoft.SharePoint.IdentityModel, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> 
    <%@ Import Namespace="Microsoft.SharePoint.WebControls" %> 
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
    <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Page Language="C#"  MasterPageFile="~/_layouts/simple.master"  %>
    
    <asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    
    </asp:Content>
    
    <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    
    <script language="C#" runat="server">
    
            protected void Page_Load(object sender, EventArgs e)
            {
                string killed = "no";
    
                if (Request.Cookies["FedAuth"] != null)
                {
                    killed = "yes";
    
            HttpCookie expiredCookie = new HttpCookie("FedAuth");
                    expiredCookie.Expires = DateTime.UtcNow.AddDays(-1);
                    Response.Cookies.Add(expiredCookie);                
                }
    
                string returnURL = Request["ReturnUrl"].ToString();
    
                Response.Redirect("/_trust/default.aspx?trust=SSO%20Trusted%20Provider&ReturnUrl=" + returnURL + "&cooke=" + killed);
            }
    
     </script>
    
    </asp:Content>
    

    后面没有代码。

    解决它的另一种方法是使用新的 cookie 处理程序修改 cookie。你可以在这里看到。 http://www.msngn.com/blog/Lists/Posts/Post.aspx?ID=5

    【讨论】:

      【解决方案2】:

      对此的另一个答案是将 HTTP 和 HTTPS 放在备用访问映射中的同一区域中。然后您需要覆盖 cookiehandler 以允许在 HTTP 和 HTTPS 中使用相同的 cookie。

      http://www.msngn.com/blog/Lists/Posts/Post.aspx?ID=5

      【讨论】:

        猜你喜欢
        • 2012-09-06
        • 2011-08-04
        • 1970-01-01
        • 2015-10-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-25
        相关资源
        最近更新 更多