Azure AD:如何获取令牌中的组信息? [英] Azure AD: How to get group information in token?

查看:106
本文介绍了Azure AD:如何获取令牌中的组信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经在MEAN堆栈中开发了应用程序。我们正在使用 adal-agular 库进行天蓝色广告身份验证。根据文档和示例

We have application developed in MEAN stack. We are using adal-agular library for azure ad authentication. As per the documentation and sample


Adal.js使用OAuth隐式流与Azure AD进行通信。
必须为您的应用程序启用隐式流。

Adal.js uses the OAuth implicit flow to communicate with Azure AD. You must enable the implicit flow for your application.

但是,当我们启用隐式流时,Azure AD 不要在令牌中包含组信息。已在此处中对该问题进行了讨论详细信息并由@vibronet确认

However when we enable implicit flow, Azure AD DOES NOT include group information in the token. The issue has been discussed here in detail and confirmed by @vibronet

问题

Azure AD功能几乎每天都在变化,因此上述答案仍然有效吗?我们仍然需要启用应用程序的隐式流吗?我想获取令牌中的组信息(我不想使用图形api作为解决方案。)

我问这个问题的另一个原因因为我禁用,隐式流程和用户仍然能够访问该应用程序。但是我仍然看不到令牌中的 group 信息。

another reason i am asking this question because i disabled the implicit flow and user was still able to access the application. However i still don't see group information in the token.

推荐答案

Azure AD JWT 确实以隐式流程发出安全组。
在应用程序注册清单中,设置 groupMembershipClaims: SecurityGroup

Azure AD JWT does emit security groups in implicit flow. In Application Registration manifest, set "groupMembershipClaims": "SecurityGroup",

然后在服务器中:

 var groups = new List<string>();
        ClaimsPrincipal.Current.Claims.Where(t => t.Type == "groups")
    .ForEach(g => groups.Add(g.Value));

不需要GraphApi

no need for GraphApi

https://docs.microsoft.com/zh-CN/azure / architecture / multitenant-identity / app-roles
https://github.com/Azure-Samples/active-directory-dotnet-webapp-groupclaims

这篇关于Azure AD:如何获取令牌中的组信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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