【问题标题】:Azure JWT with property "hasgroups=true" instead of groups property object具有属性“hasgroups=true”而不是组属性对象的 Azure JWT
【发布时间】:2019-04-08 05:04:33
【问题描述】:

我有一个带有 Azure Active Directory 身份验证的 Azure Web 应用程序(使用 adal-angular 制作);

在应用程序清单中我设置了"groupMembershipClaims": "SecurityGroup"

奇怪的是,在某些日子里,对于一个用户来说,它在 AAD 令牌中没有包含组成员对象 ID 列表的组声明,而是有一个名为 hasgroups 的属性,其值为 true .

我能做点什么吗? 现在我将检查是否有一个属性或另一个,然后调用 GraphAPI 以获得直接组成员身份。

【问题讨论】:

    标签: azure-web-app-service azure-active-directory


    【解决方案1】:

    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
    

    【讨论】:

    • 限制是 200,现在是 5?我唯一能想到的词是“不公平”
    • 问题出现在具有 7 个安全组成员的配置文件中
    • @MicheleT 7 是这种情况...奇怪我以为 MS 将它设置为 200,为什么它是 7?
    • 我相信早期是 200,但现在似乎是 5……但这有点太严格了。谁有 5 个或更少的组?我的普通用户帐户上有 23 个!
    • 此限制仅适用于通过隐式流(adal.js、msal.js)获得的访问令牌。请参考下面的详细答案?
    【解决方案2】:

    请检查您使用的是Authorization Code grant 还是implicit grant

    hasGroups 声明仅在implicit_grant 的情况下提供,groups 声明中提供的组数限制为 6 个,因为更多会扩展 URI 片段超出 URL 长度限制。请参阅Azure Active Directory access tokens 中的 hasGroupsgroups 声明文档。

    【讨论】:

      猜你喜欢
      • 2022-01-23
      • 2014-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-31
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      相关资源
      最近更新 更多