[#1867] fix: convert vault client trust_domain and namespace configurable#2015
Conversation
|
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. |
799c1d8 to
5ae2e40
Compare
5ae2e40 to
1c4df6c
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThis PR parameterizes SPIFFE certificate configuration by extending ChangesSPIFFE Configuration and Certificate Generation
Site-Specific Vault Configuration
Test Fixture Completeness
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/secrets/src/forge_vault.rs (1)
1047-1061: ⚡ Quick winAdd test coverage for empty/whitespace-only base path.
The
machine_spiffe_urifunction has anif base.is_empty()branch (lines 145-146) that is not exercised by these tests. Consider adding a case to verify that behavior.Proposed addition
assert_eq!( machine_spiffe_uri("forge.local", "forge-system/machine", "abc-123"), "spiffe://forge.local/forge-system/machine/abc-123" ); + // Empty or whitespace-only base path omits the path segment + assert_eq!( + machine_spiffe_uri("forge.local", "", "abc-123"), + "spiffe://forge.local/abc-123" + ); + assert_eq!( + machine_spiffe_uri("forge.local", " ", "abc-123"), + "spiffe://forge.local/abc-123" + ); }🤖 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/secrets/src/forge_vault.rs` around lines 1047 - 1061, Add test assertions to exercise the machine_spiffe_uri branch where base.is_empty(): in the existing test (or a new test) call machine_spiffe_uri with an empty string base ("") and with a whitespace-only base (" ") for at least one trust domain and id, and assert the resulting URI matches the expected spiffe://<trust-domain>/machine/<id> (i.e., no extra slashes or base path inserted); reference the machine_spiffe_uri function to locate and extend the test cases.
🤖 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/secrets/src/forge_vault.rs`:
- Around line 1047-1061: Add test assertions to exercise the machine_spiffe_uri
branch where base.is_empty(): in the existing test (or a new test) call
machine_spiffe_uri with an empty string base ("") and with a whitespace-only
base (" ") for at least one trust domain and id, and assert the resulting URI
matches the expected spiffe://<trust-domain>/machine/<id> (i.e., no extra
slashes or base path inserted); reference the machine_spiffe_uri function to
locate and extend the test cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 927fca33-d7a9-4941-914a-0371b60a73e1
📒 Files selected for processing (4)
crates/api-integration-tests/tests/vault_catalogue.rscrates/api-test-helper/src/utils.rscrates/api/src/run.rscrates/secrets/src/forge_vault.rs
1c4df6c to
a29b77a
Compare
|
@ianderson-nvidia, please review. |
a29b77a to
43aab1c
Compare
|
|
||
| const DEFAULT_VAULT_CA_PATH: &str = "/var/run/secrets/forge-roots/ca.crt"; | ||
| const VAULT_CACERT_ENV_VAR: &str = "VAULT_CACERT"; | ||
| const DEFAULT_SPIFFE_TRUST_DOMAIN: &str = "forge.local"; |
There was a problem hiding this comment.
I would recommend that nico.local is the default, and any location that has the name forge in it, is replaced with nico, to be less confusing for someone who reads this in two years time.
There was a problem hiding this comment.
This should be a follow-up issue IMO:
By changing to nico.local the only way to deploy this build without breaking existing deployments is to coordinate the deployment with changes to the ConfigMap of the api config file for all pre-existing sites. For each pre-existing site, we'd need to ensure spiffe_trust_domain = forge.local is set.
There was a problem hiding this comment.
agree, and to add, the name change ideally should be a repo wide task broadly considering the side effects and also being consistant.
43aab1c to
e4b3be6
Compare
Summary
Vault-issued machine certificates previously hardcoded SPIFFE URI SANs as
spiffe://forge.local/forge-system/machine/<id>. Sites with non-default trust domains (e.g.nico.local) received certs that did not match auth/SPIFFE expectations.This PR wires machine PKI URI SANs to the same trust settings used elsewhere:
spiffe_trust_domainandspiffe_machine_base_pathonVaultConfig, with defaults (forge.local,/forge-system/machine/) and env overrides (VAULT_SPIFFE_TRUST_DOMAIN,VAULT_SPIFFE_MACHINE_BASE_PATH)machine_spiffe_uri()to build URIs consistently from trust domain, base path, and machine IDcarbide-apistartup,vault_config_for_site()copies[auth.trust]into the Vault client config when site auth config is present, so issued certs align with site SPIFFE layout without a separate namespace field[auth.trust]now get matching URI SANs on Vault-issued machine certs.Files changed
crates/secrets/src/forge_vault.rscrates/api/src/run.rscrates/api-test-helper/src/utils.rs,crates/api-integration-tests/tests/vault_catalogue.rsDescription
Type of Change
Related Issues (Optional)
#1867
Breaking Changes
Testing
Additional Notes
Summary by CodeRabbit
New Features
Improvements