我有一个Azure Web应用程序,使用Azure Active Directory身份验证(使用adal-angular制作);
在应用程序清单中,我设置了"groupMembershipClaims": "SecurityGroup"
奇怪的是,在某些日子里,对于一个用户来说,它在AAD令牌中没有组声明,其中包含组成员身份objectIds的列表,而是有一个名为hasgroups
的属性,其值为{ {1}}。
我能为此做些什么吗? 现在我要检查是否有一个属性或另一个属性,然后调用GraphAPI直接成为组成员。
答案 0 :(得分:6)
hasGroups=true
。我不知道确切的阈值是多少( 20?200?)但实际上你需要在你的代码中做的是(伪代码):
if (hasGroups)
Call the Graph to inquire:
Either about the full group membership OR
About membership to a particular group
else
Access groups directly from the token
Get all the groups a users belongs to:
https://graph.windows.net/myorganization/users/{user_id}/$links/memberOf?api-version
Inquire whether the user belongs to a specific group:
https://graph.windows.net/myorganization/users/{user_id}/isMemberOf?api-version
答案 1 :(得分:0)
请检查您使用的是Authorization Code grant还是implicit grant?
hasGroups 声明仅在implicit_grant的情况下提供,并且 groups 声明中提供的组数限制为6个,以便扩展URI片段超出网址长度限制。请参阅Azure Active Directory access tokens中的 hasGroups 和 groups 声明文档。