intermediateAuthorization & Role-Based Access Control

Why does `@PreAuthorize` on a method sometimes get silently ignored?

Method security only applies through Spring's proxy mechanism, so a `@PreAuthorize`-annotated method called from another method in the SAME class bypasses the proxy entirely (it's a plain Java method call, not going through the bean), and the check never fires. The call has to come from a different bean — through the proxy — for the annotation to take effect.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Why use a short-lived access token plus a separate long-lived refresh token instead of one long-lived token?← Back to all Spring Boot questions