Reconsider and document redirect policy
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- go
- Lĩnh vực
- api, networking
Hướng nghiên cứu
Bắt đầu với dial.go ở các dòng 76-103 và tài liệu thư viện mô tả DialOptions, sau đó so sánh hành vi chuyển hướng với đặc tả WebSocket được trích dẫn và các giới hạn của WASM. Làm rõ và ghi lại chính sách hiện tại, đồng thời xác định liệu giá trị mặc định có nên thay đổi trong một phiên bản tương lai hay không; issue #333 liên quan cung cấp thêm ngữ cảnh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Go
- Star
- 5.5k
- Fork
- 377
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của coder/websocket
-
Must not wrap io.EOF Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
export wstest Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Tất cả issue của coder/websocket
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
github/gh-aw-mcpg#13748 ·
-
agentic-workflows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
googleapis/librarian#7670 · 2 bình luận ·