fix: exclude org-scoped roles from tenant export by filtering type='tenant' - #1453
Draft
harshithRai wants to merge 3 commits into
Draft
fix: exclude org-scoped roles from tenant export by filtering type='tenant'#1453harshithRai wants to merge 3 commits into
harshithRai wants to merge 3 commits into
Conversation
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.
🔧 Changes
Excludes organization-scoped roles from the tenant roles export/import flow.
When the
api2_org_level_roles_eafeature flag is enabled on a tenant,GET /api/v2/rolesstarts returning organization-scoped roles (those withtype: "organization") mixed in with tenant-level roles. The deploy CLI treats every listed role as tenant configuration, so without this change it would:tenant.yaml/roles/*.json)AUTH0_ALLOW_DELETEis enabled, since they are not present in the local config filesThe roles handler now passes
type: 'tenant'toroles.listso only tenant-level roles are managed. Org-scoped roles are managed within an organization context and are intentionally out of scope here.The endpoint stays on offset pagination. Although the API spec moves
/rolesto checkpoint pagination, node-auth0 deliberately kept offset pagination for/rolesfor backward compatibility (checkpoint is deferred to a future major SDK), sopaginate: trueis retained rather than switching to checkpoint.Bumps
auth0to^6.2.0, which adds thetypefilter parameter and includestypeon theRoleresponse.Shape change: exported roles now include a
typefield (returned by the 6.2.0Roleresponse). This is additive and backward compatible on import. Role IDs are stripped on export as before, so noidis written.YAML (
tenant.yaml):JSON(
roles/Test Role.json):{ "name": "Test Role", "description": "Role to reproduce the error", "type": "tenant", "permissions": [] }Migration note
Configs exported while the
api2_org_level_roles_eaflag was on may contain organization-scoped roles. After upgrading, these are no longer read from the tenant, so they appear local-only and would be recreated as tenant roles on deploy. Affected roles should be removed from local config after a re-export.🔬 Testing
Unit tests:
test/tools/auth0/handlers/roles.tests.jsassertsroles.listis called withtype: 'tenant'.Manual end-to-end against a live tenant with
api2_org_level_roles_eaenabled:POST /api/v2/roleswithtype: "organization"and anowner_id).GET /api/v2/rolesreturns it (3 roles) whileGET /api/v2/roles?type=tenantdoes not (2 roles).exportin both YAML and directory formats: the org-scoped role was excluded from the output; only tenant roles were written, each with atypefield and noid.import --dry-runwith the org role present on the tenant: the proposed-changes plan was empty, confirming the org role is not pulled into the baseline and not flagged for deletion (even withAUTH0_ALLOW_DELETEenabled).📝 Checklist