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.
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