Class ApiKeyService
java.lang.Object
org.elasticsearch.xpack.security.authc.ApiKeyService
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classstatic final classA cached version of theApiKeyService.ApiKeyDoc. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.elasticsearch.common.settings.Setting<String>static final org.elasticsearch.common.settings.Setting<Integer>static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue>static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue>static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue>static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue>static final org.elasticsearch.common.settings.Setting<String> -
Constructor Summary
ConstructorsConstructorDescriptionApiKeyService(org.elasticsearch.common.settings.Settings settings, Clock clock, org.elasticsearch.client.internal.Client client, SecurityIndexManager securityIndex, org.elasticsearch.cluster.service.ClusterService clusterService, CacheInvalidatorRegistry cacheInvalidatorRegistry, org.elasticsearch.threadpool.ThreadPool threadPool) -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateApiKey(org.elasticsearch.xpack.core.security.authc.Authentication authentication, org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyRequest request, Set<org.elasticsearch.xpack.core.security.authz.RoleDescriptor> userRoles, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyResponse> listener) Asynchronously creates a new API key based off of the request and authenticationorg.elasticsearch.xpack.core.security.authc.AuthenticationcreateApiKeyAuthentication(org.elasticsearch.xpack.core.security.authc.AuthenticationResult<org.elasticsearch.xpack.core.security.user.User> authResult, String nodeName) voidgetApiKeyMetadata(org.elasticsearch.xpack.core.security.authc.Authentication authentication) If the authentication has type of api_key, returns the metadata associated to the API key.voidgetApiKeys(String realmName, String username, String apiKeyName, String apiKeyId, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyResponse> listener) Get API key information for given realm, user, API key name and id combinationstatic StringgetCreatorRealmName(org.elasticsearch.xpack.core.security.authc.Authentication authentication) Returns realm name of the owner user of an API key if the effective user is an API Key.static StringgetCreatorRealmType(org.elasticsearch.xpack.core.security.authc.Authentication authentication) Returns realm type of the owner user of an API key if the effective user is an API Key.voidinvalidateApiKeys(String realmName, String username, String apiKeyName, String[] apiKeyIds, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.InvalidateApiKeyResponse> invalidateListener) Invalidate API keys for given realm, user name, API key name and id.List<org.elasticsearch.xpack.core.security.authz.RoleDescriptor>parseRoleDescriptors(String apiKeyId, Map<String, Object> roleDescriptorsMap, org.elasticsearch.xpack.core.security.authz.store.RoleReference.ApiKeyRoleType roleType) List<org.elasticsearch.xpack.core.security.authz.RoleDescriptor>parseRoleDescriptorsBytes(String apiKeyId, org.elasticsearch.common.bytes.BytesReference bytesReference, org.elasticsearch.xpack.core.security.authz.store.RoleReference.ApiKeyRoleType roleType) voidqueryApiKeys(org.elasticsearch.action.search.SearchRequest searchRequest, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.QueryApiKeyResponse> listener) protected voidverifyKeyAgainstHash(String apiKeyHash, ApiKeyService.ApiKeyCredentials credentials, org.elasticsearch.action.ActionListener<Boolean> listener)
-
Field Details
-
PASSWORD_HASHING_ALGORITHM
-
DELETE_TIMEOUT
public static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue> DELETE_TIMEOUT -
DELETE_INTERVAL
public static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue> DELETE_INTERVAL -
CACHE_HASH_ALGO_SETTING
-
CACHE_TTL_SETTING
public static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue> CACHE_TTL_SETTING -
CACHE_MAX_KEYS_SETTING
-
DOC_CACHE_TTL_SETTING
public static final org.elasticsearch.common.settings.Setting<org.elasticsearch.core.TimeValue> DOC_CACHE_TTL_SETTING
-
-
Constructor Details
-
ApiKeyService
public ApiKeyService(org.elasticsearch.common.settings.Settings settings, Clock clock, org.elasticsearch.client.internal.Client client, SecurityIndexManager securityIndex, org.elasticsearch.cluster.service.ClusterService clusterService, CacheInvalidatorRegistry cacheInvalidatorRegistry, org.elasticsearch.threadpool.ThreadPool threadPool)
-
-
Method Details
-
createApiKey
public void createApiKey(org.elasticsearch.xpack.core.security.authc.Authentication authentication, org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyRequest request, Set<org.elasticsearch.xpack.core.security.authz.RoleDescriptor> userRoles, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.CreateApiKeyResponse> listener) Asynchronously creates a new API key based off of the request and authentication- Parameters:
authentication- the authentication that this api key should be based off ofrequest- the request to create the api key included any permission restrictionsuserRoles- the user's actual roles that we always enforcelistener- the listener that will be used to notify of completion
-
createApiKeyAuthentication
public org.elasticsearch.xpack.core.security.authc.Authentication createApiKeyAuthentication(org.elasticsearch.xpack.core.security.authc.AuthenticationResult<org.elasticsearch.xpack.core.security.user.User> authResult, String nodeName) -
parseRoleDescriptors
-
parseRoleDescriptorsBytes
-
verifyKeyAgainstHash
protected void verifyKeyAgainstHash(String apiKeyHash, ApiKeyService.ApiKeyCredentials credentials, org.elasticsearch.action.ActionListener<Boolean> listener) -
ensureEnabled
public void ensureEnabled() -
invalidateApiKeys
public void invalidateApiKeys(String realmName, String username, String apiKeyName, String[] apiKeyIds, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.InvalidateApiKeyResponse> invalidateListener) Invalidate API keys for given realm, user name, API key name and id.- Parameters:
realmName- realm nameusername- user nameapiKeyName- API key nameapiKeyIds- API key idinvalidateListener- listener forInvalidateApiKeyResponse
-
getApiKeys
public void getApiKeys(String realmName, String username, String apiKeyName, String apiKeyId, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.GetApiKeyResponse> listener) Get API key information for given realm, user, API key name and id combination- Parameters:
realmName- realm nameusername- user nameapiKeyName- API key nameapiKeyId- API key idlistener- listener forGetApiKeyResponse
-
queryApiKeys
public void queryApiKeys(org.elasticsearch.action.search.SearchRequest searchRequest, org.elasticsearch.action.ActionListener<org.elasticsearch.xpack.core.security.action.apikey.QueryApiKeyResponse> listener) -
getCreatorRealmName
public static String getCreatorRealmName(org.elasticsearch.xpack.core.security.authc.Authentication authentication) Returns realm name of the owner user of an API key if the effective user is an API Key. If the effective user is not an API key, it just returns the source realm name.- Parameters:
authentication-Authentication- Returns:
- realm name
-
getCreatorRealmType
public static String getCreatorRealmType(org.elasticsearch.xpack.core.security.authc.Authentication authentication) Returns realm type of the owner user of an API key if the effective user is an API Key. If the effective user is not an API key, it just returns the source realm type.- Parameters:
authentication-Authentication- Returns:
- realm type
-
getApiKeyMetadata
public static Map<String,Object> getApiKeyMetadata(org.elasticsearch.xpack.core.security.authc.Authentication authentication) If the authentication has type of api_key, returns the metadata associated to the API key.- Parameters:
authentication-Authentication- Returns:
- A map for the metadata or an empty map if no metadata is found.
-