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.WrapperNested classes/interfaces inherited from interface org.elasticsearch.rest.RestHandler
org.elasticsearch.rest.RestHandler.Route -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.elasticsearch.license.XPackLicenseStateprotected final org.elasticsearch.common.settings.SettingsFields inherited from class org.elasticsearch.rest.BaseRestHandler
DEFAULT_INCLUDE_TYPE_NAME_POLICY, INCLUDE_TYPE_NAME_PARAMETER, MULTI_ALLOW_EXPLICIT_INDEX -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSecurityBaseRestHandler(org.elasticsearch.common.settings.Settings settings, org.elasticsearch.license.XPackLicenseState licenseState) -
Method Summary
Modifier and TypeMethodDescriptionprotected ExceptioncheckFeatureAvailable(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.RestChannelConsumerinnerPrepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client) Implementers should implement this method as they normally would forBaseRestHandler.prepareRequest(RestRequest, NodeClient)and ensure that all request parameters are consumed prior to returning a value.protected final org.elasticsearch.rest.BaseRestHandler.RestChannelConsumerprepareRequest(org.elasticsearch.rest.RestRequest request, org.elasticsearch.client.internal.node.NodeClient client) Calls theinnerPrepareRequest(RestRequest, NodeClient)method and then checks the license state.Methods inherited from class org.elasticsearch.rest.BaseRestHandler
getName, getUsageCount, handleRequest, mediaTypesValid, responseParams, responseParams, routes, unrecognizedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 settingslicenseState- 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 theinnerPrepareRequest(RestRequest, NodeClient)method and then checks the license state. If the license state allows auth, the result frominnerPrepareRequest(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:
prepareRequestin classorg.elasticsearch.rest.BaseRestHandler- Throws:
IOException
-
checkFeatureAvailable
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:
nullif 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 forBaseRestHandler.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
-