StartSTS 和带有负载均衡器的依赖方
由于需要在负载均衡器上运行我的网站,我不得不用以下内容替换会话令牌处理程序。
public class WebFarmSessionSecurityTokenHandler : SessionSecurityTokenHandler
{
public WebFarmSessionSecurityTokenHandler(X509Certificate2 protectionCertificate)
: base(CreateRsaTransforms(protectionCertificate))
{ }
private static ReadOnlyCollection<CookieTransform> CreateRsaTransforms
(X509Certificate2 protectionCertificate)
{
var transforms = new List<CookieTransform>()
{
new DeflateCookieTransform(),
new RsaEncryptionCookieTransform(protectionCertificate),
new RsaSignatureCookieTransform(protectionCertificate),
};
return transforms.AsReadOnly();
}
}
然后我修改了 web.config 如下。
<microsoft.identityModel>
<service>
...
<securityTokenHandlers>
<clear />
<add type="MyAssembly.WebFarmSessionSecurityTokenHandler, MyAssembly"/>
</securityTokenHandlers>
...
</service>
</microsoft.identityModel>
完成此操作后,我希望我的依赖方无论访问哪个节点或哪个盒子发起身份验证,都能正常运行。
我当前收到以下信息:SecurityTokenHandler 未注册来读取安全令牌。
有什么想法吗?
I've had to replace the session token handler with the following, due to a requirement of running my site on load balancers.
public class WebFarmSessionSecurityTokenHandler : SessionSecurityTokenHandler
{
public WebFarmSessionSecurityTokenHandler(X509Certificate2 protectionCertificate)
: base(CreateRsaTransforms(protectionCertificate))
{ }
private static ReadOnlyCollection<CookieTransform> CreateRsaTransforms
(X509Certificate2 protectionCertificate)
{
var transforms = new List<CookieTransform>()
{
new DeflateCookieTransform(),
new RsaEncryptionCookieTransform(protectionCertificate),
new RsaSignatureCookieTransform(protectionCertificate),
};
return transforms.AsReadOnly();
}
}
I then amended the web.config as follows.
<microsoft.identityModel>
<service>
...
<securityTokenHandlers>
<clear />
<add type="MyAssembly.WebFarmSessionSecurityTokenHandler, MyAssembly"/>
</securityTokenHandlers>
...
</service>
</microsoft.identityModel>
My hope after doing this was that my relying party would function no matter what node it was accessing or what box initiated the authenication.
I'm currently getting the following : A SecurityTokenHandler is not registered to read security token.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
上面的内容需要放在global.asax文件中。在应用程序启动中连接以下事件。
我不再需要 WebFarmSessionSecurityTokenHandler 或配置更改来将其插入。
The above needs to be placed inside the global.asax file. With the following event hooked up in the application start.
I no longer required the WebFarmSessionSecurityTokenHandler or the config changes to slot it in.