activate-user-profile.asciidoc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [role="xpack"]
  2. [[security-api-activate-user-profile]]
  3. === Activate user profile API
  4. ++++
  5. <titleabbrev>Activate user profile</titleabbrev>
  6. ++++
  7. NOTE: The user profile feature is designed only for use by {kib} and
  8. Elastic’s {observability}, {ents}, and {elastic-sec} solutions. Individual
  9. users and external applications should not call this API directly. Elastic reserves
  10. the right to change or remove this feature in future releases without prior notice.
  11. Creates or updates a user profile on behalf of another user.
  12. [[security-api-activate-user-profile-request]]
  13. ==== {api-request-title}
  14. `POST /_security/profile/_activate`
  15. [[security-api-activate-user-profile-prereqs]]
  16. ==== {api-prereq-title}
  17. * To use this API, you must have the `manage_user_profile` cluster privilege.
  18. [[security-api-activate-user-profile-desc]]
  19. ==== {api-description-title}
  20. The activate user profile API creates or updates a profile document for end
  21. users with information that is extracted from the user's authentication object,
  22. including `username`, `full_name`, `roles`, and the authentication realm.
  23. When updating a profile document, the API enables the document if it was
  24. disabled. Any updates do not change existing content for either the `labels` or
  25. `data` fields.
  26. This API is intended only for use by applications (such as {kib}) that need to
  27. create or update profiles for end users.
  28. IMPORTANT: The calling application must have either an `access_token`, or a
  29. combination of `username` and `password` for the user that the profile document
  30. is intended for.
  31. [role="child_attributes"]
  32. [[security-api-activate-user-profile-request-body]]
  33. ==== {api-request-body-title}
  34. `access_token`::
  35. (Required*, string)
  36. The user's access token. If you specify the `access_token` grant type, this
  37. parameter is required. It is not valid with other grant types.
  38. `grant_type`::
  39. (Required, string)
  40. The type of grant.
  41. +
  42. .Valid values for `grant_type`
  43. [%collapsible%open]
  44. ====
  45. `access_token`::
  46. (Required*, string)
  47. In this type of grant, you must supply an access token that was created by the
  48. {es} token service. For more information, see
  49. <<security-api-get-token>> and <<token-service-settings>>.
  50. `password`::
  51. (Required*, string)
  52. In this type of grant, you must supply the `username` and `password` for the
  53. user that you want to create the API key for.
  54. ====
  55. `password`::
  56. (Optional*, string)
  57. The user's password. If you specify the `password` grant type, this parameter is
  58. required. It is not valid with other grant types.
  59. `username`::
  60. (Optional*, string)
  61. The username that identifies the user. If you specify the `password` grant type,
  62. this parameter is required. It is not valid with other grant types.
  63. *Indicates that the setting is required in some, but not all situations.
  64. [[security-api-activate-user-profile-response-body]]
  65. ==== {api-response-body-title}
  66. A successful activate user profile API call returns a JSON structure that contains
  67. the profile unique ID, user information, timestamp for the operation and version
  68. control numbers.
  69. [[security-api-activate-user-profile-example]]
  70. ==== {api-examples-title}
  71. [source,console]
  72. ----
  73. POST /_security/profile/_activate
  74. {
  75. "grant_type": "password",
  76. "username" : "jacknich",
  77. "password" : "l0ng-r4nd0m-p@ssw0rd"
  78. }
  79. ----
  80. // TEST[setup:jacknich_user]
  81. The API returns the following response:
  82. [source,console-result]
  83. ----
  84. {
  85. "uid": "u_79HkWkwmnBH5gqFKwoxggWPjEBOur1zLPXQPEl1VBW0_0",
  86. "enabled": true,
  87. "last_synchronized": 1642650651037,
  88. "user": {
  89. "username": "jacknich",
  90. "roles": [
  91. "admin", "other_role1"
  92. ],
  93. "realm_name": "native",
  94. "full_name": "Jack Nicholson",
  95. "email": "jacknich@example.com"
  96. },
  97. "labels": {},
  98. "data": {},
  99. "_doc": {
  100. "_primary_term": 88,
  101. "_seq_no": 66
  102. }
  103. }
  104. ----
  105. // TESTRESPONSE[s/1642650651037/$body.last_synchronized/]
  106. // TESTRESPONSE[s/88/$body._doc._primary_term/]
  107. // TESTRESPONSE[s/66/$body._doc._seq_no/]