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

[Search][Onboarding] api-key plugin #191926

Merged
merged 48 commits into from
Oct 2, 2024

Conversation

yansavitski
Copy link
Contributor

@yansavitski yansavitski commented Sep 2, 2024

Summary

Kibana plugin that helps manage the session for the api-key that provides two exports:

  • React custom hook to read the api-key stored in session. This hook should return the api-key if it exists, otherwise null.
  • Component to present either the api key in storage or action to create api key and store into sessionStorage after callback.
Screenshot 2024-09-27 at 20 52 52 Screenshot 2024-09-27 at 20 52 39 Screenshot 2024-09-27 at 20 52 28

Checklist

Delete any items that are not applicable to this PR.


return apiKey;
} catch (e) {
logger.error(`Error creating API Key for elasticsearch start`);
Copy link
Member

@joemcelroy joemcelroy Sep 17, 2024

Choose a reason for hiding this comment

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

better error message here (focus on api-keys plugin)


return apiKey.api_keys?.[0];
} catch (e) {
logger.error(`Error getting API Key for elasticsearch start`);
Copy link
Member

Choose a reason for hiding this comment

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

same here: better error message, associating with api-key plugin

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#7045

[❌] x-pack/test_serverless/functional/test_suites/search/config.feature_flags.ts: 0/25 tests passed.

see run history

}
};

export const useSearchApiKey = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The contents of this hook could be broken up into more composable pieces. But at a minimum we will need a hook exported to get the session API key for the code examples.

Copy link
Member

Choose a reason for hiding this comment

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

yep that makes sense. I've updated the code to also do the code sample replacement.

const codeParams = useMemo(() => {
return {
indexName: createIndexForm.indexName || undefined,
elasticsearchURL: elasticsearchUrl,
apiKey: apiKeyIsVisible && apiKey ? apiKey : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

we'll need to do this for the index details no data view too here

Copy link
Member

Choose a reason for hiding this comment

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

yep was done as part of the change

},
});

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

since we're rendering this provider in the search_indices application now this will be called for all search_indices routes on page load.

With this going out to serverless only for now, I'm ok with it for now. But I think we'll need to refine this in the future to be more explicit about when the creation logic is called vs when we just check and read for an existing key.

Copy link
Member

Choose a reason for hiding this comment

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

yep this useEffect will run on page routes but the API creation code will only be executed once a hook has been mounted and will only be run once until the provider is unmounted.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
searchIndices 181 216 +35

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/search-api-keys-components - 8 +8
@kbn/search-api-keys-server - 3 +3
@kbn/search-shared-ui - 2 +2
total +13

Async chunks

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

id before after diff
searchIndices 92.6KB 148.1KB +55.6KB
security 590.8KB 590.9KB +80.0B
serverlessSearch 327.2KB 327.3KB +80.0B
total +55.7KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/core 1 2 +1
@kbn/search-api-keys-components - 1 +1
total +2

Page load bundle

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

id before after diff
searchIndices 6.0KB 6.2KB +227.0B
Unknown metric groups

API count

id before after diff
@kbn/search-api-keys-components - 8 +8
@kbn/search-api-keys-server - 3 +3
@kbn/search-shared-ui - 2 +2
total +13

async chunk count

id before after diff
searchIndices 4 5 +1

ESLint disabled line counts

id before after diff
@kbn/security-api-key-management 5 6 +1

Total ESLint disabled count

id before after diff
@kbn/security-api-key-management 5 6 +1

History

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

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#7056

[✅] x-pack/test_serverless/api_integration/test_suites/search/config.feature_flags.ts: 25/25 tests passed.

see run history

Copy link
Contributor

@SiddharthMantri SiddharthMantri left a comment

Choose a reason for hiding this comment

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

API Key flyout changes LGTM

@joemcelroy joemcelroy merged commit c5aa739 into elastic:main Oct 2, 2024
36 checks passed
@joemcelroy joemcelroy deleted the onboarding-api-plugin branch October 2, 2024 08:45
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11140669260

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.x Backport failed because of merge conflicts

You might need to backport the following PRs to 8.x:
- [ML] Various fixes for possible prototype pollution vulnerabilities (#194529)
- [UII] Add proxy args to install snippets (#193922)
- Update Search Index Document Card design. (#194061)

Manual backport

To create the backport manually run:

node scripts/backport --pr 191926

Questions ?

Please refer to the Backport tool documentation

delanni added a commit that referenced this pull request Oct 2, 2024
## Summary
#191926 introduces something
that's in contradiction with
#194144

This PR adds a fix.
@delanni
Copy link
Contributor

delanni commented Oct 2, 2024

@yansavitski if you'd like to backport this, you'll have to accommodate for changes in #194144 - (like #194676)

@joemcelroy
Copy link
Member

💚 All backports created successfully

Status Branch Result
8.x

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

Questions ?

Please refer to the Backport tool documentation

joemcelroy pushed a commit to joemcelroy/kibana that referenced this pull request Oct 2, 2024
## Summary
Kibana plugin that helps manage the session for the api-key that
provides two exports:
- React custom hook to read the api-key stored in session. This hook
should return the api-key if it exists, otherwise null.
- Component to present either the api key in storage or action to create
api key and store into sessionStorage after callback.
<img width="1255" alt="Screenshot 2024-09-27 at 20 52 52"
src="https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62">
<img width="1248" alt="Screenshot 2024-09-27 at 20 52 39"
src="https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534">
<img width="676" alt="Screenshot 2024-09-27 at 20 52 28"
src="https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb">

(cherry picked from commit c5aa739)

# Conflicts:
#	.github/CODEOWNERS
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Oct 3, 2024
@kibanamachine
Copy link
Contributor

Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync.

joemcelroy added a commit that referenced this pull request Oct 3, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[Search][Onboarding] api-key plugin
(#191926)](#191926)

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

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

<!--BACKPORT [{"author":{"name":"Yan
Savitski","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-02T08:45:20Z","message":"[Search][Onboarding]
api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps
manage the session for the api-key that\r\nprovides two exports:\r\n-
React custom hook to read the api-key stored in session. This
hook\r\nshould return the api-key if it exists, otherwise null.\r\n-
Component to present either the api key in storage or action to
create\r\napi key and store into sessionStorage after callback.\r\n<img
width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52
52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img
width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52
39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img
width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52
28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor"],"number":191926,"url":"https://github.com/elastic/kibana/pull/191926","mergeCommit":{"message":"[Search][Onboarding]
api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps
manage the session for the api-key that\r\nprovides two exports:\r\n-
React custom hook to read the api-key stored in session. This
hook\r\nshould return the api-key if it exists, otherwise null.\r\n-
Component to present either the api key in storage or action to
create\r\napi key and store into sessionStorage after callback.\r\n<img
width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52
52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img
width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52
39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img
width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52
28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191926","number":191926,"mergeCommit":{"message":"[Search][Onboarding]
api-key plugin (#191926)\n\n## Summary\r\nKibana plugin that helps
manage the session for the api-key that\r\nprovides two exports:\r\n-
React custom hook to read the api-key stored in session. This
hook\r\nshould return the api-key if it exists, otherwise null.\r\n-
Component to present either the api key in storage or action to
create\r\napi key and store into sessionStorage after callback.\r\n<img
width=\"1255\" alt=\"Screenshot 2024-09-27 at 20 52
52\"\r\nsrc=\"https://github.com/user-attachments/assets/dc5bcd39-7fe6-433c-8aaa-ad3578a68b62\">\r\n<img
width=\"1248\" alt=\"Screenshot 2024-09-27 at 20 52
39\"\r\nsrc=\"https://github.com/user-attachments/assets/d760c163-9017-4f57-ba1a-38ee8ee21534\">\r\n<img
width=\"676\" alt=\"Screenshot 2024-09-27 at 20 52
28\"\r\nsrc=\"https://github.com/user-attachments/assets/e908d20a-7e0c-4f3b-9ea2-8e2d1a74c9eb\">","sha":"c5aa73991463dee50b036bb51645e03cc283bb8c"}}]}]
BACKPORT-->

---------

Co-authored-by: Yan Savitski <[email protected]>
@kibanamachine kibanamachine added v8.16.0 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Oct 3, 2024
@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#7133

[✅] x-pack/test_serverless/api_integration/test_suites/search/config.feature_flags.ts: 25/25 tests passed.

see run history

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) release_note:skip Skip the PR/issue when compiling release notes v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants