在Azure Web App容器中使用B2C身份验证时重定向错误 [英] Redirect error when using B2C authentication inside Azure Web App for Containers
问题描述
我有一个ASP Core 2.1 Web应用程序,在Startup.cs中使用.AddAzureADB2C()身份验证时会引发错误.我知道我的代码和B2C租户配置有效,因为我已经使用本地主机答复URL在本地计算机上对其进行了测试,但是当 该应用程序托管在使用Docker和SSL绑定的Azure容器容器应用程序中,它将引发以下错误:
I have an ASP Core 2.1 web application that throws an error when using .AddAzureADB2C() authentication in the Startup.cs. I know my code and B2C tenant configuration works because I have tested it on my local machine using a localhost reply URL but when the application is being hosted in an Azure App for Container environment that uses Docker and SSL binding it throws the below error:
请求中提供的重定向URI'http://.../callback-path'未为客户端ID'...'注册
The redirect URI 'http://.../callback-path' provided in the request is not registered for the client id '...'
使用Chrome DevTools时,我在B2C回调请求中发现了错误>带有保存日志"的网络打勾,似乎是什么问题.在Azure门户上定义的B2C租户的回复URL已向"https://..."注册, 但是由代码生成的URL(该代码随后附加了我的回调路径)是使用"http://.../callback-path"生成的.
I find the error in the B2C callback request when using the Chrome DevTools > Network with "Preserve log" ticked and it seems clear as to what the problem. The B2C tenant's reply URL, as defined on the Azure portal, is registered with "https://....", but the URL generated by the code which then appends my callback path is being generated with "http://.../callback-path".
有人知道如何解决这个问题吗?
Does anybody know how to solve this problem?
推荐答案
您需要两个单独的应用程序注册:
You need two separate app registrations:
Azure AD B2C中的一个用于您的应用程序-该应用程序具有应用程序的重定向URL:
One in Azure AD B2C for your app - this one has your apps' redirect URLs:
http://localhost:55838/signin-oidc(示例)
http://localhost:55838/signin-oidc(example)
https://coredwexposure.onmicrosoft.com/signin-oidc(示例)
https://coredwexposure.onmicrosoft.com/signin-oidc(example)
Azure AD中的一个用于Azure AD B2C-此对象具有B2C作为重定向URL:
One in Azure AD for Azure AD B2C - this one has B2C as the redirect URL:
https://login.microsoftonline.com/te/coredwexposureb2c.onmicrosoft.com/oauth2/authresp
https://login.microsoftonline.com/te/coredwexposureb2c.onmicrosoft.com/oauth2/authresp
本文 ;有更多信息.
检查此链接以解决此问题
Check this links to solve this
https://social.msdn.microsoft.com/Forums/azure/zh-CN/919d5cb8-632c-4e66-9ef0-eb0d6e21a685/cant-redirect-to-azure-ad-b2c-login-page?forum = WindowsAzureAD
https://social.msdn.microsoft.com/Forums/azure/en-US/919d5cb8-632c-4e66-9ef0-eb0d6e21a685/cant-redirect-to-azure-ad-b2c-login-page?forum=WindowsAzureAD
请遵循本文档中的步骤
https://docs.microsoft.com/zh-CN/azure/active-directory-b2c/active-directory-b2c-app-registration
https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-app-registration
这篇关于在Azure Web App容器中使用B2C身份验证时重定向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!