使用IdentityServer将SAML令牌转换为JWT令牌

时间:2013-07-01 12:40:14

标签: wif saml federated-identity jwt ws-trust

我使用身份联合(google,facebook,live id)和WCF SOAP服务配置了Thintecture Identity Server。

现在我需要Windows Phone应用程序的WCF Rest Endpoint(webHttpBinding)。我不想在授权标头中传递WSTrust SAML令牌。是否可以将SamlToken转换为JWT令牌以及如何:)?

以下是我尝试的代码,但无效。

var factory = new WSTrustChannelFactory(
    new WindowsWSTrustBinding(SecurityMode.Transport),
    new EndpointAddress("https://identityserver.local/issue/???"))
{
    TrustVersion = TrustVersion.WSTrust13
};

var rst = new RequestSecurityToken
{
    RequestType =  RequestTypes.Issue,
    KeyType = KeyTypes.Bearer,
    TokenType = TokenTypes.JsonWebToken,
    AppliesTo = new EndpointReference("http://my.realm/")
};

var securityToken = xmlToken.ToSecurityToken();
var response = factory.CreateChannelWithIssuedToken(securityToken).Issue(rst);

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您可以配置IdentityServer以返回JWT。转到全局配置并将默认令牌类型更改为JWT(与默认的http令牌类型相同)。应该这样做。

更新:你为什么要使用WSTrust-IdSrv不支持使用例如身份验证谷歌通过WS-Trust。

相关问题