首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SAML2.0协议获取SAML2.0断言XML

使用SAML2.0协议获取SAML2.0断言XML
EN

Stack Overflow用户
提问于 2018-10-29 19:26:06
回答 1查看 145关注 0票数 0

我想使用SAML2.0协议而不是WSTrust获得SAML2.0令牌。使用ADFS 3.0。是否有任何nuget包或其他库可以实现这一点?

当前代码使用的是WSTrust和KERBEROS:

代码语言:javascript
复制
WSTrustChannelFactory trustChannelFactory = null;
var bindingElementCollection = new BindingElementCollection();
    bindingElementCollection.Add(SecurityBindingElement.CreateKerberosOverTransportBindingElement());

    trustChannelFactory = new WSTrustChannelFactory
    (
        new CustomBinding(bindingElementCollection),
        new EndpointAddress(kerberosmixedendpoint)
    );

    trustChannelFactory.Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;


trustChannelFactory.TrustVersion = TrustVersion.WSTrust13;

var requestSecurityToken = new RequestSecurityToken
{
    RequestType = RequestTypes.Issue,
    AppliesTo = new EndpointReference(Url),
    KeyType = KeyTypes.Bearer,
};   


var channel = (WSTrustChannel)trustChannelFactory.CreateChannel();

var securityToken = await Task<GenericXmlSecurityToken>.Factory.FromAsync(
    channel.BeginIssue, ar =>
    {
        GenericXmlSecurityToken token = null;

        try
        {
            token = channel.EndIssue(ar, out RequestSecurityTokenResponse response)
                as GenericXmlSecurityToken;
        }
        catch (Exception ex)
        {
        }

        return token as GenericXmlSecurityToken;
    },
    requestSecurityToken,
    null
);

result = securityToken?.TokenXml?.OuterXml;

所以我需要像这个securityToken?.TokenXml?.OuterXml一样获取smth,但是使用SAMLP协议。我不能使用WIF,因为它不支持SAML 2.0协议。

EN

回答 1

Stack Overflow用户

发布于 2019-03-15 01:48:08

您可以在项目的以下位置包含可用的代码文件,以获得对所有基本方法调用的访问,您需要构造SAML请求、解密和验证SAML响应、读取SAML断言等。

https://github.com/onelogin/dotnet-saml/tree/master/App_Code

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53044517

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档