access-control-patterns
Installation
SKILL.md
Access Control Patterns
Prevent users from accessing data or actions they are not allowed to access. Broken Access Control is OWASP A01 because it is the most common serious web vulnerability: user A can read user B's invoice, change another tenant's settings, or call an admin endpoint by guessing an ID.
The Rule
Authentication proves who the user is. Authorization proves what the user can do. You need both on every protected operation.
Core Principles
- Deny by default -- no route is public unless explicitly marked public
- Check authorization server-side -- never trust hidden buttons or client checks
- Scope every query by user or tenant -- never fetch by raw ID alone
- Use centralized policies -- avoid scattered
if (user.role === 'admin')checks - Separate roles from permissions -- roles are bundles, permissions are actions
- Audit sensitive decisions -- log denied and privileged actions