activate-user-profile.asciidoc 4.4 KB

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