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

Ensure all API Keys have a defined name #175721

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

legrego
Copy link
Member

@legrego legrego commented Jan 26, 2024

Summary

Resolves #173890.

API Keys created in the 7.x era did not require a name (https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body). The name is no longer an optional field, but our UIs have come to assume that a name will always be available. This updates our GET /internal/security/api_key API to ensure that a name will always exist.

Update The behavior of this has changed slightly via #175733. Instead of returning an empty name, the name will fallback to the key's id.

@legrego legrego added release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Users/Roles/API Keys backport:all-open Backport to all branches that could still receive a release labels Jan 26, 2024
@legrego
Copy link
Member Author

legrego commented Jan 26, 2024

/ci

@legrego legrego marked this pull request as ready for review January 26, 2024 18:32
@legrego legrego requested a review from a team as a code owner January 26, 2024 18:32
@elasticmachine
Copy link
Contributor

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

@legrego legrego enabled auto-merge (squash) January 26, 2024 18:44
@jeramysoucy jeramysoucy self-requested a review January 26, 2024 18:54
Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

LGTM

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #14 / CustomFields should sort the custom fields correctly
  • [job] [logs] Jest Tests #14 / CustomFields should update the custom fields

Metrics [docs]

✅ unchanged

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@legrego legrego merged commit 707b423 into elastic:main Jan 26, 2024
28 checks passed
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
7.17 Backport failed because of merge conflicts

You might need to backport the following PRs to 7.17:
- Upgrade ESLint to v8 (#162309)
8.12

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 175721

Questions ?

Please refer to the Backport tool documentation

@legrego legrego deleted the fix-null-api-key-names branch January 26, 2024 20:23
@legrego legrego added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) and removed backport:all-open Backport to all branches that could still receive a release labels Jan 26, 2024
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 26, 2024
## Summary

Resolves elastic#173890.

API Keys created in the 7.x era did not require a `name`
(https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body).
The `name` is no longer an optional field, but our UIs have come to
assume that a `name` will always be available. This updates our `GET
/internal/security/api_key` API to ensure that a `name` will always
exist.

(cherry picked from commit 707b423)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.12

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

legrego added a commit that referenced this pull request Jan 26, 2024
Followup to #175721.

Prefer using the key's `id` when `name` is not defined.
kibanamachine added a commit that referenced this pull request Jan 27, 2024
# Backport

This will backport the following commits from `main` to `8.12`:
- [Ensure all API Keys have a defined name
(#175721)](#175721)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Larry
Gregory","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-01-26T20:16:06Z","message":"Ensure
all API Keys have a defined name (#175721)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/173890.\r\n\r\nAPI Keys created
in the 7.x era did not require a
`name`\r\n(https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body).\r\nThe
`name` is no longer an optional field, but our UIs have come
to\r\nassume that a `name` will always be available. This updates our
`GET\r\n/internal/security/api_key` API to ensure that a `name` will
always\r\nexist.","sha":"707b4233898c18e63896581a61ddf8bfb7f20979","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Security","Feature:Users/Roles/API
Keys","backport:all-open","v8.13.0"],"title":"Ensure all API Keys have a
defined
name","number":175721,"url":"https://github.com/elastic/kibana/pull/175721","mergeCommit":{"message":"Ensure
all API Keys have a defined name (#175721)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/173890.\r\n\r\nAPI Keys created
in the 7.x era did not require a
`name`\r\n(https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body).\r\nThe
`name` is no longer an optional field, but our UIs have come
to\r\nassume that a `name` will always be available. This updates our
`GET\r\n/internal/security/api_key` API to ensure that a `name` will
always\r\nexist.","sha":"707b4233898c18e63896581a61ddf8bfb7f20979"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","branchLabelMappingKey":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175721","number":175721,"mergeCommit":{"message":"Ensure
all API Keys have a defined name (#175721)\n\n## Summary\r\n\r\nResolves
https://github.com/elastic/kibana/issues/173890.\r\n\r\nAPI Keys created
in the 7.x era did not require a
`name`\r\n(https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body).\r\nThe
`name` is no longer an optional field, but our UIs have come
to\r\nassume that a `name` will always be available. This updates our
`GET\r\n/internal/security/api_key` API to ensure that a `name` will
always\r\nexist.","sha":"707b4233898c18e63896581a61ddf8bfb7f20979"}}]}]
BACKPORT-->

Co-authored-by: Larry Gregory <[email protected]>
legrego added a commit to legrego/kibana that referenced this pull request Jan 29, 2024
Followup to elastic#175721.

Prefer using the key's `id` when `name` is not defined.

(cherry picked from commit 2cf9668)
legrego referenced this pull request Jan 29, 2024
#175800)

# Backport

This will backport the following commits from `main` to `8.12`:
- [Fallback to using api key id when name is not defined
(#175733)](#175733)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Larry
Gregory","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-01-26T22:34:05Z","message":"Fallback
to using api key id when name is not defined (#175733)\n\nFollowup to
https://github.com/elastic/kibana/pull/175721.\r\n\r\nPrefer using the
key's `id` when `name` is not
defined.","sha":"2cf9668d5d84448046154e0a070b587385b6fc35","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Security","Feature:Users/Roles/API
Keys","release_note:skip","backport:prev-minor","v8.13.0"],"number":175733,"url":"https://github.com/elastic/kibana/pull/175733","mergeCommit":{"message":"Fallback
to using api key id when name is not defined (#175733)\n\nFollowup to
https://github.com/elastic/kibana/pull/175721.\r\n\r\nPrefer using the
key's `id` when `name` is not
defined.","sha":"2cf9668d5d84448046154e0a070b587385b6fc35"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175733","number":175733,"mergeCommit":{"message":"Fallback
to using api key id when name is not defined (#175733)\n\nFollowup to
https://github.com/elastic/kibana/pull/175721.\r\n\r\nPrefer using the
key's `id` when `name` is not
defined.","sha":"2cf9668d5d84448046154e0a070b587385b6fc35"}}]}]
BACKPORT-->
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
## Summary

Resolves elastic#173890.

API Keys created in the 7.x era did not require a `name`
(https://www.elastic.co/guide/en/elasticsearch/reference/7.5/security-api-create-api-key.html#security-api-create-api-key-request-body).
The `name` is no longer an optional field, but our UIs have come to
assume that a `name` will always be available. This updates our `GET
/internal/security/api_key` API to ensure that a `name` will always
exist.
CoenWarmer pushed a commit to CoenWarmer/kibana that referenced this pull request Feb 15, 2024
Followup to elastic#175721.

Prefer using the key's `id` when `name` is not defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Users/Roles/API Keys release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.12.1 v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API Keys with null name value cause UI to not render
5 participants