简体   繁体   English

Azure AD B2C,使用Google Flutter进行Easy Auth身份验证

[英]Azure AD B2C with Easy Auth Authentication with Google Flutter

I am using Google flutter has a front end for mobile development and I am using Azure App Services as a backend. 我正在使用Google flutter有一个移动开发的前端,我使用Azure App Services作为后端。

How can I handle login and authentication so I can call Azure AD B2C using Easy Auth which is part of Azure App Services. 如何处理登录和身份验证,以便我可以使用Easy Auth调用Azure AD B2C,这是Azure App Services的一部分。 I haven't seen any SDK's for Flutter. 我还没有看到任何针对Flutter的SDK。 Flutter doesn't use Javascript, so I can't use the javascript to call it like I have seen in other Azure examples. Flutter不使用Javascript,所以我不能像我在其他Azure示例中看到的那样使用javascript来调用它。

Any thoughts? 有什么想法吗? I would think a lot of other would face this same issue since Azure is so popular. 我认为很多其他人会遇到同样的问题,因为Azure非常受欢迎。 I would like to use Google Firestore, but I can't since it's not HIPAA compliant. 我想使用Google Firestore,但我不能,因为它不符合HIPAA标准。

Since its a native app implementation, you could use the ROPC (resource owner password credential) flow to obtain a token for AAD B2C for your REST API. 由于它是本机应用程序实现,您可以使用ROPC(资源所有者密码凭据)流为您的REST API获取AAD B2C的令牌。 You create a policy like so: https://docs.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc 您可以创建如下策略: https//docs.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc

Then have the application make a REST API call to obtain a token: https://docs.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc#test-the-user-flow 然后让应用程序进行REST API调用以获取令牌: https//docs.microsoft.com/en-us/azure/active-directory-b2c/configure-ropc#test-the-user-flow

The App service needs to be setup with B2C as its authentication provider: Enable authentication. 需要使用B2C作为其身份验证提供程序来设置App服务:启用身份验证。 After this select “Azure Active Directory” under the list of Authentication Providers, this will open a new configuration blade, select “Advanced” and note the required fields, including Client ID and Issuer Uri – the Client Secret and Allowed Token Audiences are optional fields. 在此选择“身份验证提供程序”列表下的“Azure Active Directory”后,将打开一个新的配置刀片,选择“高级”并记下必填字段,包括客户端ID和颁发者Uri - 客户端密钥和允许的令牌受众是可选字段。 Go to the next steps to collect the application Client ID and Issuer URI values from B2C. 转到后续步骤以从B2C收集应用程序客户端ID和颁发者URI值。

Create a new B2C application. 创建一个新的B2C应用程序。 From the Azure Portal (optionally, you can open a separate browser tab or new browser session, keeping the previous blade open/available), go to your B2C Tenant Blade, and select Applications, then select +Add to create a New Application. 从Azure门户(您可以选择打开单独的浏览器选项卡或新浏览器会话,保持以前的刀片打开/可用),转到您的B2C租户刀片,然后选择应用程序,然后选择+添加以创建新应用程序。 In the New Application blade, give the app a friendly name, Select Yes for Web App/ Web API option, in the Reply URL section, enter in the full Azure website name that you created in step 2, and append it with: /.auth/login/aad/callback. 在“新建应用程序”边栏选项卡中,为应用程序指定一个友好名称,为“Web应用程序/ Web API”选项选择“是”,在“回复URL”部分中,输入您在步骤2中创建的完整Azure网站名称,并将其附加到:/。认证/登录/ AAD /回调。 For example: https://myAppSecuredByB2C.azurewebites.net/.auth/login/aad/callback 例如: https//myAppSecuredByB2C.azurewebites.net/.auth/login/aad/callback

Select Create. 选择创建。

Collect B2C Application ID. 收集B2C应用程序ID。 After successfully creating the application, go back to the B2C Admin Portal Application blade, find your newly created application and open the profile to collect the Application ID – copy this B2C application ID – this will be used to finish the Azure Function configuration. 成功创建应用程序后,返回B2C管理门户应用程序刀片,找到新创建的应用程序并打开配置文件以收集应用程序ID - 复制此B2C应用程序ID - 这将用于完成Azure功能配置。

Collect B2C OpenID Connect Metadata URL endpoint. 收集B2C OpenID Connect元数据URL端点。 Go to the top level Azure AD B2C blade, and select User Journeys, and select a Sign In Sign Up policy (or any other policy that you have created, and select the “Run user flow” button – once the blade is opened copy the Openid Metadata endpoint 转到顶级Azure AD B2C刀片,然后选择用户旅程,并选择登录注册策略(或您创建的任何其他策略,并选择“运行用户流”按钮 - 一旦刀片打开,请复制Openid元数据端点

Go back to the authentication blade of the App Service. 返回App Service的身份验证刀片。 Select: Azure Active Directory Settings – enter the B2C Application ID into the Client ID property. 选择:Azure Active Directory设置 - 在客户端ID属性中输入B2C应用程序ID。 Similarly, enter in the B2C Open ID Connect metadata URL into the Issuer URI property. 同样,在B2C Open ID Connect元数据URL中输入Issuer URI属性。 Select OK to finish the configuration. 选择“确定”完成配置。

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

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