Skip to content
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

YAML tests and docs for viewing API key role descriptors #89186

Merged

Conversation

ywangd
Copy link
Member

@ywangd ywangd commented Aug 9, 2022

This PR expands existing YAML tests and docs for the new
role_descriptors field returned in both Get and Query API key calls.

Relates: #89166, #89058

This PR expands existing YAML tests and docs for the new
role_descriptors field returned in both Get and Query API key calls.

Relates: elastic#89166, elastic#89058
@ywangd ywangd added >docs General docs changes >test Issues or PRs that are addressing/adding tests :Security/Security Security issues without another label v8.5.0 labels Aug 9, 2022
@elasticsearchmachine elasticsearchmachine added Team:Docs Meta label for docs team Team:Security Meta label for security team labels Aug 9, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-security (Team:Security)

Comment on lines 1 to 4
---
setup:
- skip:
features: headers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a new YAML file instead of adding matches for role_descriptors to existing ones because:

  • The matches are quite verbose and they clutter the existing tests, while keeping them separately is easier to have more targeted setup.
  • It can be even more verbose once we add support for limited_role_descriptors
  • Matching multiple API keys in response of QueryApiKey requires sorting and it is easier to setup in a new test (than retrofitting into existing ones)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could go with one of 40_{view or show or read}_role_descriptors.yml to make it more explicit that it's about Get and Query. Tots optional though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 40_view_role_descriptors.yml.

Copy link
Contributor

@n1v0lg n1v0lg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

x-pack/docs/en/rest-api/security/get-api-keys.asciidoc Outdated Show resolved Hide resolved
x-pack/docs/en/rest-api/security/get-api-keys.asciidoc Outdated Show resolved Hide resolved
<10> The role descriptors that are assigned to this API key when it was <<api-key-role-descriptors,created>>
or last <<security-api-update-api-key-api-key-role-descriptors,updated>>. Note the API key's
effective permissions are an intersection of its assigned privileges and the point-in-time snapshot of
the owner user's permissions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to address now, but once we have the API key overview page we can link to a section on API key permissions there, for more detail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally!

x-pack/docs/en/rest-api/security/get-api-keys.asciidoc Outdated Show resolved Hide resolved
x-pack/docs/en/rest-api/security/query-api-key.asciidoc Outdated Show resolved Hide resolved
Comment on lines 1 to 4
---
setup:
- skip:
features: headers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could go with one of 40_{view or show or read}_role_descriptors.yml to make it more explicit that it's about Get and Query. Tots optional though.

@@ -15,7 +15,11 @@ Retrieves information for one or more API keys.
[[security-api-get-api-key-prereqs]]
==== {api-prereq-title}

* To use this API, you must have at least the `manage_api_key` cluster privilege.
* To use this API, you must have at least the `manage_own_api_key` cluster privilege.
* If you have only the `manage_own_api_key` privilege, this API returns only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"applications": [ ],
"run_as": [ ],
"metadata": { },
"transient_metadata": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

transient_metadata feels more like an internal value as opposed to something that would be part of the public API, but we already expose it via the roles API as well so it makes sense to stay consistent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is intentional for transient_metadata to be in the response, at least for regular roles. When a role has DLS/FLS but the cluster license does not allow it, the transient_metadata will have this information to let user know that the role is disabled and for what reason, e.g.:

"transient_metadata": {
  "unlicensed_features": ["dls", "fls"],
  "enabled": false
}

That said, the license enforcement for API key's permission works differently and does not rely on the transient metadata. But for future proof and consistent, I'd say it's better to keep it in the response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I didn't realize this was meant for end-users. Makes sense to keep it in the response 👍

@ywangd
Copy link
Member Author

ywangd commented Aug 10, 2022

@elasticmachine update branch

@lockewritesdocs
Copy link
Contributor

@elasticmachine run elasticsearch-ci/docs

Copy link
Contributor

@lockewritesdocs lockewritesdocs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🦖

@ywangd ywangd added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Aug 16, 2022
@ywangd
Copy link
Member Author

ywangd commented Aug 17, 2022

@elasticmachine run elasticsearch-ci/part-1

@elasticsearchmachine elasticsearchmachine merged commit 2841bf7 into elastic:main Aug 17, 2022
@ywangd ywangd deleted the doc-get-api-key-role-descriptors branch August 17, 2022 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >docs General docs changes :Security/Security Security issues without another label Team:Docs Meta label for docs team Team:Security Meta label for security team >test Issues or PRs that are addressing/adding tests v8.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants