Skip to content

Commit b6adc4b

Browse files
authored
Merge pull request #225 from nhooyr/undep
Undeprecate InsecureSkipVerify
2 parents 1f37f5d + 5e8fc37 commit b6adc4b

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Advantages of nhooyr.io/websocket:
112112
- Gorilla's implementation is slower and uses [unsafe](https://golang.org/pkg/unsafe/).
113113
- Full [permessage-deflate](https://tools.ietf.org/html/rfc7692) compression extension support
114114
- Gorilla only supports no context takeover mode
115-
- We use a vendored [klauspost/compress](https://github.com/klauspost/compress) for much lower memory usage ([gorilla/websocket#203](https://github.com/gorilla/websocket/issues/203))
115+
- We use [klauspost/compress](https://github.com/klauspost/compress) for much lower memory usage ([gorilla/websocket#203](https://github.com/gorilla/websocket/issues/203))
116116
- [CloseRead](https://pkg.go.dev/nhooyr.io/websocket#Conn.CloseRead) helper ([gorilla/websocket#492](https://github.com/gorilla/websocket/issues/492))
117117
- Actively maintained ([gorilla/websocket#370](https://github.com/gorilla/websocket/issues/370))
118118

Diff for: accept.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ type AcceptOptions struct {
2828

2929
// InsecureSkipVerify is used to disable Accept's origin verification behaviour.
3030
//
31-
// Deprecated: Use OriginPatterns with a match all pattern of * instead to control
32-
// origin authorization yourself.
31+
// You probably want to use OriginPatterns instead.
3332
InsecureSkipVerify bool
3433

3534
// OriginPatterns lists the host patterns for authorized origins.
@@ -46,6 +45,9 @@ type AcceptOptions struct {
4645
//
4746
// Please ensure you understand the ramifications of enabling this.
4847
// If used incorrectly your WebSocket server will be open to CSRF attacks.
48+
//
49+
// Do not use * as a pattern to allow any origin, prefer to use InsecureSkipVerify instead
50+
// to bring attention to the danger of such a setting.
4951
OriginPatterns []string
5052

5153
// CompressionMode controls the compression mode.

Diff for: conn_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ func TestWasm(t *testing.T) {
273273

274274
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
275275
c, err := websocket.Accept(w, r, &websocket.AcceptOptions{
276-
Subprotocols: []string{"echo"},
277-
OriginPatterns: []string{"*"},
276+
Subprotocols: []string{"echo"},
277+
InsecureSkipVerify: true,
278278
})
279279
if err != nil {
280280
t.Errorf("echo server failed: %v", err)

Diff for: examples/chat/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ Visit the printed URL to submit and view broadcasted messages in a browser.
1717
The frontend is contained in `index.html`, `index.js` and `index.css`. It sets up the
1818
DOM with a scrollable div at the top that is populated with new messages as they are broadcast.
1919
At the bottom it adds a form to submit messages.
20+
2021
The messages are received via the WebSocket `/subscribe` endpoint and published via
21-
the HTTP POST `/publish` endpoint.
22+
the HTTP POST `/publish` endpoint. The reason for not publishing messages over the WebSocket
23+
is so that you can easily publish a message with curl.
2224

2325
The server portion is `main.go` and `chat.go` and implements serving the static frontend
2426
assets, the `/subscribe` WebSocket endpoint and the HTTP POST `/publish` endpoint.

0 commit comments

Comments
 (0)