syedahnb
syedahnb7mo ago

Can You Provide Guidance on Implementing RBAC and Share GitHub Examples?

I am currently exploring the implementation of Role-Based Access Control (RBAC) and am seeking your guidance. Could you kindly provide insights, examples, or direct me to relevant GitHub repositories showcasing effective RBAC implementation? Your expertise and assistance would be highly appreciated.
8 Replies
DxD
DxD7mo ago
@syedahnb if u find a solution, can you pass it here ?
syedahnb
syedahnb7mo ago
no still looking for help and searching .if I find any clue ,will be share
Nick
Nick7mo ago
At work we have a middleware which is attached to all procedures, and it reads meta off the procedure at runtime to determine the entitlements required to call a procedure. Everything else is your own code We typically create manager and reader base procedures with the meta applied and re-use them throughout a router In terms of data structures for us, a role has many named entitlements, and a user has a role. How you put that together or whether you integrate a 3rd party library or service to handle this is your call
syedahnb
syedahnb7mo ago
could you please provide a code example? I have previous experience working with Laravel. However, I don't fully understand TRPC, so I'm struggling to comprehend how to register in middleware, how to protect routes, and how to handle this in the frontend.
Nick
Nick7mo ago
They’re the same as anywhere, learn how to write a middleware first from the docs, rejecting is as simple as throwing instead of calling next Don’t have an example to hand, but a page in the docs might be a good idea when you figure it out!
syedahnb
syedahnb7mo ago
Thank you @Nick Lucas
LittleLily
LittleLily7mo ago
Can you access metadata like the name of a procedure inside a middleware?
Nick
Nick7mo ago
I believe that must be possible and is probably in opts to begin with, but I’m AFK right now Have an explore 🙂