我想使用SAML2.0协议而不是WSTrust获得SAML2.0令牌。使用ADFS 3.0。是否有任何nuget包或其他库可以实现这一点?
当前代码使用的是WSTrust和KERBEROS:
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协议。
发布于 2019-03-15 01:48:08
您可以在项目的以下位置包含可用的代码文件,以获得对所有基本方法调用的访问,您需要构造SAML请求、解密和验证SAML响应、读取SAML断言等。
https://github.com/onelogin/dotnet-saml/tree/master/App_Code
https://stackoverflow.com/questions/53044517
复制相似问题