============================================================================== Demo 2 -- self-invocation: the annotation is there, the check is not ============================================================================== SLF4J(W): No SLF4J providers were found. SLF4J(W): Defaulting to no-operation (NOP) logger implementation SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details. alice has ROLE_USER only. adminReport() requires ROLE_ADMIN. ------------------------------------------------------------ reports.adminReport() (via proxy) DENIED -> AuthorizationDeniedException: Access Denied reports.userEntryPoint() (this.adminReport()) ALLOWED -> TOP SECRET REVENUE NUMBERS Is the annotation actually there? (reflection on the target class) ------------------------------------------------------------------ ReportService.adminReport() @PreAuthorize -> @org.springframework.security.access.prepost.PreAuthorize("hasRole('ADMIN')") bean is an AOP proxy -> true proxy class -> com.ankurm.methodsec.Demo2SelfInvocation$ReportService$$SpringCGLIB$$0 target class -> com.ankurm.methodsec.Demo2SelfInvocation$ReportService The annotation is present, the bean IS proxied, and the call was still not checked. The proxy only sees calls that arrive from outside. Three ways to make the inner call go through the proxy ------------------------------------------------------ self-injection (ObjectProvider) DENIED -> AuthorizationDeniedException: Access Denied AopContext.currentProxy() DENIED -> AuthorizationDeniedException: Access Denied call a different bean (collaborator) DENIED -> AuthorizationDeniedException: Access Denied