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

[Connection Details] Add route for own api key permissions #182013

Closed
wants to merge 53 commits into from

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Apr 29, 2024

Summary

Partially closes #181288 and follow up on connection details created in #180912

This PR creates the endpoint that will return API Keys if a user can manage their own API keys and adds it to the existing routes in the security plugin.

  • Create HTTP endpoint that returns if user can manage own API keys. See how it is done here.
  • Add the new route to x-pack/plugins/security/server/routes/api_keys.
  • Cache the result retrieved from that endpoint. (lodash once)
  • Use the result retrieved from that endpoint to provide the hasPermission option in component, it will automatically render the "API keys" appropriately.

Checklist

@rshen91 rshen91 self-assigned this Apr 29, 2024
@rshen91 rshen91 added the Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) label Apr 29, 2024
@rshen91 rshen91 changed the title add route for own api key permissions [Connection Details] Add route for own api key permissions Apr 29, 2024
@rshen91
Copy link
Contributor Author

rshen91 commented Apr 29, 2024

/ci

@rshen91
Copy link
Contributor Author

rshen91 commented Apr 30, 2024

/ci

@rshen91
Copy link
Contributor Author

rshen91 commented May 1, 2024

/ci

@rshen91
Copy link
Contributor Author

rshen91 commented May 1, 2024

/ci

@rshen91 rshen91 marked this pull request as ready for review May 7, 2024 20:07
@rshen91 rshen91 requested review from a team as code owners May 7, 2024 20:07
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@kc13greiner kc13greiner self-requested a review May 7, 2024 20:14
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

see comment

Comment on lines 68 to 70
hasPermission: once(
async () => await http!.get<boolean>('/internal/security/api_key/check_permissions')
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Calling, from a plugin, an HTTP endpoint owned by another plugin is a bad isolation pattern that is strongly discouraged.

In theory, that should be done by leveraging the security plugin's contract (that should be the one charge of performing the http call).

Let's wait on what the security team thinks about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good call, @pgayvallet . I agree it would be best to expose this alongside the rest of the apiKeys functions in Security plugin's start() > authc > apiKeys

@kibana-ci
Copy link
Collaborator

kibana-ci commented May 10, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #8 / Cloud Integrations Cloud Links integration Guided onboarding Can create an API key
  • [job] [logs] FTR Configs #8 / Cloud Integrations Cloud Links integration Guided onboarding Can create an API key
  • [job] [logs] Jest Tests #2 / Security Plugin #setup setups Management Service if management plugin is available
  • [job] [logs] Jest Tests #2 / Security Plugin #setup setups Management Service if management plugin is available
  • [job] [logs] Jest Tests #2 / Security Plugin #setup should be able to setup if optional plugins are not available
  • [job] [logs] Jest Tests #2 / Security Plugin #setup should be able to setup if optional plugins are not available
  • [job] [logs] Jest Tests #2 / Security Plugin #start should be able to setup if optional plugins are not available
  • [job] [logs] Jest Tests #2 / Security Plugin #start should be able to setup if optional plugins are not available

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
home 148.0KB 148.7KB +642.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cloudLinks 25.3KB 25.9KB +647.0B
security 68.9KB 69.0KB +105.0B
total +752.0B
Unknown metric groups

API count

id before after diff
@kbn/security-plugin-types-public 39 40 +1
@kbn/security-plugin-types-server 207 208 +1
security 413 415 +2
total +4

History

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

cc @rshen91

@rshen91
Copy link
Contributor Author

rshen91 commented May 13, 2024

Closing duplicate of https://github.com/elastic/kibana/pull/183286/files

@rshen91 rshen91 closed this May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Connection Details] Check if user has permissions to create API key
7 participants