Concept
@PreAuthorize on a service method checks a rule, such as a role or ownership, before it runs. It protects the operation wherever it is called from, not only through one controller path.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Method security doing its job.
@Configuration
@EnableMethodSecurity
class MethodSecurityConfig {}
@Service
public class ReportService {
@PreAuthorize("hasRole('ADMIN')")
public Report exportAll() { ... }
@PreAuthorize("#ownerId == authentication.name")
public Report forOwner(String ownerId) { ... }
}Relying only on URL rules while the same service is reachable from another endpoint, a scheduled job or a message listener. Authorise the operation, not just the path.
Your roadmap puts these before Method security, unless you already know them.
Once a session shows you understand Method security, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.