Azure 基于范围/角色/组的访问控制

Azure 基于范围/角色/组的访问控制,azure,oauth,oauth-2.0,azure-active-directory,access-control,Azure,Oauth,Oauth 2.0,Azure Active Directory,Access Control,我正在使用Azure Active Directory,并试图了解所描述的三种访问控制类型。每种方法的优缺点是什么?您将在何时使用它们: 使用清单的oauth2Permissions部分进行基于范围的访问控制,我可以在其中添加读写权限,如下所示: { "adminConsentDescription": "Allow the application read access to MyApi on behalf of the signed-in user.", "adminConsent

我正在使用Azure Active Directory,并试图了解所描述的三种访问控制类型。每种方法的优缺点是什么?您将在何时使用它们:

  • 使用清单的
    oauth2Permissions
    部分进行基于范围的访问控制,我可以在其中添加读写权限,如下所示:

    { "adminConsentDescription": "Allow the application read access to MyApi on behalf of the signed-in user.", "adminConsentDisplayName": "Read access to MyApi", "id": "56d944c0-f3aa-4f80-9472-9c1414383abf", "isEnabled": true, "type": "User", "userConsentDescription": "Allow the application read access to MyApi on your behalf.", "userConsentDisplayName": "Read access to MyApi", "value": "read_my_api" }, { "adminConsentDescription": "Allow the application write access to MyApi on behalf of the signed-in user.", "adminConsentDisplayName": "Write access to MyApi", "id": "6d66a2bd-c8c7-4ee0-aef4-9424b51b4967", "isEnabled": true, "type": "User", "userConsentDescription": "Allow the application write access to MyApi on your behalf.", "userConsentDisplayName": "Write access to MyApi", "value": "write_my_api" } { “AdminApprovementDescription”:“允许应用程序代表登录用户读取MyApi。”, “AdminApproverDisplayName”:“对MyApi的读取权限”, “id”:“56d944c0-f3aa-4f80-9472-9c1414383abf”, “isEnabled”:没错, “类型”:“用户”, “UserApprovementDescription”:“允许应用程序代表您读取MyApi。”, “用户名”:“对MyApi的读取权限”, “值”:“读取我的api” }, { “AdminApprovementDescription”:“允许应用程序代表登录用户对MyApi进行写访问。”, “AdminApproverDisplayName”:“对MyApi的写入访问权”, “id”:“6d66a2bd-c8c7-4ee0-aef4-9424b51b4967”, “isEnabled”:没错, “类型”:“用户”, “UserApprovementDescription”:“允许应用程序代表您对MyApi进行写访问。”, “用户名”:“对MyApi的写入访问权”, “值”:“编写我的api” }
  • 基于角色的访问控制(RBAC)-使用我清单的
    appRoles
    部分

  • 使用我的清单的
    groupMembershipClaims
    部分进行基于组的访问控制
两种最流行的方法:

  • 基于角色的访问控制-您正在为应用程序配置(Azure门户内部)中的用户或组分配角色。然后在代码中,您可以使用这些角色授权用户访问应用程序的某些部分。您可以执行以下操作:
    if(User.IsInRole(“SuperAdmin”){…}
  • 使用groupMembershipClaims的基于组的访问控制-这与此类似,但您要检查用户是否属于特定组

我认为范围和角色/组之间最重要的区别在于谁决定了允许客户做什么

  • 资源范围由资源所有者(用户)通过“同意”屏幕授予应用程序。例如,客户端应用程序可以发布到我的时间轴或查看我的朋友列表
  • 用户角色和组由Azure AD目录的管理员分配。例如,用户可以提交费用报告,也可以批准费用报告
当外部应用程序希望通过公开的API访问用户的数据时,通常使用作用域。它们决定客户端应用程序可以做什么

基于角色或组的访问通常在应用程序中用于确定用户可以做什么