在 OAuth 期间限制 office 365 中的资源访问

Restrict resources access in office 365 during OAuth

我们有一个 Web 应用程序,它使用 Azure AD 与 Office 365 进行 OAuth。我们正试图限制我们可以访问的资源。 示例:认证用户可以访问Site1、Site2 和Site3。我们想限制我们的应用程序仅访问 Site1。有谁知道这是否可能?我尝试查看 Office 365、Azure AD 甚至 Discovery API 文档,但找不到任何有用的信息。

您是否也在 Azure AD 上注册了 site1、site2 和 site3?如果我理解正确的话,我们可以为site1、site2和site 3配置应用程序清单来设置需要权限,如下所示(参考here

"oauth2Permissions": [
{
    "adminConsentDescription": "Allow the application full access to the Todo List service on behalf of the signed-in   user",
    "adminConsentDisplayName": "Have full access to the Todo List service",
    "id": "b69ee3c9-c40d-4f2a-ac80-961cd1534e40",
    "isEnabled": true,
    "type": "User",
    "userConsentDescription": "Allow the application full access to the todo service on your behalf",
    "userConsentDisplayName": "Have full access to the todo service",
    "value": "user_impersonation"
    }
],

然后我们需要为Web应用程序分配正确的权限作为Microsoft构建服务,如下图所示:

最后一步是site1、site2、site3需要通过分析access token中的scope来验证请求是否有访问资源的权限。

为了管理用户授权,您应该实施基于角色的访问控制,在此 link 您将找到一个使用 Azure AD 的示例 https://github.com/Azure-Samples/active-directory-dotnet-webapp-roleclaims