syedahnb
syedahnb13mo 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/>
<DxD/>13mo ago
@syedahnb if u find a solution, can you pass it here ?
syedahnb
syedahnbOP13mo ago
no still looking for help and searching .if I find any clue ,will be share
Nick
Nick13mo 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
syedahnbOP13mo 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
Nick13mo 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
syedahnbOP13mo ago
Thank you @Nick Lucas
LittleLily
LittleLily13mo ago
Can you access metadata like the name of a procedure inside a middleware?
Nick
Nick13mo ago
I believe that must be possible and is probably in opts to begin with, but I’m AFK right now Have an explore 🙂