繁体   English   中英

没有从HttpContext.Current.GetOwinContext()。Authentication获得其他声明

[英]Not getting additional claims from HttpContext.Current.GetOwinContext().Authentication

我有一个使用Owin和Identity Server 4进行身份验证的.net表单客户端,但是我没有从HttpContext.Current.GetOwinContext()。Authentication.User处获得其他声明。 我究竟做错了什么?

我在IDS4上的accountController中添加其他声明,如下所示:

await HttpContext.Authentication.SignInAsync(user.SubjectId, user.Username, props, additionalClaims.ToArray());

在我的客户上:

if (!Request.IsAuthenticated)
            {               

                HttpContext.Current.GetOwinContext().Authentication.Challenge(
                    new AuthenticationProperties
                    {
                        RedirectUri = "/Default1.aspx",

                    },                 
                    OpenIdConnectAuthenticationDefaults.AuthenticationType);

            }
            else
            {         
                foreach (var claim in HttpContext.Current.GetOwinContext().Authentication.User.Claims)

您是否在“索赔”属性中收到以下索赔:

var claimsIdentity = HttpContext.Current.User.Identity as ClaimsIdentity;

这是他们将其与Owin和Cookie身份验证结合使用的方式,并且可以完美地工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM