似乎大多数WIF信息对于在整个应用程序中启用联合身份验证很有用。我有兴趣使用API创建SAML身份验证请求并接收/解释SAML响应。
我在SO上发现了以下帖子 从SAML令牌中读取SAML属性 这让我在接收和解释SAML响应方面朝着正确的方向前进。任何人都可以向我提供有关如何使用API创建SAML请求的更多信息吗?
一般来说,API上的更多信息(阅读材料,视频等)将不胜感激。
似乎大多数WIF信息对于在整个应用程序中启用联合身份验证很有用。我有兴趣使用API创建SAML身份验证请求并接收/解释SAML响应。
我在SO上发现了以下帖子 从SAML令牌中读取SAML属性 这让我在接收和解释SAML响应方面朝着正确的方向前进。任何人都可以向我提供有关如何使用API创建SAML请求的更多信息吗?
一般来说,API上的更多信息(阅读材料,视频等)将不胜感激。
这是一个小例子 我们的样品 它显示了如何以编程方式为STS创建(SAML)安全令牌请求:
private static SecurityToken GetSamlToken(string realm, string stsEndpoint, ClientCredentials clientCredentials)
{
using (var factory = new WSTrustChannelFactory(
new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
new EndpointAddress(new Uri(stsEndpoint))))
{
factory.Credentials.UserName.UserName = clientCredentials.UserName.UserName;
factory.Credentials.UserName.Password = clientCredentials.UserName.Password;
factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
factory.TrustVersion = TrustVersion.WSTrust13;
WSTrustChannel channel = null;
try
{
var rst = new RequestSecurityToken
{
RequestType = WSTrust13Constants.RequestTypes.Issue,
AppliesTo = new EndpointAddress(realm),
KeyType = KeyTypes.Bearer,
};
channel = (WSTrustChannel)factory.CreateChannel();
return channel.Issue(rst);
}
finally
{
if (channel != null)
{
channel.Abort();
}
factory.Abort();
}
}
这是一个小例子 我们的样品 它显示了如何以编程方式为STS创建(SAML)安全令牌请求:
private static SecurityToken GetSamlToken(string realm, string stsEndpoint, ClientCredentials clientCredentials)
{
using (var factory = new WSTrustChannelFactory(
new UserNameWSTrustBinding(SecurityMode.TransportWithMessageCredential),
new EndpointAddress(new Uri(stsEndpoint))))
{
factory.Credentials.UserName.UserName = clientCredentials.UserName.UserName;
factory.Credentials.UserName.Password = clientCredentials.UserName.Password;
factory.Credentials.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None;
factory.TrustVersion = TrustVersion.WSTrust13;
WSTrustChannel channel = null;
try
{
var rst = new RequestSecurityToken
{
RequestType = WSTrust13Constants.RequestTypes.Issue,
AppliesTo = new EndpointAddress(realm),
KeyType = KeyTypes.Bearer,
};
channel = (WSTrustChannel)factory.CreateChannel();
return channel.Issue(rst);
}
finally
{
if (channel != null)
{
channel.Abort();
}
factory.Abort();
}
}
由于没有其他人回答,这里有一篇来自无与伦比的Michelle Bustamante的文章: