git.iko.soy/typeable/oauth2-proxy
on master help sign in
Update session state handling
5dfefb6Joel Speed
go.mod+3−1
@@ -22,13 +22,14 @@ require (
22 github.com/oauth2-proxy/tools/reference-gen v0.0.0-20210118095127-56ffd7384404
22 github.com/oauth2-proxy/tools/reference-gen v0.0.0-20210118095127-56ffd7384404
23 github.com/onsi/ginkgo v1.16.5
23 github.com/onsi/ginkgo v1.16.5
24 github.com/onsi/gomega v1.21.1
24 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
26 github.com/prometheus/client_golang v1.13.0
26 github.com/prometheus/client_golang v1.13.0
27 github.com/spf13/cast v1.5.0
27 github.com/spf13/cast v1.5.0
28 github.com/spf13/pflag v1.0.5
28 github.com/spf13/pflag v1.0.5
29 github.com/spf13/viper v1.13.0
29 github.com/spf13/viper v1.13.0
30 github.com/stretchr/testify v1.8.0
30 github.com/stretchr/testify v1.8.0
31 github.com/vmihailenco/msgpack/v4 v4.3.12
31 github.com/vmihailenco/msgpack/v4 v4.3.12
32+ github.com/vmihailenco/msgpack/v5 v5.3.5
32 golang.org/x/crypto v0.1.0
33 golang.org/x/crypto v0.1.0
33 golang.org/x/exp v0.0.0-20221019170559-20944726eadf
34 golang.org/x/exp v0.0.0-20221019170559-20944726eadf
34 golang.org/x/net v0.1.0
35 golang.org/x/net v0.1.0
@@ -68,6 +69,7 @@ require (
68 github.com/spf13/jwalterweatherman v1.1.0 // indirect
69 github.com/spf13/jwalterweatherman v1.1.0 // indirect
69 github.com/subosito/gotenv v1.4.1 // indirect
70 github.com/subosito/gotenv v1.4.1 // indirect
70 github.com/vmihailenco/tagparser v0.1.1 // indirect
71 github.com/vmihailenco/tagparser v0.1.1 // indirect
72+ github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
71 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
73 github.com/yuin/gopher-lua v0.0.0-20210529063254-f4c35e4016d9 // indirect
72 go.opencensus.io v0.23.0 // indirect
74 go.opencensus.io v0.23.0 // indirect
73 golang.org/x/sys v0.1.0 // indirect
75 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
320github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
320github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
321github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
321github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
322github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
322github.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=
323+github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc=
324−github.com/pierrec/lz4 v2.6.1+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
324+github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
325github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
325github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
326github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
326github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
327github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
327github.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
386github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
386github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
387github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
387github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
388github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
388github.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=
389github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
391github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
390github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI=
392github.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=
391github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
395github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
392github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
396github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
393github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
397github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
pkg/apis/sessions/session_state.go+6−6
@@ -9,8 +9,8 @@ import (
9
9
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/clock"
11 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
11 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
12− "github.com/pierrec/lz4"
12+ "github.com/pierrec/lz4/v4"
13− "github.com/vmihailenco/msgpack/v4"
13+ "github.com/vmihailenco/msgpack/v5"
14)
14)
15
15
16// SessionState is used to store information about the currently authenticated user session
16// 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
208func lz4Compress(payload []byte) ([]byte, error) {
208func lz4Compress(payload []byte) ([]byte, error) {
209 buf := new(bytes.Buffer)
209 buf := new(bytes.Buffer)
210 zw := lz4.NewWriter(nil)
210 zw := lz4.NewWriter(nil)
211− zw.Header = lz4.Header{
211+ zw.Apply(
212− BlockMaxSize: 65536,
212+ lz4.BlockSizeOption(lz4.BlockSize(65536)),
213− CompressionLevel: 0,
213+ lz4.CompressionLevelOption(lz4.Fast),
214− }
214+ )
215 zw.Reset(buf)
215 zw.Reset(buf)
216
216
217 reader := bytes.NewReader(payload)
217 reader := bytes.NewReader(payload)
pkg/apis/sessions/session_state_test.go+5−4
@@ -10,6 +10,7 @@ import (
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
10 "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/encryption"
11 . "github.com/onsi/gomega"
11 . "github.com/onsi/gomega"
12 "github.com/stretchr/testify/assert"
12 "github.com/stretchr/testify/assert"
13+ "github.com/stretchr/testify/require"
13)
14)
14
15
15func timePtr(t time.Time) *time.Time {
16func timePtr(t time.Time) *time.Time {
@@ -247,16 +248,16 @@ func TestEncodeAndDecodeSessionState(t *testing.T) {
247 for testName, ss := range testCases {
248 for testName, ss := range testCases {
248 t.Run(testName, func(t *testing.T) {
249 t.Run(testName, func(t *testing.T) {
249 encoded, err := ss.EncodeSessionState(c, false)
250 encoded, err := ss.EncodeSessionState(c, false)
250− assert.NoError(t, err)
251+ require.NoError(t, err)
251 encodedCompressed, err := ss.EncodeSessionState(c, true)
252 encodedCompressed, err := ss.EncodeSessionState(c, true)
252− assert.NoError(t, err)
253+ require.NoError(t, err)
253 // Make sure compressed version is smaller than if not compressed
254 // Make sure compressed version is smaller than if not compressed
254 assert.Greater(t, len(encoded), len(encodedCompressed))
255 assert.Greater(t, len(encoded), len(encodedCompressed))
255
256
256 decoded, err := DecodeSessionState(encoded, c, false)
257 decoded, err := DecodeSessionState(encoded, c, false)
257− assert.NoError(t, err)
258+ require.NoError(t, err)
258 decodedCompressed, err := DecodeSessionState(encodedCompressed, c, true)
259 decodedCompressed, err := DecodeSessionState(encodedCompressed, c, true)
259− assert.NoError(t, err)
260+ require.NoError(t, err)
260
261
261 compareSessionStates(t, decoded, decodedCompressed)
262 compareSessionStates(t, decoded, decodedCompressed)
262 compareSessionStates(t, decoded, &ss)
263 compareSessionStates(t, decoded, &ss)