fix(helm-prereqs): default nico-cli-client PKI role OU to the role name, not "Invalid"#4040
fix(helm-prereqs): default nico-cli-client PKI role OU to the role name, not "Invalid"#4040shayan1995 wants to merge 1 commit into
Conversation
…me, not "Invalid" The nico-prereqs vault-pki-config job created the nicoca nico-cli-client PKI role with ou="Invalid" by default, stamping OU=Invalid into every operator CLI client cert. On affected clusters every carbide-admin-cli call returned a bare HTTP 403 (issue NVIDIA#3662). The "Invalid" default was copied from the ForgeAdminCLI principal in internal_rbac_rules.rs on the belief that the cert OU had to match it. It does not: Principal::is_proper_subset_of matches any ExternalUser against any ExternalUser without comparing the group, so that constant is documentation-only. What actually gates admin-CLI authorization is the cert mapping to an ExternalUser at all — i.e. the issuing CA's CN being listed in nico-api auth.additional_issuer_cns. - helm-prereqs/values.yaml: ou defaults to "" (falls back to the role name, nico-cli-client, via the template's existing default chain) and the comment now explains the real authorization contract. - helm-prereqs/values/nico-core.yaml: drop the stale 'pair with ou: "Invalid"' cross-reference. - helm-prereqs/README.md: document nicoCliClientRole.ou, and correct the enabled default (the chart ships enabled: true). - internal_rbac_rules.rs: rename the never-compared placeholder group to nico-cli-client and document that it is not load-bearing, so it cannot leak into site configs as a required value again. No behavior change. Fixes NVIDIA#3662 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Shayan Namaghi <snamaghi@nvidia.com>
Summary by CodeRabbit
WalkthroughThe changes align the ChangesCLI client authorization alignment
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/api-core/src/auth/internal_rbac_rules.rs (1)
963-975: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winAdd a regression test for the ForgeAdminCLI authorization contract.
This change relies on the group value being documentation-only. Add table-driven cases covering the default OU, an explicit OU override, and an issuer CN absent from
auth.additional_issuer_cns; verify that OU changes do not alter authorization while an unmapped issuer is rejected. Also assert thatRuleInfo::newemits the expectednico-cli-clientprincipal.As per coding guidelines, Rust input-to-output authorization mappings should use table-driven tests.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/api-core/src/auth/internal_rbac_rules.rs` around lines 963 - 975, The ForgeAdminCLI authorization contract lacks regression coverage for documentation-only OU matching. Add a table-driven test covering the default OU, an explicit OU override, and an issuer CN missing from auth.additional_issuer_cns; verify both mapped issuers authorize regardless of OU and unmapped issuers are rejected, and assert RuleInfo::new produces the nico-cli-client ExternalUser principal.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@crates/api-core/src/auth/internal_rbac_rules.rs`:
- Around line 963-975: The ForgeAdminCLI authorization contract lacks regression
coverage for documentation-only OU matching. Add a table-driven test covering
the default OU, an explicit OU override, and an issuer CN missing from
auth.additional_issuer_cns; verify both mapped issuers authorize regardless of
OU and unmapped issuers are rejected, and assert RuleInfo::new produces the
nico-cli-client ExternalUser principal.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f1a6e09f-b783-479f-aa26-a4db7a0bee7a
📒 Files selected for processing (4)
crates/api-core/src/auth/internal_rbac_rules.rshelm-prereqs/README.mdhelm-prereqs/values.yamlhelm-prereqs/values/nico-core.yaml
The
nico-prereqsvault-pki-configjob created thenicocanico-cli-clientPKI role withou="Invalid"by default, stampingOU=Invalidinto every operator CLI client cert. On affected clusters everycarbide-admin-clicall returned a bare HTTP 403.Root cause analysis
The
ou: "Invalid"default was copied from theForgeAdminCLIprincipal ininternal_rbac_rules.rson the belief that the cert OU had to match that hardcoded group. It does not:Principal::is_proper_subset_ofmatches anyExternalUseragainst anyExternalUserwithout comparing the group (crates/authn/src/middleware.rs), so that constant is documentation-only. What actually gates admin-CLI authorization is the cert mapping to anExternalUserat all — i.e. the issuing CA's CN being listed in nico-apiauth.additional_issuer_cns(whichhelm-prereqs/values/nico-core.yamlalready sets to["site-root"]).Changes
helm-prereqs/values.yaml:nicoCliClientRole.ounow defaults to"", which falls back to the role name (nico-cli-client) via the template's existing| defaultchain. The comment now documents the real authorization contract instead of the incorrect "must match the hardcoded group" claim.helm-prereqs/values/nico-core.yaml: drop the stalepair with ou: "Invalid"cross-reference.helm-prereqs/README.md: document the previously-undocumentednicoCliClientRole.ouknob; correct theenableddefault cell (the chart shipsenabled: true).crates/api-core/src/auth/internal_rbac_rules.rs: rename the never-compared placeholder group from"Invalid"to"nico-cli-client"with a comment explaining it is not load-bearing — so it cannot leak into site configs as a "required" value again. No behavior change (the group is not compared by the matcher).Related issues
Fixes #3662
Type of Change
Breaking Changes
Existing clusters whose PKI role was already created with
ou=Invalidkeep working (the OU is not compared); re-running the vault-config job rewrites the role toou=nico-cli-clientand newly minted certs pick it up. Explicitvault.nicoCliClientRole.ouoverrides are honored unchanged.Testing
helm templateon the chart renders the role withou="nico-cli-client"with default values, and honors an explicitouoverride.cargo check -p carbide-api-corepasses; no test references the old placeholder group value.