git.iko.soy/typeable/oauth2-proxy
on master help sign in
Update session state handling
commit5dfefb6d9b090dd4d7a3ba4152fcf0ac380e413a authorJoel Speed <joel.speed@hotmail.co.uk> dateTue 25 Oct 2022, 18:48 (4 years ago) parentf55d24b
4 files changed+20−13
go.mod+3−1 go.sum+6−2 pkg/apis/sessions/session_state.go+6−6 pkg/apis/sessions/session_state_test.go+5−4
go.mod+3−1
@@ -22,13 +22,14 @@ require (
2222 github.com/oauth2-proxy/tools/reference-gen v0.0.0-20210118095127-56ffd7384404
2323 github.com/onsi/ginkgo v1.16.5
2424 github.com/onsi/gomega v1.21.1
25− github.com/pierrec/lz4 v2.6.1+incompatible
25+ github.com/pierrec/lz4/v4 v4.1.17
2626 github.com/prometheus/client_golang v1.13.0
2727 github.com/spf13/cast v1.5.0
2828 github.com/spf13/pflag v1.0.5
2929 github.com/spf13/viper v1.13.0
3030 github.com/stretchr/testify v1.8.0
3131 github.com/vmihailenco/msgpack/v4 v4.3.12
32+ github.com/vmihailenco/msgpack/v5 v5.3.5
3233 golang.org/x/crypto v0.1.0
3334 golang.org/x/exp v0.0.0-20221019170559-20944726eadf
3435 golang.org/x/net v0.1.0
@@ -68,6 +69,7 @@ require (
6869 github.com/spf13/jwalterweatherman v1.1.0 // indirect
6970 github.com/subosito/gotenv v1.4.1 // indirect
7071 github.com/vmihailenco/tagparser v0.1.1 // indirect
72+ github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
7173 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
7274 go.opencensus.io v0.23.0 // indirect
7375 golang.org/x/sys v0.1.0 // indirect
go.sum+6−2
@@ -320,8 +320,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v
320320github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
321321github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
322322github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
323−github.com/pierrec/lz4 v2.6.1+incompatible h1:9UY3+iC23yxF0UfGaYrGplQ+79Rg+h/q9FV9ix19jjM=
324−github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
323+github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
324+github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
325325github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
326326github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
327327github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -386,8 +386,12 @@ github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs
386386github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
387387github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
388388github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
389+github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
390+github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
389391github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
390392github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
393+github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
394+github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
391395github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
392396github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
393397github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
pkg/apis/sessions/session_state.go+6−6
@@ -9,8 +9,8 @@ import (
99
1010 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
1111 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
12− "github.com/pierrec/lz4"
13− "github.com/vmihailenco/msgpack/v4"
12+ "github.com/pierrec/lz4/v4"
13+ "github.com/vmihailenco/msgpack/v5"
1414)
1515
1616// SessionState is used to store information about the currently authenticated user session
@@ -208,10 +208,10 @@ func DecodeSessionState(data []byte, c encryption.Cipher, compressed bool) (*Ses
208208func lz4Compress(payload []byte) ([]byte, error) {
209209 buf := new(bytes.Buffer)
210210 zw := lz4.NewWriter(nil)
211− zw.Header = lz4.Header{
212− BlockMaxSize: 65536,
213− CompressionLevel: 0,
214− }
211+ zw.Apply(
212+ lz4.BlockSizeOption(lz4.BlockSize(65536)),
213+ lz4.CompressionLevelOption(lz4.Fast),
214+ )
215215 zw.Reset(buf)
216216
217217 reader := bytes.NewReader(payload)
pkg/apis/sessions/session_state_test.go+5−4
@@ -10,6 +10,7 @@ import (
1010 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
1111 . "github.com/onsi/gomega"
1212 "github.com/stretchr/testify/assert"
13+ "github.com/stretchr/testify/require"
1314)
1415
1516func timePtr(t time.Time) *time.Time {
@@ -247,16 +248,16 @@ func TestEncodeAndDecodeSessionState(t *testing.T) {
247248 for testName, ss := range testCases {
248249 t.Run(testName, func(t *testing.T) {
249250 encoded, err := ss.EncodeSessionState(c, false)
250− assert.NoError(t, err)
251+ require.NoError(t, err)
251252 encodedCompressed, err := ss.EncodeSessionState(c, true)
252− assert.NoError(t, err)
253+ require.NoError(t, err)
253254 // Make sure compressed version is smaller than if not compressed
254255 assert.Greater(t, len(encoded), len(encodedCompressed))
255256
256257 decoded, err := DecodeSessionState(encoded, c, false)
257− assert.NoError(t, err)
258+ require.NoError(t, err)
258259 decodedCompressed, err := DecodeSessionState(encodedCompressed, c, true)
259− assert.NoError(t, err)
260+ require.NoError(t, err)
260261
261262 compareSessionStates(t, decoded, decodedCompressed)
262263 compareSessionStates(t, decoded, &ss)