Repository navigation
Conversation
Fine-grained admin permissions can reference a specific organization, which is resolved when the admin permissions client's authorization settings are imported. Organizations were imported last, so such a permission failed with "Resource [...] does not exist for type [Organizations]". Organizations are now imported right after users, and before the authorization settings. Closes keycloak#55160 Signed-off-by: Naitik Singh <teamopyonick@gmail.com>
Covers an organization with a linked identity provider and a managed member with a federated identity, referenced by a fine-grained admin permission, to make sure the new import order keeps these working. Closes keycloak#55160 Signed-off-by: Naitik Singh <teamopyonick@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55160
The bug: Importing a realm export fails if it has a fine-grained admin permission (FGAP v2) on one specific organization. The import stops with
Resource [<org-id>] does not exist for type [Organizations]. InDefaultExportImportManager.importRealm, the authorization settings of the admin permissions client were imported before the organizations, which came last. When that permission is imported,AdminPermissionsSchemalooks up the organization by ID, and it does not exist yet.The fix: Organizations are now imported right after users and before the authorization settings. They have to come after users because organization members are looked up by username. Nothing else moves. Nothing reacts to organization creation, so the earlier position does not change behavior. The deprecated path that skips user-dependent data (
userImport == null) still imports organizations, and its authorization settings are imported afterimportRealmreturns, as before.Testing: I added
OrganizationFgapImportTest. It creates an organization and a VIEW permission on that one organization, exports the realm on the server, deletes the realm, and imports the export again. Then it checks that the organization and the permission (with the organization as its resource) are there. Before the fix it fails with the exact error from the issue; with the fix it passes.OrganizationResourceTypeEvaluationTest(11),OrganizationTest(39) andImportTest(6) also pass. InExportImportTest, the directory and single-file export/import round trips pass. Six other tests in that class could not run on my Windows machine because the checkout path has a space, so their JSON fixtures were not found (FileNotFoundExceptionon a%20path) before any import ran. They do not depend on this change, and CI should cover them.