2013-04-29 70 views
2

查看身份和访问控制PluralSite视频后,基本上得到我需要的一切设置(我的机器上有一个Thinktecture Identity Server的本地实例,以及身份和访问vs2012扩展),我无法在同一个解决方案中获得两个Web应用程序以针对Identity Server进行身份验证。如何获得两个网站对Thinktecture的Identity Server进行身份验证?

目前,他们都要求我登录到ID服务器,这不是我想要的,我希望能够登录到Id服务器一次,并为两个站点进行身份验证。

以下是我认为这个决定应该怎么去web.config中的部分:

究竟什么是“境界”的作用?这是否需要成为真正的URL,还是可以像名称空间一样处理?我试图在多个站点上使用由Id Server发布的相同安全令牌时,必须发挥映像领域的作用。

<system.identityModel.services> 
<federationConfiguration> 
<cookieHandler requireSsl="false" /> 
<wsFederation passiveRedirectEnabled="true" issuer="https://MyIdServer.com/idsvr/issue/wsfed" realm="http://MyLocalServerRunningIISExpress:55495/" reply="http://MyLocalServerRunningIISExpress:55495/" requireHttps="false" /> 
</federationConfiguration> 
</system.identityModel.services> 

audienceUris如何工作?我假设如果我想要在多个站点上使用一个安全令牌,我需要让每个站点的URL在audienceUris部分中表示?

<system.identityModel> 
<identityConfiguration> 
<claimsAuthenticationManager type="SSO.Security.ClaimsAuthenticationManager, SSO.Security" />  
<audienceUris> 
<add value="http://MyLocalServerRunningIISExpress:55495/" /> 
<add value="http://MyLocalServerRunningIISExpress:53133/" /> 
</audienceUris> 
</identityConfiguration> 
</system.identityModel> 

第二个站点的其他web.config文件与上面的部分相似,但端口号在URL上已更改。

同样,我有Id Srv将令牌传回给我,为我认证我的一个网站,但我不能为我的生活得到它的两个工作。

我猜这是一个配置问题,或者可能是我在两个端口号上运行IIS Express的两个实例,而不是真正的IIS服务器调用并使用URL代替的事实?

任何帮助或指针,将不胜感激。

谢谢, 迈克

回答

0

好了,很明显,你必须勾选“记住我”复选框,以便将cookie传播到其他网站。所以,从本质上讲,这现在可行。然而,我仍然无法做到正确注销。 。再有,就是要注销该网站清除它自己的cookie,然后取STS甜饼,但其他网站仍然登录

在STS服务器注销页面的源视图有:

<iframe style="visibility: hidden; width: 1px; height: 1px" src="http://MyServer:55495/?wa=wsignoutcleanup1.0"></iframe> 

但是由于当前有两个网站已经登录,我应该在这里看到其中两个条目,所以此页面也可以清理该cookie。

这里是我的注销代码:

var authModule = FederatedAuthentication.WSFederationAuthenticationModule; 

//clear local cookie 
authModule.SignOut(false); 

//initiate federated sign out request to the STS 
var signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm); 
var queryString = signOutRequestMessage.WriteQueryString(); 
return new RedirectResult(queryString); 

我相信这个代码是正确的,但我想这个问题是STS服务器没有保持跟踪,其中依赖方已登录,需要有自己的饼干销毁了?

+0

一个问题是这两个网站的Cookie不同。您需要指定要使用的cookie名称,以便共享相同的cookie。请参阅[我的答案](http://stackoverflow.com/a/17229883/109392)。这解决了单点登录问题,并取消了“记住我”的需求,以使其工作。 – awe 2013-06-21 07:49:35

1

您是否试过FederatedSignOut?

WSFederationAuthenticationModule am = FederatedAuthentication.WSFederationAuthenticationModule; 
WSFederationAuthenticationModule.FederatedSignOut(new Uri(am.Issuer), new Uri(am.Realm)); 

我知道这是WIF 1。0,但是应该有WIF 4.5

1

nzpcmad类似的东西,这里就是在4.5的相似:

var authModule = FederatedAuthentication.WSFederationAuthenticationModule; 
authModule.SignOut(false); 
var signOutRequestMessage = new SignOutRequestMessage(new Uri(authModule.Issuer), authModule.Realm); 
var queryString = signOutRequestMessage.WriteQueryString(); 
return new RedirectResult(queryString); 

我觉得这里的问题有事情做与方式Thinktecture标识SVR的是发出来的cookie中的应该跟踪依赖方的身份验证。出于某种原因,包含经过身份验证的RP的cookie在收到注销请求之前似乎不会被发布,并且我相信在接收到登录请求时应该发布cookie?

一些其他人有同样的问题,并没有在GitHub上为它开出罚单: https://github.com/thinktecture/Thinktecture.IdentityServer.v2/issues/197

0

在cookie处理程序,应指定namedomain(也可能path)。所有使用此网站的网站都必须相同。

<system.identityModel.services> 
    <federationConfiguration> 
    <cookieHandler requireSsl="false" 
     name="myCookieName" domain="MyLocalServerRunningIISExpress" path="/"/> 
    <wsFederation passiveRedirectEnabled="true" requireHttps="false" 
     issuer="https://MyIdServer.com/idsvr/issue/wsfed" 
     realm="http://MyLocalServerRunningIISExpress:55495/" /> 
    </federationConfiguration> 
</system.identityModel.services> 

我不知道如何使用不同端口号的设置。我拥有的设置是标准IIS,并且这两个站点都作为应用程序在同一个根上运行。

我知道的另一个设置工作是将两个站点设置为域的最后部分。这是网站的网址:site1.mydomain.comsite2.mydomain.com。然后将<cookieHandler>中的参数domain设置为mydomain.com

是的,所有的网站都必须在<audienceUris>中列出,就像你已经在你的例子中。

注:
reply网址是相同的realm,该reply参数并不是必需的。

相关问题