我正在使用'express-jwt-authz'来验证jwt令牌的范围,我实现了如下流程。在这里,当我从路由中调用“ checkScopes”函数但它永远不会返回结果时,“ jwtAuthz”的回调不会引发任何成功或错误情况。如何在'express-jwt-authz'auth npm中检查错误处理。
Middleware
validation.js
const jwt = require('express-jwt');
const jwtAuthz = require('express-jwt-authz');
const jwksRsa = require('jwks-rsa');
const config = require('../config/config');
module.exports.checkScopes = function(options) {
return function(req, res, next) {
jwtAuthz(options, {customScopeKey: 'http://user.com/scopes'}, function(error) {
if (error) {
console.log('error', error)
} else {
console.log('result never called')
next();
}
})
}
}
Routes
invitation.js
const express = require('express');
const router = express.Router();
const jwtValidation = require('../middleware/jwtValidation');
router.get('/', jwtValidation.checkScopes([ 'create:users' ]), invitation.getAllInvitation);