Skip to content

Commit eccde9c

Browse files
authored
Add API key settings documentation (#38490) (#38499)
This commit adds missing API key service settings documentation.
1 parent 5b6da65 commit eccde9c

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

docs/reference/settings/security-settings.asciidoc

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,36 @@ method.
147147
The length of time that a token is valid for. By default this value is `20m` or
148148
20 minutes. The maximum value is 1 hour.
149149

150+
[float]
151+
[[api-key-service-settings]]
152+
==== API key service settings
153+
154+
You can set the following API key service settings in
155+
`elasticsearch.yml`.
156+
157+
`xpack.security.authc.api_key.enabled`::
158+
Set to `false` to disable the built-in API key service. Defaults to `true` unless
159+
`xpack.security.http.ssl.enabled` is `false`. This prevents sniffing the API key
160+
from a connection over plain http.
161+
162+
`xpack.security.authc.api_key.hashing.algorithm`::
163+
Specifies the hashing algorithm that is used for securing API key credentials.
164+
See <<password-hashing-algorithms>>. Defaults to `pbkdf2`.
165+
166+
`xpack.security.authc.api_key.cache.ttl`::
167+
The time-to-live for cached API key entries. A API key id and a hash of its
168+
API key are cached for this period of time. Specify the time period using
169+
the standard {es} <<time-units,time units>>. Defaults to `1d`.
170+
171+
`xpack.security.authc.api_key.cache.max_keys`::
172+
The maximum number of API key entries that can live in the
173+
cache at any given time. Defaults to 10,000.
174+
175+
`xpack.security.authc.api_key.cache.hash_algo`:: (Expert Setting)
176+
The hashing algorithm that is used for the
177+
in-memory cached API key credentials. For possible values, see <<cache-hash-algo>>.
178+
Defaults to `ssha256`.
179+
150180
[float]
151181
[[realm-settings]]
152182
==== Realm settings

x-pack/docs/en/rest-api/security/create-api-keys.asciidoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ applicable for the API key in milliseconds.
2424
NOTE: By default API keys never expire. You can specify expiration at the time of
2525
creation for the API keys.
2626

27+
See <<api-key-service-settings>> for configuration settings related to API key service.
28+
2729
==== Request Body
2830

2931
The following parameters can be specified in the body of a POST or PUT request:
@@ -97,3 +99,13 @@ API key information.
9799
<1> unique id for this API key
98100
<2> optional expiration in milliseconds for this API key
99101
<3> generated API key
102+
103+
The API key returned by this API can then be used by sending a request with a
104+
`Authorization` header with a value having the prefix `ApiKey ` followed
105+
by the _credentials_, where _credentials_ is the base64 encoding of `id` and `api_key` joined by a colon.
106+
107+
[source,shell]
108+
--------------------------------------------------
109+
curl -H "Authorization: ApiKey VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==" http://localhost:9200/_cluster/health
110+
--------------------------------------------------
111+
// NOTCONSOLE

x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public class ApiKeyService {
108108
static final String API_KEY_LIMITED_ROLE_DESCRIPTORS_KEY = "_security_api_key_limited_by_role_descriptors";
109109

110110
public static final Setting<String> PASSWORD_HASHING_ALGORITHM = new Setting<>(
111-
"xpack.security.authc.api_key_hashing.algorithm", "pbkdf2", Function.identity(), v -> {
111+
"xpack.security.authc.api_key.hashing.algorithm", "pbkdf2", Function.identity(), v -> {
112112
if (Hasher.getAvailableAlgoStoredHash().contains(v.toLowerCase(Locale.ROOT)) == false) {
113113
throw new IllegalArgumentException("Invalid algorithm: " + v + ". Valid values for password hashing are " +
114114
Hasher.getAvailableAlgoStoredHash().toString());

0 commit comments

Comments
 (0)