Hi community, looking for some assistance on Auth0 RBAC with nodejs.
I have configured RBAC on Auth0, angular frontend and nodejs backend. The nodejs backend uses express-jwt-authz. When i print out the token and go to jwt.io i can see everything is as it should be however the server is returning 403 forbidden on my route. Permissions are sent as read:employees and is configured exactly the same in the code as you can see before.
I have placed the node js code along with an example token of what the server is seeing:
const express = require(âexpressâ);
const router = express.Router();
const { expressjwt: jwt } = require(âexpress-jwtâ);
const jwks = require(âjwks-rsaâ);
const jwtAuthz = require(âexpress-jwt-authzâ);
const authorizeAuth0Token = jwt({
secret: jwks.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: ${process.env.AUT0_DOMAIN}.well-known/jwks.json
}),
audience: process.env.AUT0_AUDIENCE,
issuer: process.env.AUT0_DOMAIN,
algorithms: [âRS256â]
});
const checkAuthPermissions = jwtAuthz([âread:employeesâ], {
customScopeKey: âpermissionsâ
});
router.get(â/employeesâ,authorizeAuth0Token, checkAuthPermissions, (req, res) => {
res.status(200).json({âtestâ:âthis api call is goodâ})
});
Token: eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImdRUjNLdHFheWpGc2Z6Y05qUGFKSSJ9.eyJpc3MiOiJodHRwczovL2Rldi1ibGE1Z3Q0aGh5M2Rwd3Y2LnVzLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw2MzhiOWQwMjg3NzlhMDBlNTI2YTU0NWMiLCJhdWQiOlsiaHR0cHM6Ly9taXRhc2svYXBpIiwiaHR0cHM6Ly9kZXYtYmxhNWd0NGhoeTNkcHd2Ni51cy5hdXRoMC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNjcwNjQxNDEwLCJleHAiOjE2NzA2NDUwMTAsImF6cCI6IkF2SWt4U0lqTUxleU9PVjNQMkdlNFBFRXJpdkRxU2hlIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCIsInBlcm1pc3Npb25zIjpbInJlYWQ6ZW1wbG95ZWVzIl19.fYXSVJa4CSPt_UCIXJM9e6MPOD2xyx1KgogCeVVF0Mwo0YD68Qex7iUUU3O60gMGdMrh7x6B73qAakl-tS-gLH_bVVM3PHWf4v_fSSRbju2IIeLEHkTAAMRc6qk8jNzqiB725etGEJlmZDYipU9ryfHl11FnFFjX8kYDW4lBCbKOxdLcmHSZpJppsQ6QU0eFNLCp2_PKUqGx6waofVZ6_IpBS3b4LHfVjQkzsyGdWOFtLIRIoSnciaqkDMpT-FxydWGfp7EeP5eUaBk8n3RvZ22VMNLkkVxZPUDTmFM6wZMhu22kpy1F_h5DmfaKz6A5WYP22mLouecQtw7fYZltjw