【问题标题】:Azure ADAL with Web API and Native app带有 Web API 和本机应用程序的 Azure ADAL
【发布时间】:2018-10-11 19:58:44
【问题描述】:

我目前有一个 Xamarin Forms 应用程序正确登录并使用 Microsoft Azure AD 进行身份验证,然后才能访问也在 Azure 中配置的 Web api。

现在我想像以前使用 IdentityServer 4.0 一样添加基于角色的授权。 所以在我的 webapi 中,我把它放在了我的控制器上:

[Authorize(Roles = "SOMEDOMAIN\\ADGroup")]

所以现在我正在尝试关注网络上的文档,但人们的描述性不够。我有 1 个问题,但让我先解释一下我的设置。

对于我的本机 Xamarin 应用程序

在“必需的权限”下

  • 我已经添加了 Windows Azure Active Directory
  • 我已经添加了我的 web api

我编辑了清单

  • “groupMembershipClaims”:“SecurityGroup”,

对于我的 Web API

在“必需的权限”下

  • 我已经添加了 Windows Azure Active Directory

我编辑了清单

  • “groupMembershipClaims”:“SecurityGroup”,

问题

1) 在上述每个应用程序中,我是否需要启用Read Directory Data 以获得Windows Azure Active Directory 权限?如果没有,谁需要它?

【问题讨论】:

    标签: azure xamarin.forms azure-active-directory adal


    【解决方案1】:

    在应用程序清单中,“groupMembershipClaims”:“SecurityGroup”应将 groups 声明添加到 JWT。然后,您只需要 Azure AD 中您尝试定位的安全组的 ObjectId,详细讨论 here。组信息是id_token 的一部分,根据文档here

    提供代表主题组成员身份的对象 ID。这些值是唯一的(请参阅对象 ID)并且可以安全地用于管理访问,例如强制授权访问资源。组声明中包含的组是通过应用程序清单的“groupMembershipClaims”属性基于每个应用程序配置的。 null 值将排除所有组,“SecurityGroup”值将仅包括 Active Directory 安全组成员资格,“All”值将包括安全组和 Office 365 分发列表。

    另外,请阅读关于 ADAL 库 here 的 Github 存储库上的非常详尽的 Wiki。

    另外,这里有一些关于 groups 声明的好资源,最后一个是示例解决方案:

    http://www.cloudidentity.com/blog/2013/01/22/group-amp-role-claims-use-the-graph-api-to-get-back-isinrole-and-authorize-in-windows-azure-ad-apps/

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

    https://azure.microsoft.com/en-gb/resources/samples/active-directory-dotnet-webapp-groupclaims/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-18
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-25
      • 2018-03-19
      相关资源
      最近更新 更多