【发布时间】:2014-11-07 12:44:31
【问题描述】:
如何从ClaimsPrincipal获取SecurityToken?
我需要它,因为我想将它从 MVC 应用程序传递到 AuthenticationManager / Authenticate 中的 WCF 服务。
在 Authenticate 方法中,BootstrapContext 的值为 null。即使经过身份验证,它有时也会变为空,这对我来说不是一个可靠的选择。
这是我的身份验证管理器类:
public override ClaimsPrincipal Authenticate(string resourceName, ClaimsPrincipal incomingPrincipal)
{
string passportID = incomingPrincipal.Identity.GetPassportID().ToString();
try
{
// I need the token here
SecurityToken token = GetToken(incomingPrincipal);
return base.Authenticate(resourceName, incomingPrincipal);
}
catch (Exception ex)
{
throw new SecurityException("User is not authenticated.", ex);
}
}
【问题讨论】:
标签: .net authentication identity claims-based-identity federated-identity