在起诉NODEJS中的passport ci-oidc库时,间歇性地获取错误"state不匹配"



我们在NODEJS中使用passport ci oidc库通过云身份服务对用户进行身份验证。

身份验证时出现间歇性问题,出现错误。。。

Error: state does not match
at Strategy.authenticate (/media/cb-core-auth/node_modules/passport-ci-oidc/lib/strategy.js:359:23)
at attempt (/media/cb-core-auth/node_modules/passport/lib/middleware/authenticate.js:348:16)
at authenticate (/media/cb-core-auth/node_modules/passport/lib/middleware/authenticate.js:349:7)
at exports.sso_callback (/media/cb-core-auth/authentication/passport-ibmidci/callback.js:77:7)
at Layer.handle [as handle_request] (/media/cb-core-auth/node_modules/express/lib/router/layer.js:95:5)
at next (/media/cb-core-auth/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/media/cb-core-auth/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/media/cb-core-auth/node_modules/express/lib/router/layer.js:95:5)
at /media/cb-core-auth/node_modules/express/lib/router/index.js:281:22

你们能帮助我们解决这个间歇性的问题吗。

注意:我们不会将state作为我们战略的一部分发送。

这是一个错误,说明会话中应该保留的状态应该与OIDC提供程序的回调请求中返回的状态查询参数匹配。检查您的会话信息,以确保它保存在您的服务器上,并且会话cookie正在返回

@Lucifer007@SDRP我找到了这个临时解决方案,它不起作用,因为您可能有快速会话配置。此配置不适用于nginx代理。

cookie: {
secure: true
}

这就是我的原因,评论这句话解决了我的问题。虽然不是一个理想的解决方案。其他一些解决方案指向使用cookie会话而不是express会话来解决此问题。没有尝试过,但似乎有效。

最新更新