OpenSearch/docs/java-rest/high-level
Yogesh Gaikwad fe36861ada
Add support for API keys to access Elasticsearch (#38291)
X-Pack security supports built-in authentication service
`token-service` that allows access tokens to be used to 
access Elasticsearch without using Basic authentication.
The tokens are generated by `token-service` based on
OAuth2 spec. The access token is a short-lived token
(defaults to 20m) and refresh token with a lifetime of 24 hours,
making them unsuitable for long-lived or recurring tasks where
the system might go offline thereby failing refresh of tokens.

This commit introduces a built-in authentication service
`api-key-service` that adds support for long-lived tokens aka API
keys to access Elasticsearch. The `api-key-service` is consulted
after `token-service` in the authentication chain. By default,
if TLS is enabled then `api-key-service` is also enabled.
The service can be disabled using the configuration setting.

The API keys:-
- by default do not have an expiration but expiration can be
  configured where the API keys need to be expired after a
  certain amount of time.
- when generated will keep authentication information of the user that
   generated them.
- can be defined with a role describing the privileges for accessing
   Elasticsearch and will be limited by the role of the user that
   generated them
- can be invalidated via invalidation API
- information can be retrieved via a get API
- that have been expired or invalidated will be retained for 1 week
  before being deleted. The expired API keys remover task handles this.

Following are the API key management APIs:-
1. Create API Key - `PUT/POST /_security/api_key`
2. Get API key(s) - `GET /_security/api_key`
3. Invalidate API Key(s) `DELETE /_security/api_key`

The API keys can be used to access Elasticsearch using `Authorization`
header, where the auth scheme is `ApiKey` and the credentials, is the 
base64 encoding of API key Id and API key separated by a colon.
Example:-
```
curl -H "Authorization: ApiKey YXBpLWtleS1pZDphcGkta2V5" http://localhost:9200/_cluster/health
```

Closes #34383
2019-02-05 14:21:57 +11:00
..
ccr Use `CcrRepository` to init follower index (#35719) 2019-01-29 11:47:29 -07:00
cluster Docs: Cut down on high level rest client copy-and-paste-ness (#34125) 2018-09-28 14:48:11 -04:00
document Type removal - added deprecation warnings to _bulk apis (#36549) 2019-01-10 21:35:19 +00:00
graph HLRC GraphClient and associated tests (#32366) 2018-08-21 13:29:18 +01:00
ilm [DOCS] fix HLRC ILM doc misreferenced tag 2018-11-27 14:28:25 -08:00
indices Deprecate types in rollover index API (#38039) 2019-02-04 16:07:45 -05:00
ingest REST high-level client: add simulate pipeline API (#31158) 2018-06-22 09:59:04 +02:00
licensing HLRC: add support for get license basic/trial status API (#33176) 2018-11-13 15:52:59 +01:00
migration Adding ml_settings entry to HLRC and Docs for deprecation_info (#38118) 2019-02-01 12:45:28 -06:00
miscellaneous [Docs] Remove repeating words (#33087) 2018-08-28 13:16:43 +02:00
ml ML: Add upgrade mode docs, hlrc, and fix bug (#37942) 2019-01-30 06:51:11 -06:00
rollup HLRC: Add rollup search (#36334) 2018-12-07 14:39:58 -05:00
script HLRC: Add put stored script support to high-level rest client (#31323) 2018-09-09 13:47:47 +02:00
search Update the scroll example in the docs (#37394) 2019-01-14 13:03:00 +01:00
security Add support for API keys to access Elasticsearch (#38291) 2019-02-05 14:21:57 +11:00
snapshot Add Restore Snapshot High Level REST API 2018-07-24 16:17:09 +02:00
tasks high level REST api: cancel task (#30745) 2018-06-07 14:02:23 -07:00
watcher [DOCS] Various spelling corrections (#37046) 2019-01-07 14:44:12 +01:00
aggs-builders.asciidoc [DOCS] Update APIs grouping and ordering in REST high-level Client docs (#28497) 2018-02-02 17:19:50 +01:00
execution-no-req.asciidoc HLRC: Implement get-user-privileges API (#36292) 2018-12-12 15:12:49 +11:00
execution.asciidoc Add javadocs about expected exceptions to RestHighLevelClient (#36216) 2018-12-05 00:31:52 +01:00
getting-started.asciidoc Update Lucene repo for 7.0.0-alpha2 (#37985) 2019-01-31 09:17:02 +01:00
index.asciidoc Docs: HLRC: refactor bulk, migrate and reindex apis (#35413) 2018-11-16 08:58:13 +01:00
java-builders.asciidoc Docs: Cut down on high level rest client copy-and-paste-ness (#34125) 2018-09-28 14:48:11 -04:00
migration.asciidoc Deprecate types in index API (#36575) 2018-12-18 08:53:49 -05:00
query-builders.asciidoc added docs for `wrapper` query. 2018-03-14 11:51:22 +01:00
supported-apis.asciidoc Add support for API keys to access Elasticsearch (#38291) 2019-02-05 14:21:57 +11:00