KEYCLOAK-15773 Enable admin endpoints and admin-console via Feature flags#8369
Conversation
b79bd39 to
3421c57
Compare
There was a problem hiding this comment.
Wonder if we need ability to disable API and UI separately, or if we could just have a single ADMIN feature?
As a side-note the feature stuff is becoming a bit of a mess, and could do with a bit of improving/enhancing. Perhaps we could do a breaking change here on both names and how they are enabled/disabled in the Quarkus distribution. @pedroigor
|
I'm not 100% sure about this. At the same time, I understand the motivation and I agree that it helps to keep this form of access control within the server boundaries rather than forcing people to configure their proxies. That said, I'm not against it if there is a consensus and demand from the community that it is going to make life easier when deploying and managing Keycloak in production. W.r.t. to the proposed changes, I think it makes sense to have separate settings for controlling access to both console and API. I'm also wondering how the admin console feature somewhat here overlaps with the Perhaps a more generic solution would be to have a JAX-RS filter that intercepts requests and checks whether an endpoint is enabled or not. It should help to avoid boilerplate code we have here as well as serve as a central point for managing access to whatever API we expose. Endpoints could be annotated with In Dist.X, we are currently managing features like: However, for this one, I think it would make more sense to provide specific configuration options like: Not necessarily related to this problem, but perhaps we should also have a |
Let's think a bit broader about this than just the admin console, as the "--no-admin-console" doesn't make much sense to me. Ideally it would be very easy to disable capabilities you don't need from Keycloak. Don't want LDAP sure, just remove it. Don't want SAML, again sure just remove it. Want to have background service (like cleanup jobs) run in a separate set of nodes that don't handle request, again just do that. Now if we align features/providers a bit more, and make it easy to define what you want to include in a consistent way, then we have an easy way to do that with Quarkus right, which basically removes features/providers completely from the runtime. |
It is an attempt to make this setting more explicit when deploying into production rather than having to configure features (more verbose). Similarly to what we are planning for the hostname provider.
Sure, and that is related to the long-term modularization story we have been discussing. For now, we can't do much and my suggestions were based on what we have today. Dist.X can not help much because we have some constraints in our codebase that block us from properly adding/removing features. For instance, if you remove LDAP you also need to remove UIs, mappers, etc, all that spread in different modules. If we had features (and their providers) self-contained, we could definitely have something in Dist.X. For instance, we would have a very basic distribution with only the core bits. Additional stuff like the LDAP, SAML, etc, would be deployed similarly to what we are doing for custom providers. With the possibility to fetch these extensions from some marketplace, etc. That would be awesome, ideed. |
My point there was more in terms on how Keycloak.X should allow users to enable/disable features/providers. We don't want to make that into an "API" that has to change in the future though, and I'm pretty much sure we don't want a "--no-" option ;) Some random thoughts/ideas (I'm only thinking about how it would be configured from Keycloak.X, not the implementation/improvements there, as for now we can just wire it up to what we currently have):
Let's for arguments sake that we call these capabilities not to conflict with existing things like features/spis/providers. Then we can build some hierarchy of capabilites, so something like:
Then instead of listing "providers" with kc you'd list capabilities, which could behind the scenes be just a profile feature, a complete spi, or a provider of an spi. It could also align with setting the default provider, or with the high-level "type" of something we have, so some ideas on how this could look like in Keycloak.X: Or with a separate profile properties file or whatever: myprofile |
|
@thomasdarimont sorry for taking you're simple PR and making it into a complex discussion ;) |
|
@stianst I see where you a heading to. As I mentioned before, the example you gave for Let us discuss that in a separate discussion, I'm going to create one. |
Thanks |
3421c57 to
99db6fb
Compare
|
Would be nice to get this in. @thomasdarimont are you still interested in this one? With regards to how to disable it that should just be done like we're disabling other features (https://www.keycloak.org/server/features#_disabling_features). For the names of the features "ADMIN_API" is fine as that aligns with ACCOUNT_API, but not sure about ADMIN_CONSOLE, as we have ADMIN2 to enable the new admin console. Perhaps what we should do is add "ADMIN" feature, that enables/disables the old admin console. This should just be marked as deprecated straight away. Update so that it doesn't fallback on the old admin console if ADMIN2 is not enabled. Essentially that'd mean to use the old admin console you'd need to run:
Or, if you want to disable the admin console fully you'd just run:
|
99db6fb to
bb468f2
Compare
|
@stianst I just rebased this branch and applied the suggested changes. |
bb468f2 to
89cfba9
Compare
89cfba9 to
bd33611
Compare
|
I'm happy with the PR in it's current state. Let's stop nit-picking this one to death ;) |
|
/rerun |
|
@thomasdarimont Looks like there are some related failures. Could you please check them out? |
e79b0af to
1a77225
Compare
|
I just rebased this branch on current main, squashed the commits and adapted the failing tests in |
|
/rerun |
|
@thomasdarimont some tests are failing, which looks like real issues rather than the usual unstable tests. At least one thing I noticed is that adminConsoleEnabled is not added to https://github.com/keycloak/keycloak/blob/main/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/services/resources/QuarkusWelcomeResource.java. Not sure why, but there's a different class that exposes the welcome-page on Quarkus. |
|
@stianst I adjusted the QuarkusWelcomeResource accordingly. I just gave this a try: With admin console and admin-api disabled With invalid configurations like
|
There was a problem hiding this comment.
Note that we currently cannot use Profile.isFeatureEnabled(..) here since this currently leads to an infinite recusrsion, that ends with a StackOverFlowError.
|
@thomasdarimont Quarkus Test failures are basically about the help message. if you run |
…a feature flags Inline profile checks for enabled admin-console to avoid issues during static initialization with quarkus. Potentially Re-enable admin-api feature if admin-console is enabled via the admin/admin2 feature flag. Add legacy admin console as deprecated feature flag Throw exception if admin-api feature is disabled but admin-console is enabled Adapt ProfileTest Consider adminConsoleEnabled flag in QuarkusWelcomeResource Fix check for Admin-Console / Admin-API feature dependency. Add new features to approved help output files Co-authored-by: Stian Thorgersen <[email protected]> Signed-off-by: Thomas Darimont <[email protected]>
bbf8e62 to
0593adf
Compare
|
@pedroigor thanks for the hint! I just fixed the HelpCommandTest, rebased the branch and squashed the commits into a single one. |
|
@thomasdarimont Tks. |
|
So if I want to keep our admin dashboard separate from the public path through a reverse proxy, I'd somehow configure a subset of keycloak instances to enable the administration dashboard and some of them to disable it? Then I would route the public facing path to the keycloak instances that have the admin dashboard disabled? We are using the codecentric chart. Maybe the keycloak operator has better configuration to be able to do this? |
This PR adds the ability to control the availability of the admin-api endpoints and admin-console via feature flags.
This enables administrators to configure the
/adminendpoint's availability, including the admin REST API and the admin-console per instance.This allows admins to have public-facing
workerinstances and internaladmininstances, which reduces the attack surface for the public-facing Keycloak instances.New feature flags:
ADMIN_API
Controls whether the
AdminRootJAX-RS resource are served via the /admin pathADMIN
Controls whether the legacy
admin-consoleendpoints are served.This flag is marked as deprecated and will be removed once the legacy admin-console is removed.
Note that the existing ADMIN2 feature flag can also be used to control the availability of the "new" admin-console.
To run a Keycloak instance without admin-api and admin-console use:
To run a Keycloak instance without admin-console use: