Should Callback respect X-Forwarded-Prefix headers from reverse proxy?

Abierto
#157 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
38/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
flask, nginx, python

Línea de trabajo

Empieza en dash_auth/oidc_auth.py, en la sentencia return enlazada alrededor de la línea 277, y revisa después cómo el ProxyFix configurado gestiona X-Forwarded-Prefix. Reproduce la redirección con la configuración proporcionada de location y headers de nginx. Se considera terminado cuando la redirección final conserva /my-app1 cuando el proxy inverso proporciona ese prefijo, sin romper el fallback de base-path configurado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

https://github.com/plotly/dash-auth/blob/18f66d308943c8bda792e22d3e697414cd36a1c3/dash_auth/oidc_auth.py#L277C9-L277C73

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!

Lenguaje dominante
Python
Estrellas
135
Forks
67
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de plotly/dash-auth

Todos los issues de plotly/dash-auth

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.