change-password.asciidoc 2.4 KB

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