-
Notifications
You must be signed in to change notification settings - Fork 147
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
Realm export normalization #818
base: main
Are you sure you want to change the base?
Conversation
76dadc9
to
b2e94ff
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #818 +/- ##
=============================================
- Coverage 95.46% 83.08% -12.39%
- Complexity 1302 1339 +37
=============================================
Files 76 96 +20
Lines 4213 5037 +824
Branches 467 621 +154
=============================================
+ Hits 4022 4185 +163
- Misses 94 755 +661
Partials 97 97 ☔ View full report in Codecov by Sentry. |
a5b9b3b
to
a3b0930
Compare
0c6cd95
to
ea474cd
Compare
Would it be possible via some kind of diffing to keep params for fields with env var substitutions? Example: {
"realm": "my-realm",
"smtpServer": {
"replyToDisplayName": "$(env:SMTP_REPLY_TO_DISPLAYNAME)",
"port": "$(env:SMTP_PORT)",
"host": "$(env:SMTP_HOST)",
"replyTo": "$(env:SMTP_REPLY_TO)",
"from": "$(env:SMTP_FROM)",
"fromDisplayName": "$(env:SMTP_FROM_DISPLAY_NAME)",
"envelopeFrom": "$(env:SMTP_ENVELOPE_FROM)"
}, When I import this realm, make changes and export the realm again I'd like to keep the params for SMTP instead of having to replace the actual values from the export with the parameters again. I have no idea what that means regarding the implementation. Just as an idea to make working with the huge JSON-Files easier :) |
e4b30b6
to
f77da87
Compare
@manuschillerdev I think that might be a valuable future extension of this feature! In theory, one could provide a map of "reverse injections" where you specify something like "When the field However, I think I'd like to get the base idea of this PR (minimize a realm.json acquired from a full Keycloak realm export) done first, and then build additional features on top of that |
Always include the protocol attribute for clarity. Remove SAML-attributes if the client is OIDC.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
@jonasvoelcker what do you think. Can we look deeper into this feature? |
as mentioned in one of the other merge requests I am currently not available for any work on community things. Our project requires other things and additionally I am about to get a second child in a few days so I can't invest any freetime 😉 Best Regards |
I currently cannot spare time to work on this PR further; I switched to another employer and we're not using the feature here. But if any of the people trying to use the feature are willing to take over development on this PR, feel free to do so; I place the changes I've made here in the public domain and anyone is free to use them to continue development of this feature with my changes as a base |
Maybe talk about the topic in Vienna tomorrow? |
I just gave this a spin and aligned the changes from this branch with the latest keycloak-config-cli version in main I did only minimal changes to get it working again. I think this needs some refactoring (config property sharing, use profiles for conditional beans instead of propertys, revise naming, etc.) and I think we could (and should) extend this to support a "realm export" from an "live" realm. Note that the normalization does not support some features of KC24/25, e.g. organizations etc. The build works again I could successfully "normalize" a realm export generated from KC 25.0.5. |
@thomasdarimont would you send a pull request to sonOfRa:feature/export-diff-yaml or to adorsys:main? |
This is a squash of the commits from multiple repositories: Original PR by sonOfRa: adorsys#818 Adaptations by thomasdarimont: https://github.com/thomasdarimont/keycloak-config-cli/tree/feature/realm-normalization Fixes adorsys#799 Co-authored-by: Simon Levermann <[email protected]> Signed-off-by: Thomas Darimont <[email protected]>
This is a squash of the commits from multiple repositories: Original PR by sonOfRa: adorsys#818 Adaptations by thomasdarimont: https://github.com/thomasdarimont/keycloak-config-cli/tree/feature/realm-normalization Fixes adorsys#799 Co-authored-by: Simon Levermann <[email protected]> Signed-off-by: Thomas Darimont <[email protected]>
@francis-pouatcha I rebased this branch and adapted it to the current main. I had to squash most commits to ease the rebase. I added @sonOfRa as coauthor of the new PR. See: #1207 |
What this PR does / why we need it:
When trying to move an existing keycloak installation with no configuration management to keycloak-config-cli, it can be hard to figure out which parts of the realm export are actually needed to reproduce the state when re-importing the configuration.
This PR can serve as a (partial) solution to this problem, by taking a realm export from a certain version of Keycloak, comparing it against a reference export of a "barebones" Keycloak realm from the same version, and then creating a yml (or JSON) file that only contains changes that are actually required.
This PR will not be a complete solution that works for all cases, but it will supply an at least somewhat minimized view of clients and some related settings, which can then easily be merged with a full export in order to get a smaller view of the file. Support for additional parts (identity providers, authentication flows, etc) can be added in later steps to improve this export.
This PR includes a "mode switch" that allows users to switch between IMPORT and NORMALIZE modes using the property
run.operation=NORMALIZE
. IMPORT is the default, and is used when no option is supplied by the user.This PR includes an upgrade to Spring Boot 2.7.5, which contains a fix for spring-projects/spring-boot#32559. The
@DefaultValue
annotation is used to move configuration from the default application.properties file directly to the code. This is needed so that only the needed configurations for the chosen mode (IMPORT or NORMALIZE) are activated.Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #799Special notes for your reviewer:
A custom properties
application-normalize-dev.properties
file for testing the export functionality was added. Activating this profile enables normalization mode, and expects an input realm to be present at the top-level exports directoryThe file
in/realm.json
will be imported, and the fileout/demo1234.yaml
is created by the process, where the realm name of the input realm isdemo1234
Run the application with the
normalize-dev
profile active to normalize a given realm.The configuration parameter
normalization.output-format
can be used to switch between YAML (the default, if no option is given) and JSON output.PR Readiness Checklist:
Complete these before marking the PR as
ready to review
:CHANGELOG.md
release notes have been updated to reflect any significant (and particularly user-facing) changes introduced by this PR