Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 542 Bytes

File metadata and controls

18 lines (13 loc) · 542 Bytes

Spring Data MongoDB - Spring Security integration.

This project contains samples of the Spring Security integration in Spring Data (MongoDB).

Support for SpEL expression based filtering

public interface PersonRepository extends CrudRepository<Person, String> {

  @Override
  List<Person> findAll();

  // Custom query method with filtering based on Spring Security context information
  @Query("{id: ?#{ hasRole('ROLE_ADMIN') ? {$exists:true} : principal.id}}")
  List<Person> findAllForCurrentUserById();
}