-
Notifications
You must be signed in to change notification settings - Fork 25.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REST API changes for manage-own-api-key privilege (#44936)
This commit adds a flag that can be set to `true` if the API key request (Get or Invalidate) is for the API keys owned by the currently authenticated user only. These only interface changes and once the actual cluster privilege `manage_own_api_key` is done, we will have another PR to make the interface work. The Get API behavior would be: - when `owner` is set to `true` `GET /_security/api_key?id=abcd&owner=true` the Rest controller will take care of setting `realm_name` and `username` to the values for the authenticated user and only return results if it finds one owned by the currently authenticated user. - when `owner` is set to `false` (default) `GET /_security/api_key?id=abcd` the Rest controller will assume `realm_name` and `username` to be unspecified meaning it will try to search for the API key across users and realms. This will fail if the user has only `manage_own_api_key` privilege. Similarly, for Delete API key behavior: - when `owner` is set to `true` `DELETE /_security/api_key` ``` { "id" : "VuaCfGcBCdbkQm-e5aOx", "owner": "true" } ``` the Rest controller will take care of setting `realm_name` and `username` to the values for the authenticated user and only invalidate key if it finds one owned by the currently authenticated user. - when `my_api_keys_only` is set to `false` (default) `DELETE /_security/api_key` ``` { "id" : "VuaCfGcBCdbkQm-e5aOx", "owner": "false" } ``` the Rest controller will assume `realm_name` and `username` to be unspecified meaning it will try to search for the API key across users and realms. This will fail if the user has only `manage_own_api_key` privilege. TODO: - HLRC changes - these will be done in a separate PR - Actual enforcement of `my_api_keys_only` in a separate PR Relates #40031
- Loading branch information
Showing
9 changed files
with
424 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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.