[英]Using SAML 2.0 protocol to obtain SAML 2.0 assertion XML
我想通過使用SAML 2.0協議而不是WSTrust獲得SAML 2.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;
因此,我需要使用諸如SAMLP協議之類的securityToken?.TokenXml?.OuterXml這樣的工具。 我不能使用WIF,因為它不支持SAML 2.0協議。
您可以在項目的以下位置添加可用的代碼文件,以獲得對構造SAML請求,解密和驗證SAML響應,讀取SAML斷言等所需的所有基本方法調用的訪問權限。
https://github.com/onelogin/dotnet-saml/tree/master/App_Code
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.