|
@@ -1,10 +1,172 @@
|
|
|
[role="xpack"]
|
|
|
[[security-api-update-user-profile-data]]
|
|
|
-=== Activate user profile data API
|
|
|
+=== Update user profile data API
|
|
|
+
|
|
|
+beta::[]
|
|
|
+
|
|
|
++++
|
|
|
<titleabbrev>Update user profile data</titleabbrev>
|
|
|
++++
|
|
|
|
|
|
-Update application specific data for the user profile of the given unique ID.
|
|
|
+Updates specific data for the user profile that's associated with the specified
|
|
|
+unique ID.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-request]]
|
|
|
+==== {api-request-title}
|
|
|
+
|
|
|
+`POST /_security/profile/_data/<uid>`
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-prereqs]]
|
|
|
+==== {api-prereq-title}
|
|
|
+
|
|
|
+To use this API, you must have one of the following privileges:
|
|
|
+
|
|
|
+* The `manage_user_profile` cluster privilege.
|
|
|
+* The `update_profile_data` global privilege for the namespaces that are
|
|
|
+referenced in the request.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-desc]]
|
|
|
+==== {api-description-title}
|
|
|
+
|
|
|
+The update user profile API updates the `access` and `data` fields of an
|
|
|
+existing user profile document with JSON objects. New keys and their values are
|
|
|
+added to the profile document, and conflicting keys are replaced by data that's
|
|
|
+included in the request.
|
|
|
+
|
|
|
+For both `access` and `data`, content is namespaced by the top-level fields.
|
|
|
+The `update_profile_data` global privilege grants privileges for updating only
|
|
|
+the allowed namespaces.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-path-params]]
|
|
|
+==== {api-path-parms-title}
|
|
|
+
|
|
|
+`uid`::
|
|
|
+(Required, string) A unique identifier for the user profile.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-query-params]]
|
|
|
+==== {api-query-parms-title}
|
|
|
+
|
|
|
+include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=if_seq_no]
|
|
|
+
|
|
|
+include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=if_primary_term]
|
|
|
+
|
|
|
+include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=refresh]
|
|
|
+
|
|
|
+`uid`::
|
|
|
+(Required, string) A unique identifier for the user profile.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-request-body]]
|
|
|
+==== {api-request-body-title}
|
|
|
+
|
|
|
+`access`::
|
|
|
+(Required*, object)
|
|
|
+Searchable data that you want to associate with the user profile.
|
|
|
+This field supports a nested data structure. Within the `access` object,
|
|
|
+top-level keys cannot begin with an underscore (`_`) or contain a period (`.`).
|
|
|
+
|
|
|
+`data`::
|
|
|
+(Required*, object)
|
|
|
+Non-searchable data that you want to associate with the user profile.
|
|
|
+This field supports a nested data structure. Within the `data` object, top-level
|
|
|
+keys cannot begin with an underscore (`_`) or contain a period (`.`)
|
|
|
+The `data` object is not searchable, but can be retrieved with the
|
|
|
+<<security-api-get-user-profile,Get user profile API>>.
|
|
|
+
|
|
|
+*Indicates that the setting is required in some, but not all situations.
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-response-body]]
|
|
|
+==== {api-response-body-title}
|
|
|
+
|
|
|
+A successful update user profile data API call returns a JSON structure
|
|
|
+indicating that the request is acknowledged:
|
|
|
+
|
|
|
+[source,js]
|
|
|
+----
|
|
|
+{
|
|
|
+ "acknowledged": true
|
|
|
+}
|
|
|
+----
|
|
|
+// NOTCONSOLE
|
|
|
+
|
|
|
+[[security-api-update-user-profile-data-example]]
|
|
|
+==== {api-examples-title}
|
|
|
+
|
|
|
+The following request updates a profile document for a `uid` matching
|
|
|
+`u_kd2JMqwUQwSCCOxMv7M1vw`:
|
|
|
+
|
|
|
+[source,console]
|
|
|
+----
|
|
|
+POST /_security/profile/_data/u_kd2JMqwUQwSCCOxMv7M1vw
|
|
|
+{
|
|
|
+ "access": {
|
|
|
+ "app1": {
|
|
|
+ "tag": "prod"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "data": {
|
|
|
+ "app1": {
|
|
|
+ "theme": "default"
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+----
|
|
|
+// TEST[skip:uid is random and no way to ensure this uid exists]
|
|
|
+
|
|
|
+You can update the profile data to replace some keys and add new keys:
|
|
|
+
|
|
|
+[source,console]
|
|
|
+----
|
|
|
+POST /_security/profile/_data/u_kd2JMqwUQwSCCOxMv7M1vw
|
|
|
+{
|
|
|
+ "access": {
|
|
|
+ "app1": {
|
|
|
+ "tag": "dev"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "data": {
|
|
|
+ "app1": {
|
|
|
+ "font": "large"
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+----
|
|
|
+// TEST[skip:uid is random and no way to ensure this uid exists]
|
|
|
+
|
|
|
+If you run the request again, the consolidated profile data is returned:
|
|
|
|
|
|
-coming::[8.2.0]
|
|
|
+[source,js]
|
|
|
+----
|
|
|
+{
|
|
|
+ "u_kd2JMqwUQwSCCOxMv7M1vw": {
|
|
|
+ "uid": "u_kd2JMqwUQwSCCOxMv7M1vw",
|
|
|
+ "enabled": true,
|
|
|
+ "last_synchronized": 1642650651037,
|
|
|
+ "user": {
|
|
|
+ "username": "jacknich",
|
|
|
+ "roles": [
|
|
|
+ "admin", "other_role1"
|
|
|
+ ],
|
|
|
+ "realm_name": "native1",
|
|
|
+ "full_name": "Jack Nicholson",
|
|
|
+ "email": "jacknich@example.com",
|
|
|
+ "active": true
|
|
|
+ },
|
|
|
+ "access": {
|
|
|
+ "app1": {
|
|
|
+ "tag": "dev"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "data": {
|
|
|
+ "app1": {
|
|
|
+ "theme": "default",
|
|
|
+ "font": "large"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "_doc": {
|
|
|
+ "_primary_term": 1,
|
|
|
+ "_seq_no": 0
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+----
|
|
|
+// NOTCONSOLE
|