user-cache.asciidoc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. [role="xpack"]
  2. [[controlling-user-cache]]
  3. === Controlling the user cache
  4. User credentials are cached in memory on each node to avoid connecting to a
  5. remote authentication service or hitting the disk for every incoming request.
  6. You can configure characteristics of the user cache with the `cache.ttl`,
  7. `cache.max_users`, and `cache.hash_algo` realm settings.
  8. NOTE: PKI realms do not cache user credentials but do cache the resolved user
  9. object to avoid unnecessarily needing to perform role mapping on each request.
  10. The cached user credentials are hashed in memory. By default, {security} uses a
  11. salted `sha-256` hash algorithm. You can use a different hashing algorithm by
  12. setting the `cache.hash_algo` realm settings. See
  13. {ref}/security-settings.html#hashing-settings[User cache and password hash algorithms].
  14. [[cache-eviction-api]]
  15. ==== Evicting users from the cache
  16. {security} exposes a
  17. {ref}/security-api-clear-cache.html[Clear Cache API] you can use
  18. to force the eviction of cached users. For example, the following request evicts
  19. all users from the `ad1` realm:
  20. [source, js]
  21. ------------------------------------------------------------
  22. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1/_clear_cache'
  23. ------------------------------------------------------------
  24. To clear the cache for multiple realms, specify the realms as a comma-separated
  25. list:
  26. [source, js]
  27. ------------------------------------------------------------
  28. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1,ad2/_clear_cache'
  29. ------------------------------------------------------------
  30. You can also evict specific users:
  31. [source, java]
  32. ------------------------------------------------------------
  33. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1/_clear_cache?usernames=rdeniro,alpacino'
  34. ------------------------------------------------------------