anchor.diff:  }
   ----
   
  +.Kotlin
  +[source,kotlin,role="secondary"]
  +----
  +@Repository
  +interface MessageRepository : PagingAndSortingRepository<Message,Long> {
  +	@Query("select m from Message m where m.to.id = ?#{ principal?.id }")
  +	fun findInbox(pageable: Pageable): Page<Message>
  +}
  +----
  +====
  +
   This checks to see if the `Authentication.getPrincipal().getId()` is equal to the recipient of the `Message`.
   Note that this example assumes you have customized the principal to be an Object that has an id property.
   By exposing the `SecurityEvaluationContextExtension` bean, all of the xref:servlet/authorization/expression-based.adoc#common-expressions[Common Security Expressions] are available within the Query.
  
positive.code: Now Spring Security can be used within your queries.
  For example:
  
  [source,java]
  ----
  @Repository
  public interface MessageRepository extends PagingAndSortingRepository<Message,Long> {
  
negative.code: [[data-configuration]]
  == Spring Data & Spring Security Configuration
  
  To use this support, add `org.springframework.security:spring-security-data` dependency and provide a bean of type `SecurityEvaluationContextExtension`:
  
  ====
  .Java
  [source,java,role="primary"]
  ----
  @Bean
  public SecurityEvaluationContextExtension securityEvaluationContextExtension() {
  	return new SecurityEvaluationContextExtension();
  }
  ----
  
  .Kotlin
  [source,kotlin,role="secondary"]
  ----
  @Bean
  fun securityEvaluationContextExtension(): SecurityEvaluationContextExtension {
  	return SecurityEvaluationContextExtension()
  }
  ----
  ====
  
  In XML Configuration, this would look like:
  
  