Skip to main content
InterviewHubPRO
Section Overview
Q28

Question 28 of 50

Part 3: Microservices, Distributed Systems & Observability (25 - 35)

56%
Spring Boot & Microservices (50 Qs)•Part 3: Microservices, Distributed Systems & Observability (25 - 35)

How does Method-Level Security (`@PreAuthorize`) work?

senior LevelSecurity & AuthSystem DesignMicroservices

In Simple Words: @PreAuthorize uses Spring Expression Language (SpEL) to evaluate permissions before a method executes:

  • @PreAuthorize("hasRole('ADMIN')")
  • @PreAuthorize("#userId == authentication.principal.id or hasRole('MANAGER')") Enabled via @EnableMethodSecurity.