@climba03003/fastify-endpoint-rbac
This plugin used to manage the endpoint role-base access control. It will collect
all the specified roles and you can specify how to check the access control globally
or per-route.
Install
npm install @climba03003/fastify-endpoint-rbac --save
yarn add @climba03003/fastify-endpoint-rbac
Usage
import FastifyRBAC from '@climba03003/fastify-endpoint-rbac'
fastify.register(FastifyRBAC, {
retrieveAccountRoles(request, reply) {
return []
},
checkRBAC(routeRoles, accountRoles) {
return true
},
forbiddenMessage: 'No Privilege'
})
fastify.get(
'/',
{
config: {
rbac: {
roles: ['index:read'],
skip: false,
checkRBAC(routeRoles, accountRoles) {
return true
},
}
}
}
)
Decorators
fastify.rbac.routeRBAC
fastify.rbac.roles