outposts/proxy: Fix invalid redirect on external hosts containing path components#8915
Merged
BeryJu merged 2 commits intogoauthentik:mainfrom Mar 19, 2024
Merged
Conversation
…h components Signed-off-by: Max <github@germancoding.com>
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
BeryJu
approved these changes
Mar 19, 2024
Signed-off-by: Max <github@germancoding.com>
Contributor
Author
|
Sorry, looks like I missed that test case. I changed it to match the new logic. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8915 +/- ##
===========================================
+ Coverage 46.62% 92.33% +45.70%
===========================================
Files 626 640 +14
Lines 30996 31552 +556
===========================================
+ Hits 14451 29132 +14681
+ Misses 16545 2420 -14125
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
kensternberg-authentik
added a commit
that referenced
this pull request
Mar 21, 2024
* main: outposts/proxy: Fix invalid redirect on external hosts containing path components (#8915) core: cache user application list under policies (#8895) web: bump the eslint group in /web with 2 updates (#8959) web: bump core-js from 3.36.0 to 3.36.1 in /web (#8960) website: bump @types/react from 18.2.66 to 18.2.67 in /website (#8962) web: bump the eslint group in /tests/wdio with 2 updates (#8963)
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.
Details
I was trying to setup a proxy provider (proxy mode, not forwarding) with an outpost. I'm using an external host that contains a path component, like this:
External Host: https://example.com/myAppThis generally works nicely with authentik, except for the login. Assume my webbrowser is currently on
https://example.com/myApp/resourceAand the proxy detects that the user needs to (re-)login. Now, what happens is that after the login has completed, you get redirected back tohttps://example.com/resourceA. The path componentmyAppis simply cut off, which then causes 404 errors in my app (since that URL doesn't exist).The reason for this misbehavior is the
urlPathSet()function, which completely removes any path components set by the external host setting. This is apparently only done in one place (redirectToStart()) and no where else. It also seems to be unnecessary - why can't we simply join the base (the external host) and the target URL? This works just as before, but without the issue created by cutting off parts of the URL.I also modernized the
urlJoinfunction to use modern golang functions. The benefit is that theurl.JoinPath()is smarter thanpath.Join()- for example, path.Join cuts off trailing slashes, which might be problematic for URLs.url.JoinPath()knows this and doesn't do this.Checklist
ak test authentik/)make lint-fix)If an API change has been made
make gen-build)If changes to the frontend have been made
make web)If applicable
make website)