I am trying to authorize apis exposed by Spring Data REST. So far I am able to do role-based authorization i.e:
@RepositoryRestResource(path = "book")
public interface BookRepository extends JpaRepository<Book, Long> {
@PreAuthorize("hasRole('ROLE_ADMIN')")
<S extends Book> Book save(Book book);
}
Also in the same project i have a service layer with ACL mechanism, which is working.
I am unable to use PostFilter expression with Spring Data REST i.e:
@PostFilter("hasPermission(filterObject, 'read') or hasPermission(filterObject, admin)")
List<Book> findAll();
It would be of great help, if anyone using ACL with Spring Data REST.
Note: I am aware of below open issues:
https://github.com/spring-projects/spring-data-rest/issues/619 (formerly DATAREST-236)
https://github.com/spring-projects/spring-security/issues/2629 (formerly SEC-2409)