在 Azure Web App 中检索 Azure AD 用户组信息服务器端

问题描述 投票:0回答:1

我正在使用 Azure AD 在 Azure Web 应用程序中进行身份验证。虽然我可以通过 /.auth/me 端点客户端访问用户信息,但出于安全原因,我需要在服务器端获取用户组成员身份。如何在 Azure Web Apps 中的服务器端检索此信息?

authentication azure-active-directory azure-webapps azure-entra-id
1个回答
0
投票

我同意@Dai,在Azure Web App环境中,直接在服务器端检索Azure AD用户组信息是不可行的。您需要使用 Microsoft Graph API。

因此,通过调用以下 Microsoft Graph API 查询来修改代码以检索登录用户的组成员身份:

GET https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group
  • transitiveMemberOf
    返回与组嵌套相关的组

enter image description here

如果您想获取群组用户是的直接成员,请使用以下查询:

GET https://graph.microsoft.com/v1.0/me/memberOf/microsoft.graph.group

enter image description here

确保向 Microsoft Entra ID 应用程序授予

GroupMember.Read.All
API 权限。

参考资料:

列出用户的直接成员资格 - Microsoft Graph v1.0 |微软

active-directory-aspnetcore-webapp-openidconnect-v2/2-WebApp-graph-user (github.com)

© www.soinside.com 2019 - 2024. All rights reserved.