change-password.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [role="xpack"]
  2. [[security-api-change-password]]
  3. === Change passwords API
  4. ++++
  5. <titleabbrev>Change passwords</titleabbrev>
  6. ++++
  7. Changes the passwords of users in the native realm and built-in users.
  8. [[security-api-change-password-request]]
  9. ==== {api-request-title}
  10. `POST /_security/user/_password` +
  11. `POST /_security/user/<username>/_password`
  12. [[security-api-change-password-prereqs]]
  13. ==== {api-prereq-title}
  14. * Every user can change their own password. Users with the `manage_security`
  15. privilege can change passwords of other users.
  16. [[security-api-change-password-desc]]
  17. ==== {api-description-title}
  18. You can use the <<security-api-put-user,create user API>> to update everything
  19. but a user's `username` and `password`. This API changes a user's password.
  20. For more information about the native realm, see
  21. <<realms>> and <<native-realm>>.
  22. [[security-api-change-password-path-params]]
  23. ==== {api-path-parms-title}
  24. `username`::
  25. (Optional, string) The user whose password you want to change. If you do not specify
  26. this parameter, the password is changed for the current user.
  27. [[security-api-change-password-request-body]]
  28. ==== {api-request-body-title}
  29. `password` ::
  30. (string) The new password value. Passwords must be at least 6 characters long.
  31. +
  32. One of `password` or `password_hash` is required.
  33. `password_hash` ::
  34. (string) A _hash_ of the new password value. This must be produced using the
  35. same hashing algorithm as has been configured for password storage. For more
  36. details, see the explanation of the
  37. `xpack.security.authc.password_hashing.algorithm` setting in
  38. <<hashing-settings>>.
  39. +
  40. Using this parameter allows the client to pre-hash the password for
  41. performance and/or confidentiality reasons.
  42. +
  43. The `password` parameter and the `password_hash` parameter cannot be
  44. used in the same request.
  45. [[security-api-change-password-example]]
  46. ==== {api-examples-title}
  47. The following example updates the password for the `jacknich` user:
  48. [source,console]
  49. --------------------------------------------------
  50. POST /_security/user/jacknich/_password
  51. {
  52. "password" : "new-test-password"
  53. }
  54. --------------------------------------------------
  55. // TEST[setup:jacknich_user]
  56. A successful call returns an empty JSON structure.
  57. [source,console-result]
  58. --------------------------------------------------
  59. {}
  60. --------------------------------------------------