I need to implement RBAC in a project I'm working on, and I'm fairly new to the concept. I am trying to figure out the best way to implement it.
The most common approach seems to be to create roles and permissions and link them together through the code, I have explored a couple of libraries to do it such as CASL and accesscontrol. But it seems to me that it lacks the ability to quickly add and remove permissions and roles.
The second approach is to add tables in the database and check with each request the permissions a given user has before authorisation. This seems like a waste, as for each request there's an extra call to the database. Or maybe I could store the permissions in the headers, but this approach would expose the permissions to the client.
What is the most suitable approach?