我有一个在 EC2 实例上运行的 express 应用程序,我的后端使用 Node.js。我使用 Okta 来铸造/验证令牌以进行身份验证,多年来一直有效(未受影响)。突然,我的应用程序无法再访问我的服务器,当我使用邮递员尝试查询一些数据时,我收到以下错误:
Error while resolving signing key for kid "Py9YS2tY1x--ESeMbRQVg6lWzKm45cQfZgk0GitmUpc"
我查看了 Okta 的文档,但似乎没有任何帮助。同样,这已经工作了多年。这是进行验证的 auth.js 文件:
const OktaJwtVerifier = require('@okta/jwt-verifier')
const oktaJwtVerifier = new OktaJwtVerifier({
issuer: process.env.ISSUER,
clientId: process.env.CLIENT_ID})
module.exports = async (req, res, next) => {
try {
const { authorization } = req.headers
if (!authorization) throw new Error('You must send an Authorization header')
const [authType, token] = authorization.trim().split(' ')
if (authType !== 'Bearer') throw new Error('Expected a Bearer token')
const { claims } = await oktaJwtVerifier.verifyAccessToken(token, 'api://default')
if (!claims.scp.includes(process.env.SCOPE)) {
throw new Error('Could not verify the proper scope')
}
next()
} catch (error) {
next(error.message)
}
}
发行人和 clientID 都没有改变,什么都没有改变。据我所知,唯一发生变化的是在此之前,EC2 实例从 t2.micro 升级到 t2.small,存储空间从 8 GB 增加到 16 GB。此过程确实需要停止/启动/重新启动/等实例。然而,停止/启动/重启在过去已经多次完成,而且这个问题从未出现过。
非常感谢您的帮助!
.