You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Static Web App自定义Azure AD认证出现登录循环问题

问题:Azure Static Web App自定义认证部分用户陷入登录循环

我正尝试为Azure Static Web App构建自定义认证,已遵循微软官方的「通过Graph API分配角色」教程。目前仅两位用户可正常使用,其余用户均陷入登录循环。

已配置的staticwebapp.config.json内容

{
  "navigationFallback": {
    "rewrite": "/index.html",
    "exclude": ["/images/*.{png,jpg,gif}", "/css/*"]
  },
  "routes": [
    {
      "route": "/logout",
      "redirect": "/.auth/logout"
    },
    {
      "route": "/.auth/login/twitter",
      "statusCode": 404
    },
    {
      "route": "/.auth/login/github",
      "statusCode": 404
    },
    {
      "route": "/profile-management",
      "allowedRoles": ["manager"]
    },
    {
      "route": "/*",
      "allowedRoles": ["authenticated", "consultant", "manager"]
    }
  ],
  "auth": {
    "rolesSource": "/api/auth/getroles",
    "identityProviders": {
      "azureActiveDirectory": {
        "userDetailsClaim": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
        "registration": {
          "openIdIssuer": "https://login.microsoftonline.com/{tenant_id}",
          "clientIdSettingName": "Aad_Client_Id",
          "clientSecretSettingName": "Aad_Client_Secret"
        },
        "login": {
          "loginParameters": ["resource=https://graph.microsoft.com"]
        }
      }
    }
  },
  "responseOverrides": {
    "401": {
      "redirect": "/.auth/login/aad",
      "statusCode": 302
    }
  }
}

已完成的配置项

  • 应用注册的Client ID已配置在Azure Static Web App的应用设置中
  • 密钥以Key Vault引用形式设置,且Azure Static Web App已通过托管身份添加至Azure Key Vault
  • 已完成Azure Static Web App与对应应用注册的关联配置

内容的提问来源于stack exchange,提问作者DaniëlC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 08:25:24