user-cache.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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` setting to any of the following:
  13. [[cache-hash-algo]]
  14. .Cache hash algorithms
  15. |=======================
  16. | Algorithm | | | Description
  17. | `ssha256` | | | Uses a salted `sha-256` algorithm (default).
  18. | `md5` | | | Uses `MD5` algorithm.
  19. | `sha1` | | | Uses `SHA1` algorithm.
  20. | `bcrypt` | | | Uses `bcrypt` algorithm with salt generated in 1024 rounds.
  21. | `bcrypt4` | | | Uses `bcrypt` algorithm with salt generated in 16 rounds.
  22. | `bcrypt5` | | | Uses `bcrypt` algorithm with salt generated in 32 rounds.
  23. | `bcrypt6` | | | Uses `bcrypt` algorithm with salt generated in 64 rounds.
  24. | `bcrypt7` | | | Uses `bcrypt` algorithm with salt generated in 128 rounds.
  25. | `bcrypt8` | | | Uses `bcrypt` algorithm with salt generated in 256 rounds.
  26. | `bcrypt9` | | | Uses `bcrypt` algorithm with salt generated in 512 rounds.
  27. | `noop`,`clear_text` | | | Doesn't hash the credentials and keeps it in clear text in
  28. memory. CAUTION: keeping clear text is considered insecure
  29. and can be compromised at the OS level (for example through
  30. memory dumps and using `ptrace`).
  31. |=======================
  32. [[cache-eviction-api]]
  33. ==== Evicting users from the cache
  34. {security} exposes a
  35. {ref}/security-api-clear-cache.html[Clear Cache API] you can use
  36. to force the eviction of cached users. For example, the following request evicts
  37. all users from the `ad1` realm:
  38. [source, js]
  39. ------------------------------------------------------------
  40. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1/_clear_cache'
  41. ------------------------------------------------------------
  42. To clear the cache for multiple realms, specify the realms as a comma-separated
  43. list:
  44. [source, js]
  45. ------------------------------------------------------------
  46. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1,ad2/_clear_cache'
  47. ------------------------------------------------------------
  48. You can also evict specific users:
  49. [source, java]
  50. ------------------------------------------------------------
  51. $ curl -XPOST 'http://localhost:9200/_xpack/security/realm/ad1/_clear_cache?usernames=rdeniro,alpacino'
  52. ------------------------------------------------------------