【问题标题】:MVC Core + Azure Active Directory Get Groups from GraphAPIMVC Core + Azure Active Directory 从 Graph API 获取组
【发布时间】:2019-12-31 19:01:50
【问题描述】:

我正在尝试通过遵循此tutorial 在使用 Azure Active Directory 的 MVC Core 2.2 应用程序中实现身份验证。

我已经通过设置“groupMembershipClaims”:“SecurityGroup”适当地配置了清单,但仍然没有将组作为用户声明的一部分。看来我应该得到这样的东西

https://www.red-gate.com/simple-talk/cloud/security-and-compliance/azure-active-directory-part-4-group-claims/

在检查声明时,我似乎得到的只是“http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid:”

似乎如果用户分配了超过 4 个组,那么他们

will not be sent as part of the token. 并且需要使用 GraphAPI 为用户拉取组。

我似乎找不到任何资源来说明如何实现这一点并让它与它一起工作

    services.AddAuthorization(options =>
        {

            options.AddPolicy("Editor", policy => policy.RequireClaim("groups","XXXXXXXXXXXX"));

        });

有人能指出我正确的方向吗?

【问题讨论】:

    标签: c# azure authentication asp.net-core-mvc azure-active-directory


    【解决方案1】:

    这个@here有一个很好的答案。

    但是,它建议您获取给定用户的所有组成员身份 - 如果用户拥有大量组成员身份,这可能效率不高。

    您可以改用checkMemberGroups api。每次调用最多需要 20 个组 ID,这对于大多数情况来说应该足够了。

    【讨论】:

    • 这些都是很棒的资源。谢谢!
    猜你喜欢
    • 2019-12-20
    • 1970-01-01
    • 1970-01-01
    • 2020-04-27
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-26
    相关资源
    最近更新 更多