Skip to content

Commit 2ddb0cf

Browse files
authored
Update dependencies (#12)
1 parent cc3fa50 commit 2ddb0cf

File tree

3 files changed

+79
-32
lines changed

3 files changed

+79
-32
lines changed

auth/jwks_test.go

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ import (
1717
)
1818

1919
type jwksTester struct {
20-
privateKey *rsa.PrivateKey
21-
keyId string
22-
jwksUrl string
20+
invalidKey *rsa.PrivateKey
21+
privateKey *rsa.PrivateKey
22+
invalidKeyId string
23+
keyId string
24+
jwksUrl string
2325
}
2426

2527
func (t *jwksTester) jwksHandler(w http.ResponseWriter, r *http.Request) {
@@ -51,9 +53,17 @@ func setupJwksForTest() (*jwksTester, func()) {
5153
}
5254
kid := keyFingerprint(key)
5355

56+
invalidKey, err := rsa.GenerateKey(rand.Reader, 2048)
57+
if err != nil {
58+
panic(err)
59+
}
60+
invalidKid := keyFingerprint(invalidKey)
61+
5462
tn := jwksTester{
55-
privateKey: key,
56-
keyId: kid,
63+
invalidKey: invalidKey,
64+
privateKey: key,
65+
invalidKeyId: invalidKid,
66+
keyId: kid,
5767
}
5868

5969
s := tn.startJwksServer()
@@ -104,10 +114,11 @@ func TestJwksValidation(t *testing.T) {
104114
defer closer()
105115

106116
tests := []struct {
107-
name string
108-
claims jwt.MapClaims
109-
hasKeyId bool
110-
success bool
117+
name string
118+
claims jwt.MapClaims
119+
hasKeyId bool
120+
success bool
121+
invalidKey bool
111122
}{
112123
{
113124
name: "valid token",
@@ -142,9 +153,36 @@ func TestJwksValidation(t *testing.T) {
142153
"exp": time.Now().Add(time.Minute).Unix(),
143154
"iat": time.Now().Unix(),
144155
},
145-
success: false, // kid is technically optional, the keyfunc library requires it
156+
// the keyfunc v3.5.0+ no longer requires a kid to find the key
157+
success: true,
146158
hasKeyId: false,
147159
},
160+
{
161+
name: "invalidKey key",
162+
claims: jwt.MapClaims{
163+
"aud": "test-svc",
164+
"iss": "https://test-svc",
165+
"sub": "1234567890",
166+
"exp": time.Now().Add(time.Minute).Unix(),
167+
"iat": time.Now().Unix(),
168+
},
169+
success: false,
170+
hasKeyId: true,
171+
invalidKey: true,
172+
},
173+
{
174+
name: "invalidKey key missing kid",
175+
claims: jwt.MapClaims{
176+
"aud": "test-svc",
177+
"iss": "https://test-svc",
178+
"sub": "1234567890",
179+
"exp": time.Now().Add(time.Minute).Unix(),
180+
"iat": time.Now().Unix(),
181+
},
182+
success: false,
183+
hasKeyId: false,
184+
invalidKey: true,
185+
},
148186
{
149187
name: "expired token missing kid",
150188
claims: jwt.MapClaims{
@@ -162,11 +200,20 @@ func TestJwksValidation(t *testing.T) {
162200
for _, tt := range tests {
163201
t.Run(
164202
tt.name, func(t *testing.T) {
203+
var tokenString string
204+
var err error
165205
token := jwt.NewWithClaims(jwt.SigningMethodRS256, tt.claims)
166-
if tt.hasKeyId {
167-
token.Header["kid"] = tn.keyId
206+
if tt.invalidKey {
207+
if tt.hasKeyId {
208+
token.Header["kid"] = tn.keyId
209+
}
210+
tokenString, err = token.SignedString(tn.invalidKey)
211+
} else {
212+
if tt.hasKeyId {
213+
token.Header["kid"] = tn.keyId
214+
}
215+
tokenString, err = token.SignedString(tn.privateKey)
168216
}
169-
tokenString, err := token.SignedString(tn.privateKey)
170217
assert.NoError(t, err)
171218

172219
manager := NewJwksKeyManager(tn.jwksUrl, &ValidatableMapClaims{"aud": "test-svc"})

go.mod

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
module github.com/mbrancato/oidc-proxy
22

3-
go 1.23
3+
go 1.25.0
44

55
require (
6-
github.com/MicahParks/jwkset v0.9.6
7-
github.com/MicahParks/keyfunc/v3 v3.4.0
8-
github.com/golang-jwt/jwt/v5 v5.2.2
6+
github.com/MicahParks/jwkset v0.11.0
7+
github.com/MicahParks/keyfunc/v3 v3.7.0
8+
github.com/golang-jwt/jwt/v5 v5.3.0
99
github.com/jessevdk/go-flags v1.6.1
10-
github.com/stretchr/testify v1.10.0
11-
golang.org/x/time v0.12.0
10+
github.com/stretchr/testify v1.11.1
11+
golang.org/x/time v0.14.0
1212
gopkg.in/yaml.v3 v3.0.1
1313
)
1414

1515
require (
1616
github.com/davecgh/go-spew v1.1.1 // indirect
1717
github.com/pmezard/go-difflib v1.0.0 // indirect
18-
golang.org/x/sys v0.33.0 // indirect
18+
golang.org/x/sys v0.39.0 // indirect
1919
)

go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
github.com/MicahParks/jwkset v0.9.6 h1:Tf8l2/MOby5Kh3IkrqzThPQKfLytMERoAsGZKlyYZxg=
2-
github.com/MicahParks/jwkset v0.9.6/go.mod h1:U2oRhRaLgDCLjtpGL2GseNKGmZtLs/3O7p+OZaL5vo0=
3-
github.com/MicahParks/keyfunc/v3 v3.4.0 h1:g03TXq6NjhZyO/UkODl//abm4KiLLNRi0VhW7vGOHyg=
4-
github.com/MicahParks/keyfunc/v3 v3.4.0/go.mod h1:y6Ed3dMgNKTcpxbaQHD8mmrYDUZWJAxteddA6OQj+ag=
1+
github.com/MicahParks/jwkset v0.11.0 h1:yc0zG+jCvZpWgFDFmvs8/8jqqVBG9oyIbmBtmjOhoyQ=
2+
github.com/MicahParks/jwkset v0.11.0/go.mod h1:U2oRhRaLgDCLjtpGL2GseNKGmZtLs/3O7p+OZaL5vo0=
3+
github.com/MicahParks/keyfunc/v3 v3.7.0 h1:pdafUNyq+p3ZlvjJX1HWFP7MA3+cLpDtg69U3kITJGM=
4+
github.com/MicahParks/keyfunc/v3 v3.7.0/go.mod h1:z66bkCviwqfg2YUp+Jcc/xRE9IXLcMq6DrgV/+Htru0=
55
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
66
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
7-
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
8-
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
7+
github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo=
8+
github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE=
99
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
1010
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
1111
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
1212
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
13-
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
14-
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
15-
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
16-
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
17-
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
18-
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
13+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
14+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
15+
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
16+
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
17+
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
18+
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
1919
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2020
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2121
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)