利用州/ customState和passport-azure-ad

我无法弄清楚customState的目的,如果/如何,我可以利用它来传递数据到返回的url。 具体而言,我希望在login后将用户路由回原来的位置。我想我可以将原始URL传递给参数customState并在返回URL POST customState其返回给我,但似乎是编码或可能换成不同的值。

这是我想要达到的:

  1. 匿名用户访问/page/protected需要authentication。
  2. 代码调用passport.authenticate ,然后redirect用户login。
  3. 用户/auth/oidc/return并返回到预先configuration的返回URL,例如: /auth/oidc/return
  4. 代码处理从表单提交数据中提取信息。
  5. 用户被引导回到/page/protected

在authentication中间件redirect并将authentication请求发送到Azure AD B2C之前,向req.session写入返回URL(例如“/ page / protected”),然后从req.session读取(然后删除)该返回URLauthentication中间件接收并validation来自B2C的authentication响应后,