advancedMethod-Level Security

How do @PreAuthorize expressions access the current user and method arguments?

SpEL expressions in @PreAuthorize/@PostAuthorize have access to 'authentication' (the current Authentication object, e.g., authentication.name or authentication.principal) and to method parameters directly by name (e.g., #loanId for a parameter named loanId), as well as 'returnObject' in @PostAuthorize specifically for the method's return value.

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Spring Ecosystem Mastery library.

How do @PreAuthorize expressions access the current user and method arguments?

Next Step

Continue to Why would a team use BOTH URL-level (requestMatchers) and method-level (@PreAuthorize) security together rather than just one?← Back to all Spring Security questions