【发布时间】:2018-08-02 22:08:03
【问题描述】:
我有一组声明。我正在使用它来创建 ClaimsIdentity。我还使用 OWIN 登录身份。此外,我将它添加到 ClaimsPrincipal.Current.Identities。这是我的代码...
[HttpPost]
[AllowAnonymous]
public async Task<ActionResult> LogonCallBack()
{
var token = Request.Params["id_token"];
var validatedToken = TokenService.ValidateIdToken(token);
var identity = new ClaimsIdentity(validatedToken.Claims);
HttpContext.GetOwinContext().Authentication.SignIn(new AuthenticationProperties { IsPersistent = false }, identity);
ClaimsPrincipal.Current.AddIdentity(identity);
return RedirectToAction("Display");
//return RedirectToAction("Index", "Error", new { area = "Token Validate Failed." });
}
在调试时,我发现我正在检索的一组声明运行良好。我可以创建 ClaimsIdentity。但是,在此之后,当我被重定向到显示页面时,User.Identity.IsAuthenticated 仍然是错误的。 ClaimsPrincipal.Current 在其列表中没有添加的标识。
我怎样才能让用户通过身份验证?
【问题讨论】:
标签: owin claims-based-identity claims openid-connect