我们在 MEAN 堆栈中开发了应用程序。我们正在使用阿达尔角 https://github.com/AzureAD/azure-activedirectory-library-for-js用于天蓝色广告身份验证的库。根据文档和样本 https://azure.microsoft.com/en-us/documentation/articles/active-directory-devquickstarts-angular/
Adal.js 使用 OAuth 隐式流与 Azure AD 进行通信。你
必须为您的应用程序启用隐式流程。
但是,当我们启用隐式流时,Azure ADDOES NOT在令牌中包含组信息。该问题已讨论过here https://stackoverflow.com/questions/29762551/group-claims-with-azure-ad-and-oauth2-implicit-grant-in-adal-js详细信息并由 @vibronet 确认
Question
Azure AD 功能几乎每天都在变化,那么上述答案仍然有效吗?我们仍然需要启用应用程序的隐式流程吗?我想获取token中的群组信息(我不想使用 graph api 作为解决方案。)
我问这个问题的另一个原因是因为我disabled隐式流程和用户仍然能够访问应用程序。然而我还是没有看到group令牌中的信息。
Azure AD JWTdoes在隐式流中发出安全组。
在应用程序注册清单中,设置"groupMembershipClaims": "SecurityGroup"
,
然后在你的服务器中:
var groups = new List<string>();
ClaimsPrincipal.Current.Claims
.Where(t => t.Type == "groups")
.ForEach(g => groups.Add(g.Value));
不需要Graph Api
https://learn.microsoft.com/en-us/azure/architecture/multitenant-identity/app-roles https://learn.microsoft.com/en-us/azure/architecture/multitenant-identity/app-roles
https://github.com/Azure-Samples/active-directory-dotnet-webapp-groupclaims https://github.com/Azure-Samples/active-directory-dotnet-webapp-groupclaims
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)