liveBook · Manning

Spring Expression Language

As explained in Spring Security in Action, Second Edition

Spring Expression Language is an expression language for querying and manipulating object graphs within Spring applications.

Spring Expression Language (SpEL) lets Spring applications express authorization rules over application objects, reducing repeated security logic while preserving configuration flexibility. section 1.1

Use SpEL with method security to control execution and returned values:

  • Enable method security with @EnableMethodSecurity; method security is disabled by default. section 11.5
  • Apply @PreAuthorize with a SpEL expression to check authorization before a method executes. section 11.5
  • Apply @PostAuthorize with a SpEL expression to decide whether the caller may use a method's returned value. section 11.5
  • Move complex authorization logic into a PermissionEvaluator to keep application code readable. section 11.5

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines preauthorization and postauthorization expressions but does not detail SpEL syntax or evaluation internals.
Examples
Uses @EnableMethodSecurity, @PreAuthorize, and @PostAuthorize as configuration and authorization examples.
What it assumes
Assumes a Spring application and requires developers to understand and use Spring Security properly.
What you can do after
Apply authorization through named Spring Security annotations and delegate complex rules to a PermissionEvaluator.
How it connects
Connects Spring Security with method security, preauthorization, postauthorization, annotations, and PermissionEvaluator.

Also explained in

Compare how 2 books explain Spring Expression Language →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Security in Action, Second Edition. The section links point to the parts of the book it draws on.