-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
outposts/proxy: Fix invalid redirect on external hosts containing path components #8915
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. |
Signed-off-by: Max <github@germancoding.com>
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. |
* 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)
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/myApp
This generally works nicely with authentik, except for the login. Assume my webbrowser is currently on
https://example.com/myApp/resourceA
and 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 componentmyApp
is 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
urlJoin
function 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
)