Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cross domain 如何防止ClaimsPrincipal的FedAuth Cookie在共享同一个域的两个网站之间共享?_Cross Domain_Forms Authentication_Claims Based Identity_Federated Identity - Fatal编程技术网

Cross domain 如何防止ClaimsPrincipal的FedAuth Cookie在共享同一个域的两个网站之间共享?

Cross domain 如何防止ClaimsPrincipal的FedAuth Cookie在共享同一个域的两个网站之间共享?,cross-domain,forms-authentication,claims-based-identity,federated-identity,Cross Domain,Forms Authentication,Claims Based Identity,Federated Identity,我有两个网站: global.domain.com和global.domain.com/site1 /site one是添加到global.domain.com网站下IIS的应用程序 用户将登录到global.domain.com,然后单击指向global.domain.com/site1的链接即可到达。由于我在本文中使用了匹配的机器键和信息: 我正在设置一个Forms Auth cookie,它允许在同一个域的站点之间对单个用户进行身份验证 我还在每个站点中使用ClaimsPrincipal,

我有两个网站:

global.domain.com和global.domain.com/site1

/site one是添加到global.domain.com网站下IIS的应用程序

用户将登录到global.domain.com,然后单击指向global.domain.com/site1的链接即可到达。由于我在本文中使用了匹配的机器键和信息:

我正在设置一个Forms Auth cookie,它允许在同一个域的站点之间对单个用户进行身份验证

我还在每个站点中使用ClaimsPrincipal,通过.NET4.5中的新声明处理角色分配

但是,当用户单击或键入/site1的站点时,site1one将获得全局站点的声明,我不希望发生这种情况

如果我从全局站点直接链接到/site1,我可以在调用以下命令后使用控制器操作重定向用户:

FederatedAuthentication.SessionAuthenticationModule.SignOut();
这就清除了费多思饼干

但是,如果用户只是将/site1添加到全局站点URL的后面并点击go,那么来自全局的声明将转到/site1的声明

每个网站都应该有自己的主张

我已尝试在Global.asax中的PostAuthentication处理程序中删除FedAuth cookie:

 protected void Application_PostAuthenticateRequest()
 {
        if (HttpContext.Current.Request.UrlReferrer == null)
        {
            FederatedAuthentication.SessionAuthenticationModule.SignOut();
            HttpContext.Current.Request.Cookies.Remove("FedAuth");
            return;
        }
 }
但这似乎不起作用,b/c如果我在应用程序的第一行\u PostAuthenticateRequest上放一个分隔符,然后查看ClaimsPrincipal.Current.identies.first.Claims集合,所有的索赔都来自global

因此,即使我调用SessionAuthenticationModule.SignOut;删除FedAuth cookie,我仍然需要找到一种方法来删除ClaimsPrincipal.Current中的声明,这似乎有点黑客

有人知道分配ClaimsPrincipal.Current的时间和地点吗?由于在global.asax中点击我的处理程序之前,它在访问/site1时从全局站点获取我的声明,因此在填充ClaimsPrincipal.Current声明的管道中肯定还有其他地方


有什么想法吗?

为了防止FedAuth cookie在同一域中的应用程序之间工作,请为每个应用程序配置具有唯一路径的cookie处理程序

您的应用程序是否将cookie处理程序路径设置为/?如果是,则允许在应用程序之间共享FedAuth cookie

尝试将cookie处理程序路径设置为唯一的路径。。。这样

<cookieHandler path="/myapplicationpath/" />

或者-完全忽略路径属性也可以达到同样的效果。

想知道您是否解决了这个问题。我遇到了同样的问题。