【问题标题】:Configuring an Azure Static Web App to authenticate using Azure AD B2C配置 Azure 静态 Web 应用以使用 Azure AD B2C 进行身份验证
【发布时间】:2021-08-07 09:40:59
【问题描述】:

我已经使用 Azure 静态 Web 应用构建了一个基本的 Vue Web 应用,并且我正在尝试配置自定义身份验证。通过遵循documentation 并引用这个方便的blog post,我已经设法让一切(大部分)工作使用Auth0。

对于 Auth0,我在 local.settings.json 文件中添加了 AUTH0_ID=<my-auth0-id>AUTH0_SECRET=<my-auth0-secret>。我的 staticwebapp.config.json 看起来像这样:

...
"auth": {
      "identityProviders": {
        "customOpenIdConnectProviders": {
          "auth0": {
            "registration": {
              "clientIdSettingName": "AUTH0_ID",
              "clientCredential": {
                "clientSecretSettingName": "AUTH0_SECRET"
              },
              "openIdConnectConfiguration": {
                "wellKnownOpenIdConfiguration": "https://<my-auth0-tenant>/.well-known/openid-configuration"
              }
            },
            "login": {
              "nameClaimType": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
              "scopes": ["openid", "profile"]
            }
          }
        }
      }
    }

我现在正在尝试使用 Azure AD B2C 设置身份验证。我的理解是 Azure 静态 Web 应用程序处理部分身份验证,因此我应该将 ID 提供程序配置为与 Web 应用程序一起使用,而不是与单页应用程序框架一起使用。这是我在使用 Auth0 时所做的,它似乎有效。

我已将 AADB2C_ID=&lt;my-azure-ad-b2c-id&gt;AADB2C_SECRET=&lt;my-azure-ad-b2c-secret&gt; 添加到 local.settings.json 文件中。在 staticwebapp.config.json 中,我将 ClientIdSettingName 替换为 AADB2C_ID,将 clientSecretSettingName 替换为 AADB2C_SECRET,并将 wellKnownOpenIdConfiguration 替换为 https://&lt;my-azure-ad-b2&gt;.b2clogin.com/&lt;my-azure-ad-b2c&gt;.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=B2C_1_signupsignin1。这引用了我的 B2C 租户上的“signupsignin”用户流。

此时我可以访问指向 /.auth/login/aadb2c 的 /login,启动用户流程,并让我按预期进行注册和验证。然后在我的 Azure AD B2C 租户中创建测试用户。但是,B2C 然后尝试将我重定向到 /.auth/complete,这会引发 403 错误:

我们需要您的登录服务提供的电子邮件地址或句柄。使用 此登录名,请使用缺少的信息更新您的帐户。

我尝试在 Azure AD B2C 中添加 /.auth/complete 作为允许的重定向 URI,但这并不能解决问题。我在这里错过了什么?

【问题讨论】:

    标签: azure vue.js authentication


    【解决方案1】:

    尝试更改为:“nameClaimType”:“电子邮件”。 来自这里的 staticwebapp.config.json:https://github.com/Azure/static-web-apps/issues/457

    【讨论】:

      猜你喜欢
      • 2022-11-11
      • 2021-03-14
      • 1970-01-01
      • 2019-06-03
      • 2019-06-25
      • 2016-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多