Performance: @PreAuthorize annotation
MEDIUM IMPACT
This affects server-side request authorization speed and response time, impacting how quickly secured endpoints respond.
@PreAuthorize("hasAnyRole('ADMIN', 'USER', 'MANAGER', 'SUPERVISOR')")
public ResponseEntity<?> getData() { ... }@PreAuthorize("hasRole('ADMIN') or hasRole('USER') or hasRole('MANAGER') or hasRole('SUPERVISOR')")
public ResponseEntity<?> getData() { ... }| Pattern | Authorization Checks | CPU Usage | Response Latency | Verdict |
|---|---|---|---|---|
| Multiple OR conditions in @PreAuthorize | Multiple per request | High | Increased | [X] Bad |
| Using hasAnyRole in @PreAuthorize | Single per request | Low | Reduced | [OK] Good |