Class SecuritySearchOperationListener

java.lang.Object
org.elasticsearch.xpack.security.authz.SecuritySearchOperationListener
All Implemented Interfaces:
org.elasticsearch.index.shard.SearchOperationListener

public final class SecuritySearchOperationListener extends Object implements org.elasticsearch.index.shard.SearchOperationListener
A SearchOperationListener that is used to provide authorization for scroll requests.

In order to identify the user associated with a scroll request, we replace the ReaderContext on creation with a custom implementation that holds the Authentication object. When this context is accessed again in SearchOperationListener.onPreQueryPhase(SearchContext) the ScrollContext is inspected for the authentication, which is compared to the currently authentication.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.elasticsearch.index.shard.SearchOperationListener

    org.elasticsearch.index.shard.SearchOperationListener.CompositeListener
  • Constructor Summary

    Constructors
    Constructor
    Description
    SecuritySearchOperationListener(org.elasticsearch.xpack.core.security.SecurityContext securityContext, AuditTrailService auditTrail)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onNewScrollContext(org.elasticsearch.search.internal.ReaderContext readerContext)
    Adds the Authentication to the ScrollContext
    void
    onPreFetchPhase(org.elasticsearch.search.internal.SearchContext searchContext)
     
    void
    onPreQueryPhase(org.elasticsearch.search.internal.SearchContext searchContext)
     
    void
    validateReaderContext(org.elasticsearch.search.internal.ReaderContext readerContext, org.elasticsearch.transport.TransportRequest request)
    Checks for the ReaderContext if it exists and compares the Authentication object from the scroll context with the current authentication context

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.elasticsearch.index.shard.SearchOperationListener

    onFailedFetchPhase, onFailedQueryPhase, onFetchPhase, onFreeReaderContext, onFreeScrollContext, onNewReaderContext, onQueryPhase
  • Constructor Details

    • SecuritySearchOperationListener

      public SecuritySearchOperationListener(org.elasticsearch.xpack.core.security.SecurityContext securityContext, AuditTrailService auditTrail)
  • Method Details

    • onNewScrollContext

      public void onNewScrollContext(org.elasticsearch.search.internal.ReaderContext readerContext)
      Adds the Authentication to the ScrollContext
      Specified by:
      onNewScrollContext in interface org.elasticsearch.index.shard.SearchOperationListener
    • validateReaderContext

      public void validateReaderContext(org.elasticsearch.search.internal.ReaderContext readerContext, org.elasticsearch.transport.TransportRequest request)
      Checks for the ReaderContext if it exists and compares the Authentication object from the scroll context with the current authentication context
      Specified by:
      validateReaderContext in interface org.elasticsearch.index.shard.SearchOperationListener
    • onPreFetchPhase

      public void onPreFetchPhase(org.elasticsearch.search.internal.SearchContext searchContext)
      Specified by:
      onPreFetchPhase in interface org.elasticsearch.index.shard.SearchOperationListener
    • onPreQueryPhase

      public void onPreQueryPhase(org.elasticsearch.search.internal.SearchContext searchContext)
      Specified by:
      onPreQueryPhase in interface org.elasticsearch.index.shard.SearchOperationListener