Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 43
Role-Based Access Control
RBAC = permissions tied to roles, roles tied to users.
Course progress0%
Focus
3 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
RBAC = permissions tied to roles, roles tied to users. USER reads their data; ADMIN manages everyone; AUDITOR reads but never writes.
Informative example
bash
# usersid email ...1 ana@acme.com2 bob@acme.com# rolesid name1 USER2 ADMIN# user_roles (many-to-many)user_id role_id1 12 12 2// Endpoint@PreAuthorize("hasRole('ADMIN')")@DeleteMapping("/{id}") public void delete(@PathVariable Long id) { ... }
Best practices
- Store roles in their own table — never as a CSV column.
- Prefix authorities with
ROLE_; Spring strips it forhasRole(...). - For fine-grained needs (per-resource), graduate to ABAC / policies.
Ready to mark this lesson complete?Track your journey across the entire course.