最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

azure - Restrict Access to Specific Pages Based on AAD Groups - Stack Overflow

programmeradmin4浏览0评论

I'm working on hosting Doxygen documentation using an Azure Static Web App in my company. I've set up an Azure DevOps pipeline to automatically deploy the files to Azure. Here's what I've achieved so far:

  • Configured app registration and enterprise app to restrict access to authenticated users from my company's Azure Active Directory tenant.
  • Limited access to specific groups within the enterprise app, and this part is working as expected.

Goal:
I need to restrict access to specific HTML pages based on AAD groups. For example:

  • Index.html → Accessible to all authenticated users
  • Venus.html → Only accessible to the Venus team group
  • Pluto.html → Only accessible to the Pluto team group

What I've Tried:

  1. Created roles in Azure AD and assigned them to the relevant groups.
  2. Configured staticwebapp.config.json as follows:
{
  "routes": [
    {
      "route": "/pluto*",
      "allowedRoles": [
        "pluto"
      ]
    },
    {
      "route": "/venus*",
      "allowedRoles": [
        "venus"
      ]
    },
    {
      "route": "*",
      "allowedRoles": [
        "authenticated"
      ]
    }
  ],
  "responseOverrides": {
    "401": {
      "statusCode": 302,
      "redirect": "/.auth/login/aad"
    }
  },
  "auth": {
    "identityProviders": {
      "azureActiveDirectory": {
        "registration": {
          "openIdIssuer": "/<redacted>/v2.0",
          "clientIdSettingName": "AZURE_CLIENT_ID",
          "clientSecretSettingName": "AZURE_CLIENT_SECRET"
        }
      }
    }
  }
}

However, this is not working as expected. When those certain groups try to access those pages it says it doesn't let them, it says access restricted.

Additional Information:

  • I'm using Azure Active Directory as the authentication provider.
  • Roles were assigned through the enterprise app's Users and Groups settings.
  • I cleared the browser cache.

Question:
How can I correctly restrict access to these pages based on AAD groups? Is my approach to using roles in staticwebapp.config.json correct, or should I take a different approach, like for each project create a separate static web app?

Any help would be greatly appreciated!

发布评论

评论列表(0)

  1. 暂无评论