[Security Solution] Use authc.getCurrentUser from core.security in browser
follows https://github.com/elastic/kibana/pull/187004
Summary
This PR migrates the Security Solution Plugin's browser-side code that consume authc.getCurrentUser to use coreStart.security
Background: This PR serves as an example of a plugin migrating away from depending on the Security plugin, which is a high priority effort for the last release before 9.0.
Checklist
Delete any items that are not applicable to this PR.
- [x] Unit or functional tests were updated or added to match the most common scenarios
Pinging @elastic/security-solution (Team: SecuritySolution)
/ci
/ci
:broken_heart: Build Failed
- Buildkite Build
- Commit: a600e6d341f148de2774322b731ce9a4c4c15a61
- Interpreting CI Failures
Failed CI Steps
Test Failures
- [job] [logs] FTR Configs #49 / @skipInServerless endpoint @ess @serverless When on the Endpoint Policy Details Page when on Ingest Policy Edit Package Policy page should allow updates to policy items
- [job] [logs] FTR Configs #49 / @skipInServerless endpoint @ess @serverless When on the Endpoint Policy Details Page when on Ingest Policy Edit Package Policy page should allow updates to policy items
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 |
|---|---|---|---|
securitySolution |
15.5MB | 15.5MB | -256.0B |
Page load bundle
Size of the bundles that are downloaded on every page load. Target size is below 100kb
| id | before | after | diff |
|---|---|---|---|
securitySolution |
83.6KB | 83.6KB | +7.0B |
Unknown metric groups
References to deprecated APIs
| id | before | after | diff |
|---|---|---|---|
securitySolution |
571 | 569 | -2 |
History
- :broken_heart: Build #218580 failed 88402fdda5ac7ecc1b30f98d47d54bb555db329e
- :broken_heart: Build #218540 failed 94d24a0f20fd1e3bacc897fef562d5b4d79e3ebf
- :broken_heart: Build #218527 failed 102a92e7231dbef8b7effdaddcb30b43dc68a04e
- :broken_heart: Build #218362 failed 1bea041b06b755a0c3732f69eef28f1b3ab6e3ac
To update your PR or re-run it, just comment with:
@elasticmachine merge upstream
The functional tests failures currently in this PR are pointing to an issue in the code that is hard to debug. In the following code change:
- const { security } = useKibana().services;
+ const { securityService: security } = useKibana().services;
We expect that the securityService field of StartServices is available from services that have been passed to KibanaContextProvider. However, somewhere in the code there is a call KibanaContextProvider that doesn't have that field. Ideally, a problem like this would be caught by in type-check, but KibanaContextProvider isn't type-safe. The solution would be to restructure the code to use specific providers and hooks, and avoid using useKibana for services that come from plugins.
Example: In a high-level application tsx:
<SecuritySolutionProvider services={{ securityService: coreStart.security, ... }}>
// ... application code
</SecuritySolutionProvider>
In a low-level lib:
const { securityService } = useSecuritySolution(); // the services coming out of this hook would be guaranteed to exist
This is the same complication that I encountered with #187190. Same as that PR, I'm choosing to close this PR for now.