Update Role management to support Roles V2 Api#68
Open
RovinKYK wants to merge 3 commits intowso2-extensions:masterfrom
Open
Update Role management to support Roles V2 Api#68RovinKYK wants to merge 3 commits intowso2-extensions:masterfrom
RovinKYK wants to merge 3 commits intowso2-extensions:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates role management to support a Roles V2 SCIM API, introduces role-specific export/import transformations (audience + permissions handling), and adds application identifier mapping to support cross-resource reference replacement during role import.
Changes:
- Add Roles V2 API routing (v1 vs v2 endpoint selection) and role payload preprocessing for export/import.
- Track application identifiers during export/import to support reference replacement (e.g., role audience → application).
- Extend constants/metadata (resource type additions, system-role constants, scopes, array identifier metadata).
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| iamctl/pkg/utils/versionUtils.go | Introduces a global flag to switch role base URL behavior for Roles V2. |
| iamctl/pkg/utils/versionRequirements.go | Adds a minimum-version constant intended to gate Roles V2 usage. |
| iamctl/pkg/utils/keywordUtils.go | Adds array identifier support for ROLES. |
| iamctl/pkg/utils/init.go | Extends OAuth scopes with role permissions update scope. |
| iamctl/pkg/utils/constants.go | Adds ORGANIZATIONS resource type, system-role constants, role array identifiers, and role→application reference metadata. |
| iamctl/pkg/utils/commonUtils.go | Changes Contains behavior (case-sensitive vs case-insensitive). |
| iamctl/pkg/utils/apiUtils.go | Changes SendImportRequest to return *http.Response, updates role base URL selection, and adjusts roles GET query params. |
| iamctl/pkg/userStores/import.go | Updates import call site for new SendImportRequest signature. |
| iamctl/pkg/roles/rolesUtils.go | Adds export/import processing for Roles V2 payloads and version-based API selection. |
| iamctl/pkg/roles/import.go | Enables Roles V2 mode during import; updates system-role skipping and role create flow for audience/reference handling. |
| iamctl/pkg/roles/export.go | Enables Roles V2 mode during export; adds role preprocessing for exported payloads. |
| iamctl/pkg/organizations/organizationUtils.go | Adds helper to resolve the “super organization” ID used when importing org-audience roles. |
| iamctl/pkg/identityProviders/import.go | Updates import call site for new SendImportRequest signature. |
| iamctl/pkg/claims/import.go | Updates import call site for new SendImportRequest signature. |
| iamctl/pkg/applications/import.go | Captures import response to derive app ID from Location and populates identifier map for downstream reference replacement. |
| iamctl/pkg/applications/export.go | Populates identifier map during export to support reference replacement. |
Comments suppressed due to low confidence (1)
iamctl/pkg/utils/commonUtils.go:55
Containswas changed from case-insensitive (strings.EqualFold) to case-sensitive (==). This is used byRemoveDeletedLocalResourcesduring export; if the remote resource names differ only by case from the local filenames, this can incorrectly delete local files. If case-insensitive matching is still required, revert tostrings.EqualFold(or document/enforce consistent casing end-to-end).
func Contains(slice []string, item string) bool {
for _, s := range slice {
if s == item {
return true
}
}
return false
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Purpose
The Roles V2 API introduces breaking changes in the roles resource structure that the existing import/export implementation could not handle:
permissionsarray now includes$reffields that contain environment-specific URLs, causing validation errors on import if not stripped.audienceobject includes avaluefield containing an internal UUID (for org-scoped roles) or application ID (for app-scoped roles), which is non-portable across environments.Administrator,Impersonator) introduced in IS 7.0.0 were not excluded from import and deletion, causing errors.This PR adds version-aware handling for the Roles V2 API and implements a reference resolution mechanism for application and organization IDs used in role audience fields.
Related to https://github.com/wso2-enterprise/iam-product-management/issues/662
Goals
/scim2/v2/Roles/) for IS 7.0.0 and above while maintaining backward compatibility with V1$ref,audience.value) on export and resolve them back on importAdministratorandImpersonatorsystem roles from import and deletion on IS 7.0.0+Approach
RolesV2ApiExistsflag in utils, which is set by comparing Roles at the start of export and importprocessExportedRole()to strip$reffrom permission entries and removeaudience.valuebefore writing to fileprocessAudienceForImport()to rehydrateaudience.valueat import time: fororganizationaudience type, callsGetSuperOrganizationId()from the neworganizationspackage; forapplicationaudience type, resolves the name viaReplaceReferences()usingRESOURCE_REFERENCE_METADATASendImportRequest()to return the*http.Responseso callers can extract theLocationheader and capture the newly created resource IDimportApplication,importAppWithCRUD,updateApplication,updateAppWithCRUD) to callAddToIdentifierMap()after success, and export to call it after each successful exportorganizationspackage withGetSuperOrganizationId()fetching via theselfendpointORGANIZATIONSresource type and path routing, andinternal_organization_viewOAuth2 scoperoleArrayIdentifiersso permissions/properties arrays are correctly serialized with stable identifiersAdministratorandImpersonatorwhen V2 API is activeUser stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning