【发布时间】:2021-08-25 20:59:19
【问题描述】:
我的应用程序使用 Google 的身份验证和浏览器将 idToken 发送到我的 API 服务器。我使用checkIfAuthenticated 来验证 idToken,一旦验证成功,就需要从中解码/提取信息。但我不知道如何解码/提取。
这是验证和路由的方式:
const jwksRsa = require('jwks-rsa');
const expressJwt = require('express-jwt');
const checkIfAuthenticated = () =>
{
var googleUri = "https://www.googleapis.com/oauth2/v3/certs";
expressJwt({
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksUri: googleUri
}),
algorithms: ['RS256']
});
// try to decode but gave me a definition of ƒ (req, res, next){...
var data = expressJwt({secret: googleUri, requestProperty: 'auth', algorithms: ['RS256'] });
}
module.exports = app =>
{
app.post("/needvalidation", checkIfAuthenticated, ... );
};
【问题讨论】:
标签: node.js express-jwt