Azure B2C AD 重定向到 Angular 应用程序

Azure B2C AD Redirect to Angular App

我正在尝试 运行 this Angular 4 example 使用 Azure B2C Active Directory 和 adal-angular 4.

对于 运行 应用程序,我在 Azure 中创建了一个租户,在 AD B2C 中注册了该应用程序并添加了 Url 的回复 https://localhost:4200。然后我将应用程序 ID 和租户添加到我的 Angular 应用程序。

当我 运行 应用程序时,它正确地重定向到 https://login.microsoftonline.com... 加载登录。正确登录会重定向到 https://localhost:4200

登出时出现问题。该应用程序被重定向到 this static logout page 而不会重定向回我的应用程序。

我尝试在 Azure Active Directory(不是 B2C)中注册一个应用程序,将其配置数据移动到我的 Angular 应用程序中,当我 运行 它并注销时它暂时重定向到 this "logging you out" page 重定向回应用程序。

注销后的重定向 url 除了租户名称外都是相同的,只有 B2C 死掉了。 Chrome 和 Edge 都会发生这种情况。

我希望这不仅仅是 B2C 和常规 AD 之间的功能差异。我检查了我的配置,但也许这是我错过的 Azure 门户中的内容?

注销请求应包括 "p" 和 "post_logout_redirect_uri" 参数,例如:

GET https://login.microsoftonline.com/{tenant}/oauth2/v2.0/logout?p=b2c_1_sign_up_sign_in&post_logout_redirect_uri=https%3A%2F%2Flocalhost%3A4200%2F

如果未指定 "post_logout_redirect_uri" 参数,Azure AD B2C 将显示一条通用消息。

你应该使用 MSAL.js w/ Azure AD B2C.

ADAL ... is designed to only work against Azure AD "classic" (e.g. - NOT B2C)

参考:


看到这个Angular 4 example that uses MSAL.js