【发布时间】:2020-08-12 21:58:12
【问题描述】:
我在节点项目中使用带有 PostGraphile 4.6.0 的 JWT 验证。这是sn-p的代码:
createServer(
postgraphile(env.DATABASE_URL, "public", {
jwtVerifyAlgorithms: ["RS256"],
jwtSecret: "./publickey.pem",
jwtPgTypeIdentifier: "public.jwt_token",
rejectUnauthorized: false,
graphiql: true,
enhanceGraphiql: true,
graphqlRoute: env.POSTGRAPHILE_ROUTE + "/graphql",
graphiqlRoute: env.POSTGRAPHILE_ROUTE + "/graphiql",
})).listen(port, () => {
console.log("Listening at port:" + port);});
但是当我使用 Postman 发送 RS256 加密的 JWT 令牌时,得到错误:
{
"errors": [
{
"message": "invalid algorithm"
}
]
}
我在 Postgres 中创建了一个函数来返回 JWT 令牌,它总是返回 HS256 加密的 JWT 令牌。我在 Postman 中使用 PostGraphile 返回的 HS256 加密 JWT 令牌,JWT 令牌经过验证,GrqphQL 查询返回正常。
看来“jwtVerifyAlgorithms”选项没有生效。
有没有办法让 RS256 加密的 JWT 令牌工作?
【问题讨论】:
标签: jwt