-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Making security
a first class citizen of Kibana Core
#174578
Comments
After thinking about it a bit more, I just realized that using a simple API registration pattern for the security plugin to register its API during its respective That makes me wonder if we won't need, after all, to move the implementation to some package and have core use it directly (instead of depending on the security plugin as I initially suggested)... |
(continuing to think out loud) Looking at the current kibana/x-pack/plugins/security/server/plugin.ts Lines 73 to 85 in f7fa846
If we get to the conclusion that those 2 services are sufficient to be injected into Core (meaning that they are the only relevant parts than we need to be able to use in Core and to eventually re-expose to plugin), an alternative, that would require less work, would be to have the security plugin register this part of its setup contract during setup, and have core exposes it to plugins only via its start contract. Given most (all?) of the authc / authz APIs takes a This is less of a refactor, as we basically only introduce a new registration API in Core to be used by the security plugin, but it would still solve most of what we're trying to achieve here, so I wonder if it wouldn't be a pragmatic quick win? |
It totally does, thanks for filing this issue!
On the surface, it sounds like the easiest approach that doesn't require any significant changes for either side, which makes sense to me.
As you mentioned in the last comment, most of the security logic that other plugins rely on should be accessed after
Initially, we might skip certain parts, I think. But eventually, most of the security stuff would make sense to have in the Core, especially All in all, I think this project is already actionable and worth pursuing. |
FYI, I started working on the first part of the project, exposing |
…y` (#177976) ## Summary First part of #174578 - Introduce the new `security` core service, both on the browser and server-side. - In this first stage, this service only has a single API: `authc.getCurrentUser` - Have the security plugin register its API to Core for ex-exposition --------- Co-authored-by: kibanamachine <[email protected]>
#177976 was just merged. The next step would be to decide which security API(s) we expose next from Core, and if we can just re-use the exact same signatures or if we want to take this opportunity to clean / change it. |
Summary of yesterday's meeting with @TinaHeiligers and @azasypkin: What's next?We identified 4 areas User profileMigrating the
Internal hooksThis area is about cleaning the various hooks between the security plugin and core, by exposing internals APIs that Core could consume instead.
There is no consumer-facing APIs to move here, it's mostly about taking this opportunity to (finally) remove tech debt around those hooks. AuthorizationMigrating the
Audit loggingMigrating the
Order
|
@pgayvallet we need to add an item to update all the README's for the core packages, as discussed in our latest sync. Something along the lines of: |
…ty` plugin (#181538) ## Summary Part of #174578 Adapt Core's `userSettings` service to leverage Core's `userProfile` service instead of the `security` plugin --------- Co-authored-by: kibanamachine <[email protected]>
The The remaining tasks, as listed on this issue's description, are:
The Core team should be autonomous regarding the cleanup tasks. However regarding the @azasypkin / @legrego not really a high priority, but do you have any visibility on when you'll be able to work on that part? |
We should probably discuss our approach in an issue. |
@pgayvallet we do not have an estimated date at this point. Our focus has been pulled away recently towards other commitments. The other service we want to add is the Core Encryption Service (#180867) -- this is a new service as opposed to moving an existing one, but between those two, which would you like to see us focus on first? |
@legrego it depends on which one will will be less effort and more reward: the new Core Encryption Service or |
If we have consumers eager to use the Core Encryption Service as soon as it's introduced, I'd go with it (high effort, but also high short-term reward). Even if we re-expose authorization APIs from the Core, it will likely take quite some time before anyone commits to migrating to Core APIs from the Security ones (medium effort, but potentially low short-term reward). Both are high-reward initiatives long-term though. |
My gut feeling would be that the encryption service may be a higher effort/reward ratio, but the security team may have more visibility than we do on that question |
## Summary Part of #174578 Flag as deprecated the APIs from the security plugin that are now re-exposed from Core
@elastic/kibana-security the scope for phase 2 and 3 need to change a bit based on what code is single vs dual licensed. Here are the results (focus being on Platform only): https://docs.google.com/spreadsheets/d/1-oiYNxiAWNwBP5gnNoJP6GJ-5hs4kozAPyeYsqSC3Jg/edit?usp=sharing |
Phase 3 on hold, pending 9.0.0 Not on hold:
|
Context
We've been discussing this for a while now, but we never officialized it by opening an issue. I guess it's now done.
Security in Core, why?
Over the past few years, we've been encountering more and more scenarios and use cases where Core not being aware of the security concepts and primitives (authc, authz, user, principal...) and not able to use the security API is problematic.
Historically (and to summarize), the reasons behind this hard separation was xpack and the difference of license between the oss and xpack parts of the code, which drove the decision to have the full security implementation being under the xpack license/folder. However, things changed regarding our code's licensing, and also, there are way to keep the implementation under x-pack while having a proper API exposed from Core.
Functionally, it has always been an issue, but we worked around by various ways (exposing hapihooks so that security can plug its authc within the http lifecycle directly, having the SOR security wrapper, then the SOR security extension, and other inversions of control such as the
elasticsearch.setUnauthorizedErrorHandler
API to perform reauthentication during ES requests).However, we now have a strong feeling that now would be a good time to finally tackle this technical debt and have security be more directly and fully integrated within Core.
This would unblock a few significant improvements currently blocked by that bad integration of security (e.g the new Kibana DI system that is planning to introduce the concept of user/project scoped services), and is also a prerequisite if we eventually want to go multitenant or multiproject (as the new DI system is also a prerequisite for going into that direction anyway).
It would also cleanup some tech debt, by having a better integration / handling of security within Core. For example, Core would no longer need to expose the HAPI lifecycle hooks directly used by security to plug itself, the http security logic could then remain an implementation detail of Core, that would just directly it's security API (backed up by the implementation provided by security).
Last but not least, it would also allow to address some cyclic dependencies issues between the security plugin and other plugins (issues we started encountering recently), given security consumers would now use Core APIs directly for this, without having to known (or depends on) which plugin provides the underlying implementation.
What would change for public security API
The details will need to be discussed, but the (hopefully not so naive) way I was seeing it was to "simply" use the current security plugin's contract as the public contract that would be exposed by the new
core.security
service.That way, consumers currently using the security plugin would be able to easily transition to using the core service instead.
E.g
would become something like
Given the contract would be the same, we could, during the transition period, simply have the security plugin still expose the same contract, so that the same API would be accessible both via the
security
plugin contract and via thecore.security
service contract.How would that work for internal security APIs
I assume we will also need the
security
plugin to expose/register to Core more than just the public contract we'll re-expose.For example, I guess we will need the security plugin to expose the logic used to perform the http authentication (what's currently being registered via the HAPI hooks)
For that, (the way I currently imagine it at least), I think we could just re-use the concept of internal/public service contracts we've been using in Core since the new platform rewrite: services internally expose
internal
contracts, that are supersets of the public ones. This allows our services to expose APIs that would only be used internally within Core. Then, when injecting the contract to plugins, we build the public version of the contract from the internal one (99% of the time by just removing the internal APIs, the 1% remaining is by injecting the pluginID as an additional parameter only present on the internal version of the contract).E.g
kibana/packages/core/plugins/core-plugins-server-internal/src/plugin_context.ts
Lines 205 to 210 in c713b91
So we would have 2 versions of both the setup and start contracts of the security API:
And the security plugin would register the
private
version of those contracts during thesetup
andstart
phases of the plugin:very naive:
Do we need to do that for the full set of the security plugin's API
We at least need to register/expose
authc
andauthz
that way.Note sure about the rest, but the security team should be able to help here:
license
audit
(audit logging)privilegeDeprecationsService
userProfiles
Questions / things to figure out
Before going further, we need both our teams, @elastic/kibana-security and @elastic/kibana-core, to align on the following questions:
Do we think this initiative makes sense?
Do we think the suggested technical approach described in that issue makes sense (this is probably the most important question)?
Are there parts of the current security plugin contract we can avoid bridging into core (e.g
userProfiles
for example)?What internal security APIs does Core need in addition to just the public security contract?
Phase 1 Tasks DONE
Phase 2 Tasks target End Aug 2024
Phase 3 Tasks target End Oct 2024
Other Tasks: target End December
Tech debt: target End Feb 2025
Important changes to the plan:
July, 2024
The Core Encryption Service has evolved into a much larger initiative than we originally planned for. It will be handled separately.
August, 2024
Scope changes for Phase 2 and 3 based on Platform plugins audit
The text was updated successfully, but these errors were encountered: