How should I model roles in Prisma?
Prisma
Prisma
What does a permission map look like in code?
Ts
Why is checking on the client or in middleware not enough?
Ts
How do I enforce roles in route handlers, server actions and server components?
Ts
How do I stop a vendor editing someone else's product?
Ts
How do I test the denied paths?
Ts
Common RBAC mistakes
- Trusting a role sent from the client, whether in a hidden form field, a header or a request body. Read the role on the server.
- Checking permissions in the page but forgetting the route handler or server action behind it.
- Forgetting the check in the data layer, so a new page that queries Prisma directly skips the rules.
- Putting secrets or sensitive personal data in the JWT. The payload is readable by the client, and a role stored in it stays stale until the token expires.
- Using one broad "isAdmin" flag for everything, which makes it hard to give someone a smaller set of powers later.
- Returning detailed error messages that reveal whether a resource exists.