sso_*: proxy path-components with %-escaped characters in tact.#284
Merged
sso_*: proxy path-components with %-escaped characters in tact.#284
Conversation
jphines
suggested changes
Mar 6, 2020
Contributor
jphines
left a comment
There was a problem hiding this comment.
This looks good -- but I'd like to see a test added to the proxy side.
Codecov Report
@@ Coverage Diff @@
## master #284 +/- ##
=======================================
Coverage 61.85% 61.85%
=======================================
Files 57 57
Lines 4637 4638 +1
=======================================
+ Hits 2868 2869 +1
Misses 1556 1556
Partials 213 213 Continue to review full report at Codecov.
|
Contributor
Author
Great idea - Done; I've added one to |
jphines
approved these changes
Mar 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When proxying to a path with a %-encoded
/character (i.e.%2F), the Golanghttp.ServeMuxclass auto-unwraps the %-encoding. It then usespath.Clean()to "helpfully" normalize successive/characters (e.g./a/b//cto/a/b/c,/a/b/../cto/a, etc).Though admittedly an edge-case, the unintended side-effect is that a URL whose path contains a %-encoded URL will be proxied incorrectly. Fo instance, the URL
https://example.com/path/http:%2F%2Ffoo.com/will be proxied to
https://example.com/path/http:/foo.com/.Solution
Replace use of
http.ServeMuxwith themux.Routerclass from the popular https://github.com/gorilla/mux library, which allows use ofURL.EscapedPath()in lieu of directly readingURL.Path. This preserves the %-wrapping of path-components, which in turn preventspath.Clean()from errantly rewriting the path.Notes
The motivating example derives from the popular open-source Jenkins project, which uses URLs in such a form to check the health of a reverse-proxy - Hence this bug causes a Jenkins instance behind an SSO deployment to report a "broken" reverse-proxy configuration.