express-jwt-authz
express-jwt-authz copied to clipboard
Inquiry: Using `jwtAuthz` in a Route Handler function
Hi! Want to first thank the developers for making express-jwt-authz and express-jwt 🙌
Describe the problem you'd like to have solved
I am trying to use jwtAuthz within a Route Handler function, like such:
var jwt = require('express-jwt');
var jwtAuthz = require('express-jwt-authz');
var options = {};
app.get('/users',
jwt({ secret: 'shared_secret' }),
// jwtAuthz([ 'read:users' ], options),
function(req, res) {
jwtAuthz([ 'read:users' ], options) // not sure how to make this work here
}
);
Additional context
I have the following routes:
app.get('/a',
jwtAuthz(['read:a']),
...
);
app.get('/b',
jwtAuthz(['read:b']),
...
);
app.get('/c',
jwtAuthz(['read:c']),
...
);
I want to try the following:
app.get('/:letter',
function(req, res) {
jwtAuthz([ `read:${req.params.letter}` ])
}
);
Hope this makes sense (I am also not sure if this is considered bad practice or not, as I am fairly new to Auth0)