feat(rest-api): add Provider-related capabilities to templated iPXE OS and make visible to tenants#4067
feat(rest-api): add Provider-related capabilities to templated iPXE OS and make visible to tenants#4067pbreton wants to merge 6 commits into
Conversation
Add OperatingSystemFilterInput.ProviderOSVisibleAtSiteIDs and rework the OperatingSystemDAO.GetAll owner filtering into an explicit switch covering provider-only, tenant-only, dual-role, and tenant-admin views. The tenant-admin view surfaces provider-owned OSes only when they are associated with one of the tenant's accessible sites. Foundation for provider-admin OS management (PR 4.2/4.3).
Switch the OperatingSystem GetAll and Get handlers to authorize both provider and tenant admins via IsProviderOrTenant, and apply role-based visibility: - Provider admin lists/reads only provider-owned Operating Systems. - Tenant admin additionally sees provider-owned Operating Systems that are associated with a Site the tenant can access (via the new ProviderOSVisibleAtSiteIDs filter). - Dual-role callers see the union. Adds the getTenantSiteIDs helper, handler visibility tests, and restores the provider-admin path in the OpenAPI get-all/get descriptions. Create/Update/ Delete remain tenant-scoped and are handled in a follow-up PR.
Switch the OperatingSystem Create, Update, and Delete handlers to authorize both provider and tenant admins via IsProviderOrTenant and enforce ownership: - Provider admin may only create Provider-owned Operating Systems of type Templated iPXE; ownership (infrastructure_provider_id vs tenant_id) is derived from the caller's role. - Update/Delete require the caller to own the Operating System for their role; cross-owner mutations are rejected with 403. - Name uniqueness and site resolution are scoped to the owner (provider sites for provider-owned, tenant-accessible sites for tenant-owned). Adds write-path ownership tests, updates the two existing tenant-mismatch cases from 400 to 403 to reflect the ownership model, drops the now-unused auth import, and updates the OpenAPI create description for the provider path.
Fold operatingsystem_ownership_test.go and operatingsystem_visibility_test.go into operatingsystem_test.go (handler), and operatingsystem_providervisibility_test.go into operatingsystem_test.go (db model), following the one-test-file-per-type convention. No test logic changes.
Signed-off-by: Patrice Breton <pbreton@nvidia.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughOperating System handlers now derive authorization from provider and tenant roles, persist provider- or tenant-owned records, enforce site-scoped visibility, and authorize updates and deletes by ownership. DAO filters, tests, and OpenAPI descriptions reflect the new behavior. ChangesOperating System access control
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant OperatingSystemHandler
participant TenantSite
participant OperatingSystemSQLDAO
Caller->>OperatingSystemHandler: request Operating System access
OperatingSystemHandler->>TenantSite: resolve tenant-accessible sites
OperatingSystemHandler->>OperatingSystemSQLDAO: apply ownership and site visibility filters
OperatingSystemSQLDAO-->>OperatingSystemHandler: return authorized Operating Systems
OperatingSystemHandler-->>Caller: response or forbidden status
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
🌿 Preview your docs: https://nvidia-preview-pull-request-4067.docs.buildwithfern.com/infra-controller |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-07-24 02:27:00 UTC | Commit: d0425e8 |
Send tenant_organization_id only for tenant-owned Operating Systems so provider-owned definitions remain provider-owned when synchronized to Core. Clarify reconciliation ownership and cover both request variants.
This PR continues implementation of Templated iPXE Operating System in NICo REST API.
Specifically it adds Providers capabilities regarding Templated iPXE Operating System and makes Providers-created OS visible to Tenants.
Related issues
Builds on #3569.
Type of Change
Breaking Changes
Testing