利用州/ customState和passport-azure-ad
我无法弄清楚customState
的目的,如果/如何,我可以利用它来传递数据到返回的url。 具体而言,我希望在login后将用户路由回原来的位置。我想我可以将原始URL传递给参数customState
并在返回URL POST
customState
其返回给我,但似乎是编码或可能换成不同的值。
这是我想要达到的:
- 匿名用户访问
/page/protected
需要authentication。 - 代码调用
passport.authenticate
,然后redirect用户login。 - 用户
/auth/oidc/return
并返回到预先configuration的返回URL,例如:/auth/oidc/return
。 - 代码处理从表单提交数据中提取信息。
- 用户被引导回到
/page/protected
。
在authentication中间件redirect并将authentication请求发送到Azure AD B2C之前,向req.session
写入返回URL(例如“/ page / protected”),然后从req.session
读取(然后删除)该返回URLauthentication中间件接收并validation来自B2C的authentication响应后,