fix: backfill and derive org_id for DomainOrg under RBAC - #1487
CryptoRodeo wants to merge 5 commits into
Conversation
Reviewer's GuideThis PR enables RBAC by default, completes service-role initialization, and fixes organization ownership propagation for domains both historically and at creation time. It restores org-member access by backfilling or deriving org_id and granting the owning org its domain roles, while extending content policies and functional coverage to preserve orphan-content visibility and validate the updated authorization semantics. Sequence diagram for deriving org_id during domain creationsequenceDiagram
participant User
participant DomainAPI
participant post_create_domain
participant UserGroups
participant DomainOrg
participant GroupRole
User->>DomainAPI: Create domain without internal.org_id
DomainAPI->>post_create_domain: post_create_domain
post_create_domain->>UserGroups: _derive_org_id_from_user
UserGroups-->>post_create_domain: Exactly one rh-org-<org_id> membership
post_create_domain->>DomainOrg: Save org_id
post_create_domain->>GroupRole: _assign_domain_roles
GroupRole-->>User: Org members gain domain access
Flow diagram for historical DomainOrg org_id backfillflowchart TD
A[Migration 0022] --> B[Load DomainOrg records]
B --> C{org_id already set?}
C -->|Yes| D[Use stored org_id]
C -->|No| E[_derive_org_id]
E --> F{Exactly one org across team members?}
F -->|Yes| G[Save derived org_id]
F -->|No| H[Skip and log warning]
D --> I[Create or get rh-org-<org_id> group]
G --> I
I --> J[_assign_pair]
J --> K[Grant core.domain_owner and service.domain_admin]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
e59ff36 to
0ef7f79
Compare
Reviewer guide — where to focusThis branch is two commits: a shared RBAC-enablement commit (identical to the first commit of companion PR #1486) and the actual fix. Please concentrate here: The fix (review closely):
Skim only — the shared RBAC-enablement commit ("test: enable RBAC as the default backend…"):
|
…ssion fixes The domain-permission fixes only manifest when RBAC (PulpServiceAccessPolicy) is the active authorization backend rather than DomainBasedPermission. Switch the default so the functional suite runs under RBAC, converting the existing tests to the self-service create-domain flow accordingly. Also seed service.domain_admin/service.domain_viewer on every plugin's post_migrate (each rebuild wrapped in a transaction) so the roles hold the complete permission set once the last plugin has migrated; previously they were seeded only on the service app's post_migrate, before later plugins (file, certguard) had created their permissions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0ef7f79 to
0130a63
Compare
|
@dkliban potential fix for backfilling the |
Switch PulpServiceAccessPolicy to AccessPolicyFromDB and move the domain-create ContextVar setup into CreateDomainView/MigrateDomainView via set_domain_create_context() (PULP-2120), dropping the now-inert settings.ACCESS_POLICIES block and DomainBasedPermission from those views. This puts the branch on 2120's DB-backed RBAC, under which the org_id gap below is fixed. Org members were locked out (404 reads, 400 uploads) of domains whose rh-org-<org_id> group held no roles -- caused by DomainOrg rows with a null org_id, whose creation skipped the org group's role grant. The upload 400 is downstream of the same scope-out: the push client's idempotency pre-check reads a role-scoped content list, is scoped out to empty, and re-uploads a dependency already in the index, which pulp_python's duplicate guard rejects. Migration 0022 repairs existing rows, deriving the org from the team group's members and granting rh-org-<org_id> the missing roles. Domain creation now also derives org_id from the creating user's rh-org-<org_id> membership when the request omits internal.org_id, so no new null rows are produced. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0130a63 to
8d3b059
Compare
|
@dkliban I added a simulation instruction doc (simulate the scenarios that the Calunga team was experiencing) and a verdict doc: Verdict (TL;DR):
The anonymous-read gap ("Fix A") is closed by #1486 ( See simulation-results-public-trusted-libraries.md for the verdict, simulation-procedure-public-trusted-libraries.md to run it: 8d3b059 |
A re-runnable simulation (pub_trusted_sim.py) plus procedure and results docs for the production public-trusted-libraries 404/400 incident, run against PULP-2120 RBAC with this branch's org_id fix. Confirms the fix restores Layer 1 reads (404 -> 200) and the failed Konflux upload (the 400 duplicate-guard chain), and notes what it does not fix (anonymous scoped reads; the fromager simple/ cache-miss 404s, which aren't RBAC). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Bryan ramos <bramos@redhat.com>
8d3b059 to
d3fd57e
Compare
53e3876 moved this branch to AccessPolicyFromDB and dropped settings.ACCESS_POLICIES, but two tests still asserted the settings-based design and failed. Assert AccessPolicyFromDB and drop the obsolete content-override settings test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Read-only `pulpcore-manager domainorg_backfill_report` command that previews which missing-org_id DomainOrg rows migration 0022 will backfill vs skip (and why), so operators can review and remediate the skip-set before enabling RBAC. Derivation is extracted into a shared `domainorg_backfill` helper that 0022 now imports, keeping the report and the migration in lock-step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Bryan ramos <bramos@redhat.com>
|
Added a command that will let us see which domain orgs get backfilled and which were skipped. This should make it easier to see what was skipped and why: 8a16b81 |
Issue
Under RBAC, members of an org that owns a domain were locked out — 404 on reads, 400 on uploads — when the domain's
rh-org-<org_id>group held no roles. This happened forDomainOrgrows with a nullorg_id: their create request carried nointernal.org_id, so the org group's role grant was skipped.Fix
rh-org-<org_id>the missing roles.org_idfrom the creating user'srh-org-<org_id>membership when the request omitsinternal.org_id(only when they belong to exactly one such group), so no new null-org_iddomains are produced.Testing
Reproducing and verifying the lock-out requires RBAC active (
PulpServiceAccessPolicy); that default is enabled in the shared base commit. Functional tests cover the historical backfill, create-without-internal.org_id, and org-member access; a unit test covers the derive helper.Companion PR: #1486 (orphan-content fix / RBAC enablement).
🤖 Generated with Claude Code
Summary by Sourcery
Restore organization-member access to DomainOrg resources under RBAC by backfilling missing organization ownership and deriving organization IDs for new domains.
Bug Fixes:
Enhancements:
Deployment:
Documentation:
Tests:
Chores: