Anderson Henrique Botega’s Post

Permissions don't belong in your route handlers. Most codebases start with a simple if (user.isAdmin) check. Then comes if (user.isAdmin || user.isDoctor). Then the special case for user ID 42. Before long, access control logic is everywhere — and nowhere is authoritative. RBAC — Role-Based Access Control — is one way to bring structure to this with a simple shift: instead of asking "can this user do X?", you ask "does this user's role allow X?". The core rules can live in a centralized, typed model instead of being scattered across the codebase. This article covers the full implementation in TypeScript: → Defining roles and permissions with strict types → Building an authorize() middleware for Express routes → Creating a usePermission() hook for React → How a single file change propagates across your entire stack If your app has more than one type of user, this pattern can help prevent access control logic from becoming scattered and inconsistent. https://lnkd.in/g5-7Grqp #typescript #nodejs #react #security #softwarearchitecture

  • graphical user interface, Teams

Thank you for sharing the article. The part that confuses the most with RBAC is ownership. Role tells you that a doctor can view patient records. It does not tell you which patients. Where do you put that check? In the permission layer or down in the data layer?

Like
Reply

Super useful article, thanks for sharing

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories