Reconsider and document redirect policy
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- go
- Área
- api, networking
Línea de trabajo
Comienza con dial.go en las líneas 76-103 y la documentación de la biblioteca que describe DialOptions; después, compara el comportamiento de redirección con la especificación de WebSocket citada y las limitaciones de WASM. Aclara y documenta la política actual, y determina si el valor predeterminado debería cambiar en una versión futura; el issue #333 relacionado proporciona contexto adicional.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
The problem
It looks like that by default the library uses the default HTTPClient:
https://github.com/coder/websocket/blob/d1468a75eee5525d183123766fbf288dca1eed9b/dial.go#L76-L103
And the default HTTP client does follow redirects:
// If CheckRedirect is nil, the Client uses its default policy,
// which is to stop after 10 consecutive requests.
Edit: actually, doesn't the fact that we do specify a CheckRedirect function mean that we do not stop after 10 consecutive requests?
I am aware that it is possible to provide your own HTTPClient struct to the Dial() function, and it is nice to rely on built-in defaults, I think a WebSocket library should be more concrete in this regard. Especially given the fact that this particular one claims to be able to target WASM. And, according to the browser WebSocket spec, redirects are not followed:
redirect mode is "error"
The reason redirects are not followed and this handshake is generally restricted is because it could introduce serious security problems in a web browser context. For example, consider a host with a WebSocket server at one path and an open HTTP redirector at another. Suddenly, any script that can be given a particular WebSocket URL can be tricked into communicating to (and potentially sharing secrets with) any host on the internet, even if the script checks that the URL has the right hostname.
This IMO can be considered an inconsistency between different targets.
Note that changing redirect policy for the WASM version is not possible, according to this library's docs:
HTTPClient, HTTPHeader and CompressionMode in DialOptions are no-op
For reference, the WebSocket spec itself states:
the server might redirect the client using a 3xx status code (but clients are not required to follow them)
Also for reference, the Gorilla WebSocket library IMU does not follow redirects, see this issue: https://github.com/gorilla/websocket/pull/965 and the code.
Suggested solution
- Document that the library follows redirects, but not in the WASM version.
- For the next version: Do not follow redirects by default, and document this.
This can either be considered a breaking change (so it goes to v2.x.x), or a bug fix.
Related issue: https://github.com/coder/websocket/issues/333
- Lenguaje dominante
- Go
- Estrellas
- 5.5k
- Forks
- 377
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de coder/websocket
-
Must not wrap io.EOF Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
export wstest Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
Todos los issues de coder/websocket
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
bazel-contrib/rules_go#4726 · 1 comentario ·
-
area/auto-scaling area/monitoring area/ops-productivity kind/enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
Type/Improvement
Dificultad 1/5 1-3 horas Aptitud para principiantes 90/100
OpenNSW/nsw-srilanka#522 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 92/100