Should Callback respect X-Forwarded-Prefix headers from reverse proxy?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 135
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
Could totally be my own inexperience here, but I'm running into redirect issues from my IDP and I think it's because of this line.
My nginx config has an app running on http://127.0.0.1:8050 being accessed through location /my-app1/. So I pass a proxy_set_header X-Forwarded-Prefix /my-app1.
All the auth stuff works out, however the final redirect pushes me to <my-domain> instead of <my-domain>/my-app1 like I would expect. I believe this is because I am not setting url_base_pathname in Dash to be /my-app1/, rather I am only setting requests_pathname_prefix to that value. The reason there being ... unclear .. but I find things only work when setting requests_pathname_prefix vs url_base_pathname
I'm also using a ProxyFix, which is forwarding on that Prefix header, but I am not familiar enough with Flask internals to know where / when it is applied (if at all).
app.server.wsgi_app = ProxyFix( app.server.wsgi_app, x_for=1, x_proto=1, x_host=1, x_prefix=1 )
Either way, if I patch
return redirect(self.app.config.get("url_base_pathname") or "/")
to effectively be
return redirect(request.headers.get("X-Forwarded-Prefix") or self.app.config.get("url_base_pathname") or "/")
Everything appears to redirect as intended. So I'm wondering if that header needs to be captured in this return statement.
It's no doubt a bit confusing when you have nginx waitress flask and dash all in line trying to be helpful!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in dash_auth/oidc_auth.py at the linked return statement around line 277, then review how the configured ProxyFix handles X-Forwarded-Prefix. Reproduce the redirect with the provided nginx location and header setup. Done means the final redirect preserves /my-app1 when the reverse proxy supplies that prefix, without breaking the configured base-path fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, nginx, python
- Domain
- authentication, backend, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100