-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fixed CORS requests failing with forward auth via proxy provider #17233
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: solidDoWant <[email protected]>
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-storybook canceled.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17233 +/- ##
==========================================
- Coverage 92.90% 92.57% -0.33%
==========================================
Files 853 856 +3
Lines 46310 46498 +188
==========================================
+ Hits 43025 43047 +22
- Misses 3285 3451 +166
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: solidDoWant <[email protected]>
I'm aware code coverage is lacking. I'll add tests when/if this gets a first pass review. Running tests in this project locally is pretty difficult and time consuming, so I don't really want to put in this work if the actual code change needs a major rework. |
Signed-off-by: solidDoWant <[email protected]>
Details
This allows CORS requests to go through the proxy provider forward auth "plan" (not sure if this is the right word), fixing XHR and fetch requests, as well as WebSockets when the forward auth plan needs to be ran again.
I'm not really familiar with this codebase and I don't do much front end web dev, so there may be issues (including security vulnerabilities) introduced by this. Please review this carefully and assume that I don't know what I'm doing.
I've tested this patch against a branch based off of the latest release, and I have it working with Radarr, an app that uses credentialed XMLHTTPRequests and SignalR over WebSockets. It's working great, and renewing the proxy cookie is 100% transparent to me as a user. Note that I have only tested with Envoy/Istio. I don't have (or plan on having) traefik, caddy, or nginx deployed as a reverse proxy, so I'll be unable to test the changes that are specific to these reverse proxies.
One new requirement of this is that front-end application requests must set
XMLHTTPRequest.withCredentials = true
. Without this, the browser won't send the authentik session cookie to the authentik callback endpoint, making authentik think that every request needs to go through the application's configured auth flow. This needs to be set even if the application otherwise does not use credentials for these requests. I don't think that there is a way around this with how forward auth is handled with the proxy cookie. I'm not sure where to document this.Closes #10057
Checklist
ak test authentik/
) - These take like an hour to run locally. If they're not ran automatically in CI then I'll run them overnight.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
XMLHTTPRequest.withCredentials = true
make docs
)