-
Notifications
You must be signed in to change notification settings - Fork 173
feature/Fine-Grained Admin Permissions (FGAP) V2 compatibility with Keycloak 26.2.0+ #1322
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
base: main
Are you sure you want to change the base?
feature/Fine-Grained Admin Permissions (FGAP) V2 compatibility with Keycloak 26.2.0+ #1322
Conversation
3a15cb8 to
804338a
Compare
…hema() and use simple exception class names
These tests work for all KC versions, the annotations were added incorrectly
…date tests for realm management authorization
…date tests for realm management authorization
|
@AssahBismarkabah maybe why you test are failing check contrib/custom-representations/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java change to public void setLoginTheme(String loginTheme) { then see if test are green then |
Hello @jwklijnsma, thanks for the proposal, i am currently implementing a client-side validation in RealmRepository so bad input causes an explicit exception in the CLI before the request reaches Keycloak. |
Thendo20
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, FGAP V1 is skipped with warnings and FGAP V2 config with authorizationSchema is imported successfully tested with Keycloak version 26.3.
|
I just tested this with Keycloak 26.4.2 and I wasn't able to import the example from #1305 (comment) Yields: |
src/main/java/de/adorsys/keycloak/config/service/ClientAuthorizationImportService.java
Outdated
Show resolved
Hide resolved
preserving authorization settings import.
|
Thanks for developing this feature ! :) I tested your branch I noticed that I was not able to update an existing Policy in the client "admin-permissions" (because in FGAP v2 we no longer need to use realm-management). I received the error "policy already exists". Because, when I created an issue on Keycloak about this "unkwown_error", you'll find more details there : The keycloak team said that this is the expected behavior because the Regarding You can reproduce the problem with the following steps:
You will get a 409 Conflict. |
|
Thank you for the detailed testing and for opening the issue on Keycloak. Based on my investigation, the admin-permissions client in FGAP V2 is system-managed and its authorization settings cannot be imported via configuration files. This is by design. When adminPermissionsEnabled: true is set at the realm level, Keycloak automatically creates the client with a predefined schema (AdminPermissionsSchema.java lines 279-313. The authorization settings (resources, scopes, policies) are then managed exclusively through the Admin Console UI or direct REST API calls after realm creation. The 409 Conflict you're experiencing occurs because our code attempts to import authorization settings for a client that Keycloak intentionally blocks from external modification (returning 400 with "unknown_error" per AdminPermissionsSchema.java line 202-206). Keycloak's own import logic explicitly skips this client (DefaultExportImportManager.java lines 578-584. The fix is to align with Keycloak's behavior: skip authorization import entirely for the admin-permissions client when FGAP V2 is active. Users should remove this client from their import configurations and rely on the realm-level adminPermissionsEnabled flag. Authorization policies must then be managed post-import through the Admin Console or REST API, not through declarative configuration files. I'll implement this fix along with updated documentation clarifying that FGAP V2 authorization settings. |
imo it would still be great to be able to configure the policies with config-cli - to automate and ensure their configuration, instead of manually creating them which could lead to mistakes. Unfortunately it looks like the migration after all is not as easy as initially thought... |
Agree, @antikalk. Unfortunately, with FGAP v2 the admin-permissions client is system‑managed and the relevant Admin REST endpoints are intentionally guarded, so full declarative management via config‑cli isn’t feasible without an upstream API change in Keycloak |
|
|
I've implemented the changes to resolve the FGAP V2 409 Conflict issue. |
|
any update when this will be release ? |
|
We faced the same issue when trying to upgrading keycloak from version 26.0.5 to 26.4.7, so we ended up upgrading it version 26.1.0 which is the latest version supported at this point in time. but would be very interested in knowing the timeline for releasing this feature so we plan the next upgrade. |
|
Hello and a happy new year to everyone 🎉 Is there any update about this PR? Next Keycloak version is around the corner. |



What this PR does / why we need it:
This PR fixes Fine-Grained Admin Permissions (FGAP) V2 compatibility issues with Keycloak 26.2.0+ by implementing graceful error handling for HTTP 501 responses and maintaining backward compatibility with older Keycloak versions.
Key Changes:
@DisabledIfSystemPropertyannotations to disable FGAP V1 tests for Keycloak 26.2.0+ClientRepositoryfor HTTP 501 responsespom.xml###Which issue this PR fixes:
Fixes #1305 - HTTP 501 Not Implemented with fine-grained permissions on Keycloak 26.3.0
Special notes for your reviewer:
The core issue was not that the CLI uses V1 APIs (it correctly uses V2 APIs), but that FGAP V2 must be enabled per realm even when enabled at the server level. The HTTP 501 error occurs when FGAP V2 is disabled for a specific realm, which is expected behavior.
Testing:
mvn clean install -Dkeycloak.version=26.3.3)PR Readiness Checklist:
Complete these before marking the PR as
ready to review:CHANGELOG.mdrelease notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR