Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
An invalid membershipType escapes the partial-import error handler and produces HTTP 500 instead of the expected 400 response.
1 open issue
What changed in this PR
Adds organization definitions to Keycloak’s partial import, completing the partial-export support from #54274. Organizations can be copied without members, while existing organizations are protected from destructive overwrites.
Changes:
- Adds feature-gated organization imports with alias-based conflict detection and fresh organization/group IDs.
- Adds organization selection and result labels to the Admin Console.
- Adds integration and UI tests, plus documentation of import policies and upgrade behavior.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/admin/partialimport/PartialImportOrganizationTest.java |
Tests imports, conflict policies, validation, and member preservation. |
tests/base/src/test/java/org/keycloak/tests/admin/partialimport/PartialImportOrganizationDisabledTest.java |
Tests imports with the organization feature disabled. |
services/src/main/java/org/keycloak/partialimport/PartialImportManager.java |
Registers the organization handler when enabled. |
services/src/main/java/org/keycloak/partialimport/OrganizationsPartialImport.java |
Implements organization partial-import handling. |
server-spi-private/src/main/java/org/keycloak/partialimport/ResourceType.java |
Adds organization result and event metadata. |
server-spi-private/src/main/java/org/keycloak/models/utils/RepresentationToModel.java |
Hosts shared organization import logic. |
model/storage-private/src/main/java/org/keycloak/storage/datastore/DefaultExportImportManager.java |
Delegates definition imports while retaining member handling. |
js/libs/keycloak-admin-client/src/defs/realmRepresentation.ts |
Adds organization definitions to the realm type. |
js/apps/admin-ui/test/utils/files/organization-only.json |
Provides an organization import fixture. |
js/apps/admin-ui/test/realm-settings/import.ts |
Adds an organization-selection helper. |
js/apps/admin-ui/test/realm-settings/import.spec.ts |
Tests organization import through the console. |
js/apps/admin-ui/src/realm-settings/PartialImport.tsx |
Adds gated organization selection and result labels. |
docs/guides/server/importExport.adoc |
Documents organization imports and overwrite restrictions. |
docs/documentation/upgrading/topics/changes/changes-27_0_0.adoc |
Explains changed behavior for exported-realm imports. |
core/src/main/java/org/keycloak/representations/idm/PartialImportRepresentation.java |
Adds organizations to the import request model. |
Review effort: Balanced
94f8ad8 to
f6208a4
Compare
|
|
|
@Hakaou thank you! Could you rebase please? The branch caught a conflict. |
f6208a4 to
8599211
Compare
|
The status check fails only on SAST Check. It reports |
8599211 to
f82e129
Compare
f82e129 to
0fbf263
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A missing client referenced by exported organization group role mappings triggers HTTP 500 rather than an actionable 400 because the exception bypasses partial-import validation handling.
1 open issue
1 resolved since last review
Review effort: Balanced
0fbf263 to
f8b005f
Compare
f8b005f to
a9caba2
Compare
|
Hi @pedroigor, could you review this PR when you have time? All checks pass on a9caba2. |
The partial import reads the organizations of the file when organizations are enabled for the realm. It creates them after the identity providers, with new ids and without their members. An existing organization is found by its alias. It can be skipped or can fail the import. Overwrite is refused during preparation, because removing an organization deletes the accounts of its managed members. RepresentationToModel now holds the creation of an organization from its representation. The full import and the partial import share it. A role of a missing client in an organization group is now a validation error. The Admin Console partial import dialog offers the organizations of the file under the same condition. The admin client representation of an organization now has its groups. Closes keycloak#54343 Signed-off-by: Hakaou <hakaou@fr.scc.com>
Head branch was pushed to by a user without write access
a9caba2 to
6877b0c
Compare
|
Thanks @pedroigor. Rebased on main, no other change. |
|
Hi @pedroigor, Store Model Tests failed on this run. In the |

Follow-up to #54274. This PR supports skip and fail only, as discussed with @vramik in #54343.
Decisions:
prepare(), before any handler removes a resource. Removing an organization deletes the accounts of its managed members.OrganizationProvider.create()does.Organizations.isEnabled(session)is true. With theorganizationfeature disabled, or with organizations disabled for the realm, the organizations of the file are ignored. The Admin Console dialog offers them under the same condition.DefaultExportImportManagertoRepresentationToModel.importOrganization(), next toimportGroup(). The full import calls it and then adds the members. A role of a missing client in an organization group now throws aModelValidationExceptioninstead of aRuntimeException. The partial import and the creation of a realm then return a 400 that names the client instead of a 500.FAILandOVERWRITEwhen one of them already exists. The upgrading guide has an entry.Not in this PR:
orgIdsetting. They are not linked to the imported organization.An AI agent wrote the code and the tests under my direction.
Closes #54343