feat: enable RBAC by defaulting to PulpServiceAccessPolicy - #1467
feat: enable RBAC by defaulting to PulpServiceAccessPolicy#1467CryptoRodeo wants to merge 1 commit into
Conversation
Reviewer's GuideThe PR switches development and production REST APIs to PulpServiceAccessPolicy so domain-scoped RBAC permissions allow owners to immediately view orphan content, while adding functional tests that validate owner visibility through both content endpoints and deny unrelated organizations access. Sequence diagram for RBAC orphan content visibilitysequenceDiagram
actor Owner as OwningOrg
actor Other as UnrelatedOrg
participant API as ContentAPI
participant Policy as PulpServiceAccessPolicy
participant RBAC as DomainRBAC
participant Content as OrphanContent
Owner->>API: Upload content
API->>RBAC: Check domain membership
RBAC-->>Policy: core.view_content via service.domain_admin
Owner->>API: GET content endpoint
API->>Policy: Check core.view_content
Policy->>Content: List orphan content
Content-->>Owner: Content visible
Other->>API: GET content endpoint
API->>Policy: Check core.view_content
Policy-->>Other: Access denied
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
f2b7880 to
6970ede
Compare
|
Had to update the other tests so CI passes, they used domain based permissions instead of RBAC. This makes the diff larger, but we won't have to dig through Konflux logs to see what failed and if the orphaned content tests passed. |
Switch the default permission class from DomainBasedPermission to PulpServiceAccessPolicy, in both the dev container and prod (clowdapp). This fixes the bug that surfaced when RBAC was first turned on: after pushing content, a user couldn't view it. RBAC scopes content reads to repository membership, so orphan (not-in-a-repo) content was hidden. It now works because domain members hold core.view_content (via service.domain_admin), and the content access policy gates list on that permission instead of scoping by repository. Both the generic /content/ and the typed /content/file/files/ endpoints get the override, since the typed viewset otherwise keeps repository-based queryset scoping. Fix an ordering bug in the service role seeding that the flip exposed. service.domain_admin / service.domain_viewer were populated only on the service app's post_migrate, on the assumption every plugin's permissions already existed by then. They do not: post_migrate is emitted in app order, and plugins that emit after service (file, certguard) had not yet created their permissions, so on a fresh single migrate the role was seeded without file.add_filerepository -- domain owners then got 403 creating a repository. Seed on every plugin's post_migrate again (each rebuild wrapped in a transaction so no partial role is ever observed), so the roles hold the complete permission set once the last plugin has migrated. Add functional tests covering the fix: create a domain, upload orphan content, and confirm the owning org can view it (generic and typed file endpoints) while an unrelated org cannot. Convert the existing functional suite to RBAC so CI stays green with the new default. The DomainBasedPermission-era tests assumed the old backend and started returning 403s once RBAC was on; they now drive the self-service create-domain flow and assert role-based access. A shared conftest seeds template-domain-s3 and provides a create-domain fixture with robust admin-auth teardown. The lightwell content-listing test is removed (superseded by the RBAC content access policy). Co-Authored-By: Claude Opus 4.8 <[email protected]>
6970ede to
18dc380
Compare
|
orphaned content tests have passed ( usr/local/lib/pulp/lib64/python3.11/site-packages/pulp_service/tests/functional/test_content_view_after_upload.py::test_owner_org_views_orphan_content_via_generic_endpoint PASSED [ 39%]
usr/local/lib/pulp/lib64/python3.11/site-packages/pulp_service/tests/functional/test_content_view_after_upload.py::test_owner_org_views_orphan_content_via_typed_file_endpoint PASSED [ 40%]
usr/local/lib/pulp/lib64/python3.11/site-packages/pulp_service/tests/functional/test_content_view_after_upload.py::test_unrelated_org_cannot_view_orphan_content PASSED [ 41%] |
|
@dkliban The tests for viewing orphaned content passed. I wonder what other edge cases we should test, if any others exist? AFAIK it's standard to link content to a repository and the only edge case is orphaned content 🤔 |
Switch the default permission class from DomainBasedPermission to PulpServiceAccessPolicy, in both the dev container and prod (clowdapp).
This fixes the bug that surfaced when RBAC was first turned on: after pushing content, a user couldn't view it. RBAC scopes content reads to repository membership, so orphan (not-in-a-repo) content was hidden. It now works because domain members hold core.view_content (via service.domain_admin), and the content access policy gates list on that permission instead of scoping by repository.
Add functional tests covering the fix: create a domain, upload orphan content, and confirm the owning org can view it (generic and typed file endpoints) while an unrelated org cannot.
Summary by Sourcery
Enable PulpServiceAccessPolicy by default and preserve domain-member access to orphan content across REST content endpoints.
New Features:
Bug Fixes:
Enhancements:
Deployment:
Documentation:
Tests:
Chores: