git.iko.soy/typeable/oauth2-proxy
on master help sign in
Use the httputil.NewSingleHostReverseProxy instead of yhat/wsutil for … (#1348)

* Use the httputil.NewSingleHostReverseProxy instad of yhat/wsutil for websocket proxying. This correctly handles 404 responses with keep-alive by terminating the tunnel rather than keeping it alive * Tidy up dependencies - yhat/wsutil is no longer required * Update changelog to include reference to 1348 Co-authored-by: Matt Lilley <matt.lilley@securitease.com> Co-authored-by: Joel Speed <Joel.speed@hotmail.co.uk>

commit3957183fd5aeba951c9347764cfd4883c91331f0 authorMatt Lilley <thetrime@gmail.com> dateSun 3 Oct 2021, 15:38 (5 years ago) parenta87c27b
4 files changed+5−10
CHANGELOG.md+1 go.mod−1 go.sum−2 pkg/upstream/http.go+4−7
CHANGELOG.md+1
@@ -18,6 +18,7 @@
1818
1919## Changes since v7.1.3
2020
21+- [#1348](https://github.com/oauth2-proxy/oauth2-proxy/pull/1348) Using the native httputil proxy code for websockets rather than yhat/wsutil to properly handle HTTP-level failures (@thetrime)
2122- [#1379](https://github.com/oauth2-proxy/oauth2-proxy/pull/1379) Fix the manual sign in with --htpasswd-user-group switch (@janrotter)
2223- [#1337](https://github.com/oauth2-proxy/oauth2-proxy/pull/1337) Changing user field type to text when using htpasswd (@pburgisser)
2324- [#1239](https://github.com/oauth2-proxy/oauth2-proxy/pull/1239) Base GitLab provider implementation on OIDCProvider (@NickMeves)
go.mod−1
@@ -29,7 +29,6 @@ require (
2929 github.com/spf13/viper v1.6.3
3030 github.com/stretchr/testify v1.6.1
3131 github.com/vmihailenco/msgpack/v4 v4.3.11
32− github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997
3332 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
3433 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
3534 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
go.sum−2
@@ -426,8 +426,6 @@ github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37w
426426github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
427427github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
428428github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
429−github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997 h1:1+FQ4Ns+UZtUiQ4lP0sTCyKSQ0EXoiwAdHZB0Pd5t9Q=
430−github.com/yhat/wsutil v0.0.0-20170731153501-1d66fa95c997/go.mod h1:DIGbh/f5XMAessMV/uaIik81gkDVjUeQ9ApdaU7wRKE=
431429github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
432430github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
433431github.com/yuin/gopher-lua v0.0.0-20191213034115-f46add6fdb5c/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
pkg/upstream/http.go+4−7
@@ -10,7 +10,6 @@ import (
1010 "github.com/mbland/hmacauth"
1111 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/middleware"
1212 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
13− "github.com/yhat/wsutil"
1413)
1514
1615const (
@@ -156,14 +155,12 @@ func setProxyDirector(proxy *httputil.ReverseProxy) {
156155
157156// newWebSocketReverseProxy creates a new reverse proxy for proxying websocket connections.
158157func newWebSocketReverseProxy(u *url.URL, skipTLSVerify bool) http.Handler {
159− // This should create the correct scheme for insecure vs secure connections
160− wsScheme := "ws" + strings.TrimPrefix(u.Scheme, "http")
161− wsURL := &url.URL{Scheme: wsScheme, Host: u.Host}
162−
163− wsProxy := wsutil.NewSingleHostReverseProxy(wsURL)
158+ wsProxy := httputil.NewSingleHostReverseProxy(u)
164159 /* #nosec G402 */
165160 if skipTLSVerify {
166− wsProxy.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
161+ wsProxy.Transport = &http.Transport{
162+ TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
163+ }
167164 }
168165 return wsProxy
169166}