Azure B2C注册策略重定向到应用程序后AngularJS哈希#问题 [英] AngularJS hash # problem after Azure B2C Sign Up policy redirects to application

查看:80
本文介绍了Azure B2C注册策略重定向到应用程序后AngularJS哈希#问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们想要做的是在用户成功注册后自动登录\登录.

What we'd like to do is to automatically Sign In\Login the user after they successfully Sign Up.

比方说,用户收到了该应用程序的邀请.他们进入注册"页面,填写表格,然后单击创建"按钮.如果一切正常,则将用户添加到Azure B2C目录,然后我们将以某种方式自动运行登录"策略或以其他方式自动登录.

Let's say the user got an invitation for the application. They go to the Sign Up page, fills out the form and clicks the Create button. If all is OK, the user is added to Azure B2C directory and then we'd somehow have the Sign In policy run automatically OR some other way of logging in automatically.

所以我只想知道使用Azure B2C时这是否可行.

So I just want to know if this is viable or not when using Azure B2C.

进一步调试后,我看到了问题所在...

After further debugging I see what is the problem...

我们有一个旧的AngularJS(1.6)SPA应用程序.

We have an old AngularJS (1.6) SPA application.

在用户完成注册过程之后,从Azure B2C发送回#id_token ...但是,在浏览器中的URL具有#id_token之后,控制权不会传递给应用程序,即OWIN中间件没有被调用.对于登录,它可以正常工作,因为它是从SPA本身开始的.用户单击登录"按钮,然后由msalService.loginRedirect重定向.

An #id_token is sent back from Azure B2C after the user completes the Sign Up process... however after the URL in the browser has the #id_token, control is not passed to the application, that is, OWIN middleware is not being called. For the Sign In it works as expected since it starts from within the SPA itself. The user clicks the Login button and is redirected by msalService.loginRedirect.

注册"策略的执行有所不同,因为它仅以电子邮件邀请链接开头.因此,它不是来自SPA本身. Azure B2C重定向回应用程序后,AngularJS会破坏#id_token的哈希部分.

The Sign Up policy execution is different because it starts by an e-mail invitation link only. So it's not from within the SPA itself. The hash portion of #id_token is being messed up by AngularJS once Azure B2C redirects back to the app.

我已经在AngularJS $locationProvider.html5(true)模式下玩过,但是没有用.

I already played with AngularJS $locationProvider.html5(true) mode but it did not work.

我现在想做的是重定向到自定义的signup.html回复URL,然后返回AngularJS应用,但我不确定如何进行连接.

What I'm trying to do now is to redirect to a custom signup.html reply URL and then return to the AngularJS app but I'm not sure how to wire up this.

推荐答案

默认情况下,在流程结束时(即,除密码重置流程和

By default, at the end of a flow (i.e. all built-in flows except the password reset flow and all custom flows except the password reset flow), an SSO session is generated for the user so, in effect, they are signed in after sign-up.

因此,同一会话中的默认体验是,如果用户注册了App A,然后被重定向以登录App B,则不会提示他们重新进行身份验证.

Therefore, the default experience in the same session is that, if a user signs up for App A and then is redirected to sign in for App B, then they won't be prompted to re-authenticate.

您可以配置注册和登录流程,以便它们发出相同的声明,以便应用程序可以以相同的行为处理注册和登录回调.

You can configure the sign-up and sign-in flows so that they issue the same claims so applications can handle the sign-up and sign-in callbacks with the same behavior.

这篇关于Azure B2C注册策略重定向到应用程序后AngularJS哈希#问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆