2018-05-14 18:35:02 -04:00
|
|
|
[role="xpack"]
|
2017-04-06 21:29:29 -04:00
|
|
|
[[controlling-user-cache]]
|
2018-05-14 18:35:02 -04:00
|
|
|
=== Controlling the user cache
|
2017-04-06 21:29:29 -04:00
|
|
|
|
|
|
|
User credentials are cached in memory on each node to avoid connecting to a
|
|
|
|
remote authentication service or hitting the disk for every incoming request.
|
|
|
|
You can configure characteristics of the user cache with the `cache.ttl`,
|
|
|
|
`cache.max_users`, and `cache.hash_algo` realm settings.
|
|
|
|
|
2018-04-20 11:53:47 -04:00
|
|
|
NOTE: PKI realms do not cache user credentials but do cache the resolved user
|
|
|
|
object to avoid unnecessarily needing to perform role mapping on each request.
|
2017-04-06 21:29:29 -04:00
|
|
|
|
2018-12-19 17:53:37 -05:00
|
|
|
The cached user credentials are hashed in memory. By default, the {es}
|
|
|
|
{security-features} use a salted `sha-256` hash algorithm. You can use a
|
|
|
|
different hashing algorithm by setting the `cache.hash_algo` realm settings. See
|
2018-08-21 05:05:42 -04:00
|
|
|
{ref}/security-settings.html#hashing-settings[User cache and password hash algorithms].
|
2017-04-06 21:29:29 -04:00
|
|
|
|
|
|
|
[[cache-eviction-api]]
|
2018-05-14 18:35:02 -04:00
|
|
|
==== Evicting users from the cache
|
2017-04-06 21:29:29 -04:00
|
|
|
|
2018-12-19 17:53:37 -05:00
|
|
|
You can use the {ref}/security-api-clear-cache.html[clear cache API] to force
|
|
|
|
the eviction of cached users . For example, the following request evicts all
|
|
|
|
users from the `ad1` realm:
|
2017-04-06 21:29:29 -04:00
|
|
|
|
|
|
|
[source, js]
|
|
|
|
------------------------------------------------------------
|
2018-12-11 04:13:10 -05:00
|
|
|
$ curl -XPOST 'http://localhost:9200/_security/realm/ad1/_clear_cache'
|
2017-04-06 21:29:29 -04:00
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
|
|
To clear the cache for multiple realms, specify the realms as a comma-separated
|
|
|
|
list:
|
|
|
|
|
|
|
|
[source, js]
|
|
|
|
------------------------------------------------------------
|
2018-12-11 04:13:10 -05:00
|
|
|
$ curl -XPOST 'http://localhost:9200/_security/realm/ad1,ad2/_clear_cache'
|
2017-04-06 21:29:29 -04:00
|
|
|
------------------------------------------------------------
|
|
|
|
|
|
|
|
You can also evict specific users:
|
|
|
|
|
|
|
|
[source, java]
|
|
|
|
------------------------------------------------------------
|
2018-12-11 04:13:10 -05:00
|
|
|
$ curl -XPOST 'http://localhost:9200/_security/realm/ad1/_clear_cache?usernames=rdeniro,alpacino'
|
2017-04-06 21:29:29 -04:00
|
|
|
------------------------------------------------------------
|