Designing a Role-Based Access Control (RBAC)

I am looking into on how to design, and develop a RBAC system that limits and enforces access to a product base on roles and permissions. This is something I wanted to try for fun because it seems interesting. However, I am unsure how to go from actually designing it. I was thinking on implementing it as a library. Would like some guidance in good approaches that I can look into or try out. Thank you!
Hello! The first approach that comes to my mind is implement a proxy. Have a look at this example:
https://refactoring.guru/design-patterns/proxy/cpp/example#lang-features
Can it be done without the use of proxy or other frameworks/libraries? Say, I was thinking just implementing the system with a Role class, permission class, User class, and a role manager class.
We need more information about the system 😏

Is this some kind of client/server system, where a client connects to a server and wants to perform some operations? If so, first of all, you need to authorize (identify) the user, e.g. by using TLS Client Certificate or by using UserName + Password. Once the user has been authorized successfully, i.e. when your server knows to whom it is talking, you can figure what permissions that user has. So, you have to look up the user's roles from the server's user database. Next, you have to compute the union of all permissions of all roles that the user has. Finally, you can decide whether the user has the required permission to perform the requested operation...

At least for the user database, which you will need, I'd recommend to use an existing library, such as SQLite or MySQL Connector/C.
Last edited on
An example of implementing a system on Windows using Azure or other platforms.

https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-implement-rbac-for-apps

The metasearch I used to find that, this isn't an area of programming I am interested in implementing:

https://duckduckgo.com/?t=ffab&q=role-based+access+control+example&ia=web
Topic archived. No new replies allowed.