Class SecurityBaseRestHandler

java.lang.Object
org.elasticsearch.rest.BaseRestHandler
org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler
All Implemented Interfaces:
org.elasticsearch.rest.RestHandler
Direct Known Subclasses:
EnrollmentBaseRestHandler, OpenIdConnectBaseRestHandler, RestActivateProfileAction, RestAuthenticateAction, RestChangePasswordAction, RestClearApiKeyCacheAction, RestClearPrivilegesCacheAction, RestClearRealmCacheAction, RestClearRolesCacheAction, RestClearServiceAccountTokenStoreCacheAction, RestCreateApiKeyAction, RestCreateServiceAccountTokenAction, RestDelegatePkiAuthenticationAction, RestDeletePrivilegesAction, RestDeleteRoleAction, RestDeleteRoleMappingAction, RestDeleteServiceAccountTokenAction, RestDeleteUserAction, RestGetApiKeyAction, RestGetBuiltinPrivilegesAction, RestGetPrivilegesAction, RestGetProfileAction, RestGetRoleMappingsAction, RestGetRolesAction, RestGetServiceAccountAction, RestGetServiceAccountCredentialsAction, RestGetTokenAction, RestGetUserPrivilegesAction, RestGetUsersAction, RestGrantApiKeyAction, RestHasPrivilegesAction, RestInvalidateApiKeyAction, RestInvalidateTokenAction, RestPutPrivilegesAction, RestPutRoleAction, RestPutRoleMappingAction, RestPutUserAction, RestQueryApiKeyAction, RestSetEnabledAction, RestUpdateProfileDataAction, SamlBaseRestHandler

public abstract class SecurityBaseRestHandler extends org.elasticsearch.rest.BaseRestHandler
Base class for security rest handlers. This handler takes care of ensuring that the license level is valid so that security can be used!
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.elasticsearch.rest.BaseRestHandler

    org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer, org.elasticsearch.rest.BaseRestHandler.Wrapper

    Nested classes/interfaces inherited from interface org.elasticsearch.rest.RestHandler

    org.elasticsearch.rest.RestHandler.Route
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final org.elasticsearch.license.XPackLicenseState
     
    protected final org.elasticsearch.common.settings.Settings
     

    Fields inherited from class org.elasticsearch.rest.BaseRestHandler

    DEFAULT_INCLUDE_TYPE_NAME_POLICY, INCLUDE_TYPE_NAME_PARAMETER, MULTI_ALLOW_EXPLICIT_INDEX
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    SecurityBaseRestHandler(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.license.XPackLicenseState licenseState)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected Exception
    checkFeatureAvailable(org.elasticsearch.rest.RestRequest request)
    Check whether the given request is allowed within the current license state and setup, and return the name of any unlicensed feature.
    protected abstract org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
    innerPrepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client)
    Implementers should implement this method as they normally would for BaseRestHandler.prepareRequest(RestRequest, NodeClient) and ensure that all request parameters are consumed prior to returning a value.
    protected final org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer
    prepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client)
    Calls the innerPrepareRequest(RestRequest, NodeClient) method and then checks the license state.

    Methods inherited from class org.elasticsearch.rest.BaseRestHandler

    getName, getUsageCount, handleRequest, mediaTypesValid, responseParams, responseParams, routes, unrecognized

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface org.elasticsearch.rest.RestHandler

    allowsUnsafeBuffers, allowSystemIndexAccessByDefault, canTripCircuitBreaker, supportsContentStream
  • Field Details

    • settings

      protected final org.elasticsearch.common.settings.Settings settings
    • licenseState

      protected final org.elasticsearch.license.XPackLicenseState licenseState
  • Constructor Details

    • SecurityBaseRestHandler

      protected SecurityBaseRestHandler(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.license.XPackLicenseState licenseState)
      Parameters:
      settings - the node's settings
      licenseState - the license state that will be used to determine if security is licensed
  • Method Details

    • prepareRequest

      protected final org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer prepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client) throws IOException
      Calls the innerPrepareRequest(RestRequest, NodeClient) method and then checks the license state. If the license state allows auth, the result from innerPrepareRequest(RestRequest, NodeClient) is returned, otherwise a default error response will be returned indicating that security is not licensed. Note: the implementing rest handler is called before the license is checked so that we do not trip the unused parameters check
      Specified by:
      prepareRequest in class org.elasticsearch.rest.BaseRestHandler
      Throws:
      IOException
    • checkFeatureAvailable

      protected Exception checkFeatureAvailable(org.elasticsearch.rest.RestRequest request)
      Check whether the given request is allowed within the current license state and setup, and return the name of any unlicensed feature. By default this returns an exception if security is not enabled. Sub-classes can override this method if they have additional requirements.
      Returns:
      null if all required features are available, otherwise an exception to be sent to the requestor
    • innerPrepareRequest

      protected abstract org.elasticsearch.rest.BaseRestHandler.RestChannelConsumer innerPrepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client) throws IOException
      Implementers should implement this method as they normally would for BaseRestHandler.prepareRequest(RestRequest, NodeClient) and ensure that all request parameters are consumed prior to returning a value. The returned value is not guaranteed to be executed unless security is licensed and all request parameters are known
      Throws:
      IOException