-
Notifications
You must be signed in to change notification settings - Fork 25.6k
DOCS] Adds update cross cluster API key API examples #129843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
380cfa8
DOCS] Adds update cross cluster API k
szabosteve 178fa40
Fixes markup.
szabosteve 0665d4f
Merge branch 'main' into update-ccapikey-example
szabosteve 6cde2de
Update docs/reference/elasticsearch/rest-apis/update-cc-api-key-examp…
szabosteve 7b308e0
[DOCS] Subheadings.
szabosteve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
205 changes: 205 additions & 0 deletions
205
docs/reference/elasticsearch/rest-apis/update-cc-api-key-examples.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| --- | ||
| applies_to: | ||
| stack: all | ||
| navigation_title: Update cross-cluster API examples | ||
| --- | ||
| # Update cross-cluster API key API examples | ||
|
|
||
| The [update cross-cluster API key API](https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-cross-cluster-api-key) updates the attributes of an existing cross-cluster API key, which is used for API key based remote cluster access. This page shows you examples of using this API. | ||
|
|
||
| If you create a cross-cluster API key as follows: | ||
|
|
||
| ```console | ||
| POST /_security/cross_cluster/api_key | ||
| { | ||
| "name": "my-cross-cluster-api-key", | ||
| "access": { | ||
| "search": [ | ||
| { | ||
| "names": ["logs*"] | ||
| } | ||
| ] | ||
| }, | ||
| "metadata": { | ||
| "application": "search" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| A successful call returns a JSON structure that provides API key information. For example: | ||
|
|
||
| ```console-result | ||
| { | ||
| "id": "VuaCfGcBCdbkQm-e5aOx", | ||
| "name": "my-cross-cluster-api-key", | ||
| "api_key": "ui2lp2axTNmsyakw9tvNnw", | ||
| "encoded": "VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==" | ||
| } | ||
| ``` | ||
|
|
||
| % TESTRESPONSE[s/VuaCfGcBCdbkQm-e5aOx/$body.id/] | ||
| % TESTRESPONSE[s/ui2lp2axTNmsyakw9tvNnw/$body.api_key/] | ||
| % TESTRESPONSE[s/VnVhQ2ZHY0JDZGJrUW0tZTVhT3g6dWkybHAyYXhUTm1zeWFrdzl0dk5udw==/$body.encoded/] | ||
|
|
||
| Information of the API key, including its exact role descriptor can be inspected with the [Get API key API](https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-api-key). | ||
|
|
||
| ```console | ||
| GET /_security/api_key?id=VuaCfGcBCdbkQm-e5aOx | ||
| ``` | ||
|
|
||
| % TEST[s/VuaCfGcBCdbkQm-e5aOx/$body.id/] | ||
| % TEST[continued] | ||
|
|
||
| A successful call returns a JSON structure that contains the information of the API key: | ||
|
|
||
| ```js | ||
| { | ||
| "api_keys": [ | ||
| { | ||
| "id": "VuaCfGcBCdbkQm-e5aOx", | ||
| "name": "my-cross-cluster-api-key", | ||
| "type": "cross_cluster", | ||
| "creation": 1548550550158, | ||
| "expiration": null, | ||
| "invalidated": false, | ||
| "username": "myuser", | ||
| "realm": "native1", | ||
| "metadata": { | ||
| "application": "search" | ||
| }, | ||
| "role_descriptors": { | ||
| "cross_cluster": { <1> | ||
| "cluster": [ | ||
| "cross_cluster_search" | ||
| ], | ||
| "indices": [ | ||
| { | ||
| "names": [ | ||
| "logs*" | ||
| ], | ||
| "privileges": [ | ||
| "read", "read_cross_cluster", "view_index_metadata" | ||
| ], | ||
| "allow_restricted_indices": false | ||
| } | ||
| ], | ||
| "applications": [ ], | ||
| "run_as": [ ], | ||
| "metadata": { }, | ||
| "transient_metadata": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| }, | ||
| "access": { <2> | ||
| "search": [ | ||
| { | ||
| "names": [ | ||
| "logs*" | ||
| ], | ||
| "allow_restricted_indices": false | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| % NOTCONSOLE | ||
|
|
||
| 1. Role descriptor corresponding to the specified `access` scope at creation time. | ||
| In this example, it grants cross cluster search permission for the `logs*` index pattern. | ||
| 2. The `access` corresponds to the value specified at API key creation time. | ||
|
|
||
| The following example updates the API key created above, assigning it new access scope and metadata: | ||
|
|
||
| ```console | ||
| PUT /_security/cross_cluster/api_key/VuaCfGcBCdbkQm-e5aOx | ||
| { | ||
| "access": { | ||
| "replication": [ | ||
| { | ||
| "names": ["archive"] | ||
| } | ||
| ] | ||
| }, | ||
| "metadata": { | ||
| "application": "replication" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| % TEST[s/VuaCfGcBCdbkQm-e5aOx/\${body.api_keys.0.id}/] | ||
| % TEST[continued] | ||
|
|
||
| A successful call returns a JSON structure indicating that the API key was updated: | ||
|
|
||
| ```console-result | ||
| { | ||
| "updated": true | ||
| } | ||
| ``` | ||
|
|
||
| The API key's permissions after the update can be inspected again with the [Get API key API](https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-api-key) and it will be: | ||
|
|
||
| ```js | ||
| { | ||
| "api_keys": [ | ||
| { | ||
| "id": "VuaCfGcBCdbkQm-e5aOx", | ||
| "name": "my-cross-cluster-api-key", | ||
| "type": "cross_cluster", | ||
| "creation": 1548550550158, | ||
| "expiration": null, | ||
| "invalidated": false, | ||
| "username": "myuser", | ||
| "realm": "native1", | ||
| "metadata": { | ||
| "application": "replication" | ||
| }, | ||
| "role_descriptors": { | ||
| "cross_cluster": { <1> | ||
| "cluster": [ | ||
| "cross_cluster_replication" | ||
| ], | ||
| "indices": [ | ||
| { | ||
| "names": [ | ||
| "archive*" | ||
| ], | ||
| "privileges": [ | ||
| "cross_cluster_replication", "cross_cluster_replication_internal" | ||
| ], | ||
| "allow_restricted_indices": false | ||
| } | ||
| ], | ||
| "applications": [ ], | ||
| "run_as": [ ], | ||
| "metadata": { }, | ||
| "transient_metadata": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| }, | ||
| "access": { <2> | ||
| "replication": [ | ||
| { | ||
| "names": [ | ||
| "archive*" | ||
| ], | ||
| "allow_restricted_indices": false | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| % NOTCONSOLE | ||
|
|
||
| 1. Role descriptor is updated to be the `access` scope specified at update time. | ||
| In this example, it is updated to grant the cross cluster replication permission | ||
| for the `archive*` index pattern. | ||
| 2. The `access` corresponds to the value specified at API key update time. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.