Skip to content

Commit 361177a

Browse files
chore: update golang-jwt to v5 (#1171)
1 parent acb2584 commit 361177a

14 files changed

+23
-23
lines changed

credentials/signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"context"
88
"net/url"
99

10-
"github.com/golang-jwt/jwt/v4"
10+
"github.com/golang-jwt/jwt/v5"
1111
)
1212

1313
type Signer interface {

credentials/signer_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"reflect"
1212

1313
"github.com/go-jose/go-jose/v3"
14-
"github.com/golang-jwt/jwt/v4"
14+
"github.com/golang-jwt/jwt/v5"
1515
"github.com/pkg/errors"
1616
"golang.org/x/crypto/ed25519"
1717
)

credentials/signer_default_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/golang-jwt/jwt/v4"
12+
"github.com/golang-jwt/jwt/v5"
1313

1414
"github.com/ory/oathkeeper/internal"
1515
)

credentials/signer_default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/golang-jwt/jwt/v4"
13+
"github.com/golang-jwt/jwt/v5"
1414
"github.com/pkg/errors"
1515
"github.com/stretchr/testify/require"
1616

credentials/verifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"context"
88
"net/url"
99

10-
"github.com/golang-jwt/jwt/v4"
10+
"github.com/golang-jwt/jwt/v5"
1111

1212
"github.com/ory/fosite"
1313
)

credentials/verifier_default.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"fmt"
1111
"strings"
1212

13-
"github.com/golang-jwt/jwt/v4"
13+
"github.com/golang-jwt/jwt/v5"
1414
"github.com/pkg/errors"
1515

1616
"github.com/ory/fosite"
@@ -82,14 +82,14 @@ func (v *VerifierDefault) Verify(
8282
}
8383

8484
return nil, errors.WithStack(herodot.ErrBadRequest.WithReasonf(`The signing key algorithm does not match the algorithm from the token header.`))
85-
})
85+
}, jwt.WithIssuedAt())
8686
if err != nil {
87-
if e, ok := errors.Cause(err).(*jwt.ValidationError); ok {
88-
if _, ok := errors.Cause(e.Inner).(*herodot.DefaultError); !ok {
89-
return nil, herodot.ErrInternalServerError.WithErrorf(e.Error()).WithTrace(err)
90-
}
91-
92-
return nil, e.Inner
87+
if errors.Is(err, jwt.ErrTokenUnverifiable) ||
88+
errors.Is(err, jwt.ErrTokenUnverifiable) ||
89+
errors.Is(err, jwt.ErrTokenSignatureInvalid) ||
90+
errors.Is(err, jwt.ErrTokenInvalidClaims) ||
91+
errors.Is(err, jwt.ErrTokenMalformed) {
92+
return nil, herodot.ErrInternalServerError.WithErrorf(err.Error()).WithTrace(err)
9393
}
9494
return nil, err
9595
} else if !t.Valid {

credentials/verifier_default_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13-
"github.com/golang-jwt/jwt/v4"
13+
"github.com/golang-jwt/jwt/v5"
1414
"github.com/pkg/errors"
1515
"github.com/stretchr/testify/assert"
1616
"github.com/stretchr/testify/require"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/go-swagger/go-swagger v0.30.0
2828
github.com/gobuffalo/httptest v1.5.2
2929
github.com/gobwas/glob v0.2.3
30-
github.com/golang-jwt/jwt/v4 v4.4.3
30+
github.com/golang-jwt/jwt/v5 v5.2.1
3131
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2
3232
github.com/golang/mock v1.6.0
3333
github.com/google/go-replayers/httpreplay v1.1.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
409409
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
410410
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
411411
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
412-
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
413-
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
412+
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
413+
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
414414
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2 h1:xisWqjiKEff2B0KfFYGpCqc3M3zdTz+OHQHRc09FeYk=
415415
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
416416
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=

pipeline/authn/authenticator_jwt.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"net/http"
1010
"strings"
1111

12-
"github.com/golang-jwt/jwt/v4"
12+
"github.com/golang-jwt/jwt/v5"
1313
"github.com/pkg/errors"
1414
"go.opentelemetry.io/otel/trace"
1515

@@ -130,7 +130,7 @@ func (a *AuthenticatorJWT) Authenticate(r *http.Request, session *Authentication
130130
}
131131

132132
func (a *AuthenticatorJWT) tryEnrichResultErr(token string, err *herodot.DefaultError) *herodot.DefaultError {
133-
t, _ := jwt.ParseWithClaims(token, jwt.MapClaims{}, nil)
133+
t, _ := jwt.ParseWithClaims(token, jwt.MapClaims{}, nil, jwt.WithIssuedAt())
134134
if t == nil {
135135
return err
136136
}

pipeline/authn/authenticator_jwt_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"testing"
1313
"time"
1414

15-
"github.com/golang-jwt/jwt/v4"
15+
"github.com/golang-jwt/jwt/v5"
1616
"github.com/tidwall/sjson"
1717

1818
"github.com/ory/herodot"

pipeline/mutate/mutator_id_token.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
"github.com/dgraph-io/ristretto"
1717

18-
"github.com/golang-jwt/jwt/v4"
18+
"github.com/golang-jwt/jwt/v5"
1919

2020
"github.com/pborman/uuid"
2121
"github.com/pkg/errors"

pipeline/mutate/mutator_id_token_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/ory/oathkeeper/x"
2323
"github.com/ory/x/configx"
2424

25-
"github.com/golang-jwt/jwt/v4"
25+
"github.com/golang-jwt/jwt/v5"
2626

2727
"github.com/ory/oathkeeper/credentials"
2828
"github.com/ory/oathkeeper/driver/configuration"

test/e2e/okclient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"time"
1414

1515
"github.com/go-jose/go-jose/v3"
16-
"github.com/golang-jwt/jwt/v4"
16+
"github.com/golang-jwt/jwt/v5"
1717

1818
"github.com/ory/oathkeeper/x"
1919
"github.com/ory/x/cmdx"

0 commit comments

Comments
 (0)