我在字符串中有一个SAML令牌:
<saml:Assertion xmlns:saml="..." ...> ..etc... </>
Run Code Online (Sandbox Code Playgroud)
在HttpModule中,我想将其转换为ClaimsPrincipal,以便我的服务可以将通常的Thread.CurrentPrincipal作为IClaimsPrincipal来完成.
我找到了一些诱人的网页/博客/等...看起来很有帮助:
我实际上试图将SAML令牌转换为ClaimsPrincipal(通过SecurityToken中间步骤或直接...以任何方式开心).Cibrax的想法中的示例代码使用以下内容进行关键验证和反序列化步骤:
SecurityTokenSerializer securityTokenSerializer
= new SecurityTokenSerializerAdapter(
FederatedAuthentication.SecurityTokenHandlers,
MessageSecurityVersion.Default.SecurityVersion,
false, new SamlSerializer(), null, null);
SecurityToken theToken
= WSFederationAuthenticationModule.GetSecurityToken(
theSamlTokenInStringForm, securityTokenSerializer);
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,WIF的RTM版本没有公开GetSecurityToken的这个重载...它只暴露:
WSFederationAuthenticationModule fam = new WSFederationAuthenticationModule();
SecurityToken theToken = fam.GetSecurityToken(HttpRequest theRequest);
SecurityToken theToken = fam.GetSecurityToken(SignInResponseMessage message);
Run Code Online (Sandbox Code Playgroud)
谢谢你帮我搞砸了!
泰勒
我一直在研究各种样本,试图为ASP.Net Web服务和WCF RESTful Web服务拼凑基于SAML令牌的身份验证解决方案......我参考过的一些示例:
我一直在与每个障碍作斗争,我很亲密,我可以品尝它.给我的最新一块是:
如果我用的是普通WebServiceHostFactory,定制的授权策略被应用,并且结束Thread.CurrentPrincipal中最多的,取值为我的HTTP模块集HttpContext.Current.User ...但是...如果我使用WebServiceHost2Factory(即从REST入门工具包),以获得自动求助终点,等等,然后将已授权政策没有应用,并且Thread.CurrentPrincipal中最终被以任何方式有关ClaimsPrincipal我在设置RoleProviderPrincipal的实例的HttpModule ..: - (
有任何想法,想法如何让WebServiceHost2Factory与自定义/重写主体发挥良好作用?
谢谢,
泰勒