Table of Contents
Example 3: Combining RBAC with attribute checks
Hint
Order: superuser → suspension → project roles → workspace roles → deny.
- I used deny-by-default.
- I covered background jobs or non-HTTP flows.
- I included audit logging for sensitive allows/denies.
Practical projects
- Add RBAC middleware to a demo REST API (users, projects, tasks). Include unit tests for common and edge cases.
- Implement project-scoped roles and a role editor seed script.
- Add an audit log service that records who did what, where, and why (decision summary).
- Create a migration to introduce a new permission without breaking existing roles.
Who this is for
- Backend Engineers building multi-user systems.
- Developers adding authorization to existing APIs.
- Engineers preparing for security-conscious teams and audits.
Prerequisites
- Comfort with API design and HTTP status codes.
- Basic database modeling.
- Familiarity with authentication (tokens/sessions), as authz builds on top.
Learning path
- Understand RBAC basics and least privilege.
- Model permissions, roles, and resource scopes.
- Implement a checker with deny-by-default + audits.
- Add caching and cover background processes.
- Test, monitor, and iterate with real usage.
Next steps
- Automate permission tests with fixtures covering resource scopes.
- Introduce just-in-time elevation flows for rare admin tasks.
- Review logs for noisy denies and refine roles safely.
Mini challenge
Your product manager wants "export_all_data" for managers. Propose a safer alternative using existing permissions. Explain why it’s safer and how to instrument audits. Write your answer in 5–7 bullet points.
Reminder: The quick test is open to all learners. Log in if you want your progress saved.