We are using Spring Security's ACL Annotations to allow access to certain web services. @PreAuthorize
and @PostAuthorize
seems to be extremely useful and favours most of the use cases we are having. The SPEL based rules on individual methods et al are helping us in fine grain security on the application and its services.
For eg:- We check the owner of a returned object as below
@PreAuthorize("hasRole('ROLE_ADMIN') and returnObject.owner == authentication.name")
public SomeDTO getSomeDTO(){ ... }
This works fine when a single object is returned. What would be the equivalent if a List is returned? How do we loop through a collection and check individual element properties in that collection using SPEL?