声明中的Azure广告返回角色,但User.IsInRole返回false [英] Azure Ad Returning Roles in Claims but User.IsInRole returns false

查看:59
本文介绍了声明中的Azure广告返回角色,但User.IsInRole返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何想法可能是什么原因造成的吗?我可以在User.Claims中看到声明.我唯一能想到的是Azure广告角色的声明返回的方式与IsInRole()检查的内容不同吗?

Any idea what might be causing this? I can see the claims in User.Claims The only thing I can think of is that the claims from Azure Ad Roles come back differently than what IsInRole() checks for?

CorpAdmin角色显示在声明中.

User.IsInRole返回false

[Startup.Auth] [3]

[Startup.Auth][3]

请澄清一下,我要重新找回角色,但我认为这些角色未正确添加到声明列表中,我无法弄清楚原因.Nerith IsInRole或[Authorize(Roles ="...")]将正确检查角色声明.

Just to clarify, I AM getting roles back but I think they are not being added to the list of claims correctly and I cannot figure out why. Nerith IsInRole or [Authorize(Roles="...")] will correctly check the roles claims.

推荐答案

以下任何更改对我都有效:

Anyone of these changes worked for me:

            TokenValidationParameters = new TokenValidationParameters()
            {
                ValidateIssuer = false,
                RoleClaimType = System.Security.Claims.ClaimTypes.Role
            },

            TokenValidationParameters = new TokenValidationParameters()
            {
                ValidateIssuer = false,
                RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
            },

这篇关于声明中的Azure广告返回角色,但User.IsInRole返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆