fix: oci creds incorrectly omitted when sourceRepos set to specific registry path#26824
fix: oci creds incorrectly omitted when sourceRepos set to specific registry path#268240xVox wants to merge 1 commit intoargoproj:masterfrom
Conversation
🔴 Preview Environment stopped on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
7c54d81 to
b8604b5
Compare
…eg path Signed-off-by: 0xVox <tom.brew3@gmail.com>
b8604b5 to
a602dc3
Compare
blakepettersson
left a comment
There was a problem hiding this comment.
The fix is to for the app project to have the relevant source prefix(es) inprojSources no?
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #26824 +/- ##
==========================================
- Coverage 62.98% 62.98% -0.01%
==========================================
Files 414 414
Lines 56153 56168 +15
==========================================
+ Hits 35370 35378 +8
- Misses 17416 17420 +4
- Partials 3367 3370 +3 ☔ View full report in Codecov by Sentry. |
It certainly works that way, and the credentials will be passed through. But, if you were to attempt further granularity with the This fixes that, and enables that further granularity in sourceRepos control. See: #26311 (comment) |
Summary
GetPermittedReposCredentialsto permit credential templates when their URL is a prefix of any permitted source repo in the AppProjectIsCredentialPermittedForAnySourcemethod to AppProject to handle prefix-based credential matchingContext
When an AppProject's
sourceReposuses*, all repository credentials pass the permission filter and are sent to the repo-server. However, whensourceReposis scoped to specific repositories (e.g.reg.example.com/org/charts), credential templates with broader prefix URLs (e.g.reg.example.com) are filtered out, causinghelm dependency buildto fail with 403 errors when resolving OCI Helm chart dependencies.This affects any Git-sourced Application containing a Helm chart with OCI registry dependencies where the AppProject has restrictive
sourceRepos.Rationale
GetPermittedReposCredentialsusesIsSourcePermittedto decide whether a credential should be passed to the repo-server.IsSourcePermitteddoes exact glob matching: it checks whether the sourceRepos pattern matches the credential URL. But credential template URLs are prefix-based by design — a credential with URLreg.example.comis meant to provide authentication for everything under that hostname (e.g.reg.example.com/org/charts).When
sourceReposcontains a specific path likereg.example.com/org/charts, the glob match against the shorter credential URLreg.example.comalways fails, so the credential is filtered out and never reaches the repo-server. The only workaround was to add the exact credential URL (bare hostname) tosourceRepos, which defeats the purpose of restricting which paths the project can access.Fix
Added
IsCredentialPermittedForAnySourceon AppProject, which checks the reverse direction: whether any permitted sourceRepo falls under the credential's URL prefix.GetPermittedReposCredentialsnow calls this as a fallback whenIsSourcePermitteddoesn't match, so credentials are permitted if they could provide auth for any source the project is allowed to use.The check normalises both URLs and strips
oci://schemes before comparison, so it handles all combinations of OCI and non-OCI sourceRepos entries.I suspect this may also close out #26311