-
Notifications
You must be signed in to change notification settings - Fork 6.5k
fix: prevent rootpath duplication in OIDC redirect URLs, fixes #21857 #20790 #12195 #22254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Diasker <[email protected]>
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22254 +/- ##
=========================================
Coverage ? 55.82%
=========================================
Files ? 342
Lines ? 57231
Branches ? 0
=========================================
Hits ? 31952
Misses ? 22636
Partials ? 2643 ☔ View full report in Codecov by Sentry. |
server/server.go
Outdated
| if rootPath == "" { | ||
| addr = fmt.Sprintf("localhost:%d", port) | ||
| } else { | ||
| addr = fmt.Sprintf("localhost:%d/%s", port, strings.TrimRight(strings.TrimLeft(rootPath, "/"), "/")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use strings.Trim(...)
server/server.go
Outdated
| target := "https://" + req.Host | ||
| if rootPath != "" { | ||
| target += "/" + strings.TrimRight(strings.TrimLeft(rootPath, "/"), "/") | ||
| root := strings.TrimRight(strings.TrimLeft(rootPath, "/"), "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.Trim(...)
server/server.go
Outdated
| // Check if the request path already contains rootPath | ||
| // If so, remove rootPath from the request path | ||
| prefix := "/" + root | ||
| req.URL.Path = strings.TrimPrefix(req.URL.Path, prefix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe modify how target is updated instead? req.URL.Path modification may bring req in the inconsistent state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review and suggestions! I have made changes based on your feedback!
…truction Signed-off-by: Diasker <[email protected]>
Hi there. As you see now, the reviewers might be busy and haven’t had time to merge the fix for this yet. In the meantime, you can try applying the changes from my PR (if applicable) directly to your setup, or you can test the pre-built image I’ve shared: fuckery/argocd:rootpath-fix. This image includes the fix for the root path duplication issue. |
agaudreault
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Hello is this applied on the latest docker image or just on this fuckery/argocd ? |
Sorry, I'm not sure about that. But I think they haven't built the latest image just now after merging my PR. |
…oj#21857 argoproj#20790 argoproj#12195 (argoproj#22254) Signed-off-by: Diasker <[email protected]> Signed-off-by: Kanika Rana <[email protected]>
…oj#21857 argoproj#20790 argoproj#12195 (argoproj#22254) Signed-off-by: Diasker <[email protected]> Signed-off-by: Oliver Gondža <[email protected]>
|
For those also browsing: Key highlights |
Fix rootPath duplication in OIDC callback URLs
Fixes #21857
Fixes #20790
Fixes #12195
Checklist
Problem Description
When ArgoCD is configured with a
rootPath, there is an issue where therootPathappears duplicated in OIDC authentication callback URLs. For example, whenrootPathis set to/argocd, the callback URL becomeshttps://example.com/argocd/argocd/..., causing authentication to fail and preventing users from successfully logging in.Note that the
/argocdsegment appears twice in the URL. This causes the authentication callback to fail, preventing users from successfully logging in.This issue has been reported in multiple tickets:
Root Cause Analysis
After reviewing the code, I identified two functions in
server.gothat contribute to this issue:withRootPathfunction: WhenrootPathis empty, it still creates anhttp.ServeMuxand processes the path, instead of directly returning the original handler.newRedirectServerfunction: When constructing the server address and handling redirect URLs, it doesn't properly handle the emptyrootPathcase, which can lead to rootPath being added multiple times in certain scenarios.Fix Implementation
I've made the following changes to
server.go:withRootPathfunction to add handling for emptyrootPath.newRedirectServerfunction to improve address construction logic.These changes ensure that
rootPathis handled correctly in URL processing, preventing the path duplication issue.Testing Validation
I've validated the fix through the following methods:
Unit Testing:
server/rootpath_test.goto verify the fix.Here are the test results:
The key test
TestNewRedirectServerRootPathDuplicationverifies that when a request path already contains the rootPath (e.g.,/argocd/applications), the redirect URL correctly becomeshttps://example.com:8080/argocd/applicationsinstead of the duplicatedhttps://example.com:8080/argocd/argocd/applications.Building ArgoCD Image:
Deployment Testing:
rootPath: /argocdComparison Testing:
/argocd/argocd/)/argocd/)Impact Scope
This fix only affects ArgoCD instances configured with a
rootPathparameter, particularly when using OIDC authentication. The fix does not impact other functionality or configurations.Summary
This fix resolves the rootPath duplication issue in ArgoCD, allowing ArgoCD instances configured with
rootPathto properly use OIDC authentication. The fix is minimal and focused, and has been validated through actual deployment testing.