简体   繁体   English

如何通过 Azure AD B2C 使用身份验证功能在 Azure Web 应用程序上添加身份验证?

[英]How to add authentication on Azure Web App using Authentication feature via Azure AD B2C?

I would like to add authentication to a web application running on Azure Web Apps using Azure AD B2C.我想为在 Azure Web 应用程序上运行的 web 应用程序添加身份验证。

To do so, I followed the following steps:为此,我按照以下步骤操作:

  1. Create an tenant on Azure AD B2C在 Azure AD B2C 上创建租户
  2. Add app registration and client key添加应用注册和客户端密钥
  3. Add user flow添加用户流
  4. From "Authentication" (on the left side panel) on Azure Web Apps, I chose Microsoft as identity provider and supplied configurations based on the values obtained in the previous steps.从 Azure Web 应用程序的“身份验证”(左侧面板上)中,我选择 Microsoft 作为身份提供者,并根据前面步骤中获得的值提供配置。

But when I accessed the Azure Web Apps url, I was not redirected to the login page, but got the following message.但是当我访问 Azure Web 应用程序 url 时,我没有被重定向到登录页面,而是收到以下消息。

{"code":401,"message":"An error of type 'unauthorized_client' occurred during the login process: 'AADB2C90057: The provided application is not configured to allow the 'OAuth' Implicit flow.\r\nCorrelation ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\r\nTimestamp: 2021-04-09 10:06:00Z\r\n'"}

Also, in the edit page of identify provider, it says Application with ID xxxxxxxxxxxxxxxx not found in the current tenant. Tenant ID: yyyyyyyyyyyyyyyyy.此外,在识别提供者的编辑页面中,它Application with ID xxxxxxxxxxxxxxxx not found in the current tenant. Tenant ID: yyyyyyyyyyyyyyyyy. Application with ID xxxxxxxxxxxxxxxx not found in the current tenant. Tenant ID: yyyyyyyyyyyyyyyyy.

This obviously means that the application I registered on the Azure B2C tenant is not on the same tenant as one the Azure Web Apps is linked.这显然意味着我在 Azure B2C 租户上注册的应用程序与 Azure Web 应用程序之一不在同一租户上。

My question is "how to add authentication on Azure Web App using its "Authentication" feature via Azure AD B2C?".我的问题是“如何通过 Azure AD B2C 使用其“身份验证”功能在 Azure Web 应用程序上添加身份验证? Does Microsoft identity provider of The "Authentication" feature only support clients on the same tenant as Azure Web Apps? “身份验证”功能的 Microsoft 身份提供程序是否仅支持与 Azure Web 应用程序位于同一租户的客户端?

how to add authentication on Azure Web App using its "Authentication" feature via Azure AD B2C?如何通过 Azure AD B2C 使用其“身份验证”功能在 Azure Web 应用程序上添加身份验证?

According to your error, it should be caused by your application not enabling implicit flow.根据您的错误,这应该是由于您的应用程序未启用隐式流造成的。 So, you need to enable it in Azure B2C.因此,您需要在 Azure B2C 中启用它。

  1. Go to Azure B2C portal>App registrations>your app>Authentication. Go 到 Azure B2C 门户>应用注册>您的应用>身份验证。

在此处输入图像描述

2.Go to Azure B2C portal>Applications (Legacy)>your app. 2.Go 到 Azure B2C 门户>应用程序(旧版)>您的应用程序。

在此处输入图像描述

Does Microsoft identity provider of The "Authentication" feature only support clients on the same tenant as Azure Web Apps? “身份验证”功能的 Microsoft 身份提供程序是否仅支持与 Azure Web 应用程序位于同一租户的客户端?

Yes.是的。

Go to Azure App Service --> Under Settings Click Authentication AppService Authentication Go 到Azure App Service --> 在Settings点击Authentication AppService Authentication

Edit Authentication Settings and select RequiresAuthentiction Authentication allow编辑身份验证设置和 select RequiresAuthentiction身份验证允许

Then Click on Add Identity Provider and Select the Identity provider from the list Select Provider然后单击添加身份提供者和 Select 身份提供者列表Select 提供者

After Selecting Identity Provider choose App Registration type .选择身份提供者后,选择App Registration type Microsoft itsef creates and registers App registration for top 2 choices --> If you choose Provide the details of an existing app registration follow below steps Microsoft itsef 为前 2 个选项创建和注册应用程序注册 --> 如果您选择提供现有应用程序注册的详细信息,请按照以下步骤操作

To create an App Registration in AAD follow this link-- https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#register-an-application-with-azure-ad-and-create-a-service-principal要在 AAD 中创建应用程序注册,请点击此链接 - https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#register-an-application-使用 azure-ad-and-create-a-service-principal

1.Fill the Application Client Id which is App Registration ID you will get on creating App Registration 1.填写应用程序客户端ID ,即应用程序注册ID ,您将在创建应用程序注册时获得

2.provide client secret which you can create on App Registration 2.提供您可以在应用注册时创建的客户端密码

3. Issuer url would be -- https://sts.windows.net/{tenant-id}/v2.0 (replace with your Tenant ID inside{}) 3.颁发者 url将是 -- https://sts.windows.net/{tenant-id}/v2.0 (在里面替换为您的租户 ID{})

4. Allowed token audiences would be -- api://{Application-Client-Id} (replace with your Application Client Id inside{}) Authentication and Click Add 4.允许的令牌受众将是 -- api://{Application-Client-Id} (替换为您的应用程序客户端 ID {})身份验证并单击添加

5.Final task is to add Authentication scope Goto your AppRegistration in AAD and click Authentication Authentication AAD 5.最后的任务是添加Authentication scope Goto your AppRegistration in AAD and click Authentication Authentication AAD

  1. click on Add a platform and select Web点击添加平台和 select Web

7.After selecting add a Redirect URI Redirecting URI would be https://{appservice-name}.azurewebsites.net/.auth/login/aad/callback (replace with your app service name inside{}) and select ID Tokens Rediret URL Click on configure 7. 选择添加重定向 URI后,重定向 URI 将是https://{appservice-name}.azurewebsites.net/.auth/login/aad/callback (替换为您的应用服务名称内{})select ID 令牌URL点击配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM