Skip to content

Commit

Permalink
Bump golang-jwt to v5.
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Wobrock committed Jun 27, 2024
1 parent 6d628fb commit 90dc53e
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 24 deletions.
2 changes: 1 addition & 1 deletion credentials/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"net/url"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
)

type Signer interface {
Expand Down
2 changes: 1 addition & 1 deletion credentials/signer_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/url"
"reflect"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
"golang.org/x/crypto/ed25519"
"gopkg.in/square/go-jose.v2"
Expand Down
2 changes: 1 addition & 1 deletion credentials/signer_default_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"

"github.com/ory/oathkeeper/internal"
)
Expand Down
2 changes: 1 addition & 1 deletion credentials/signer_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
"github.com/stretchr/testify/require"

Expand Down
2 changes: 1 addition & 1 deletion credentials/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"net/url"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"

"github.com/ory/fosite"
)
Expand Down
11 changes: 2 additions & 9 deletions credentials/verifier_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
"strings"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"

"github.com/ory/fosite"
Expand Down Expand Up @@ -82,15 +82,8 @@ func (v *VerifierDefault) Verify(
}

return nil, errors.WithStack(herodot.ErrBadRequest.WithReasonf(`The signing key algorithm does not match the algorithm from the token header.`))
})
}, jwt.WithIssuedAt())
if err != nil {
if e, ok := errors.Cause(err).(*jwt.ValidationError); ok {
if _, ok := errors.Cause(e.Inner).(*herodot.DefaultError); !ok {
return nil, herodot.ErrInternalServerError.WithErrorf(e.Error()).WithTrace(err)
}

return nil, e.Inner
}
return nil, err
} else if !t.Valid {
return nil, errors.WithStack(fosite.ErrInactiveToken)
Expand Down
2 changes: 1 addition & 1 deletion credentials/verifier_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/go-swagger/go-swagger v0.30.0
github.com/gobuffalo/httptest v1.5.2
github.com/gobwas/glob v0.2.3
github.com/golang-jwt/jwt/v4 v4.4.3
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2
github.com/golang/mock v1.6.0
github.com/google/go-replayers/httpreplay v1.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.4.3 h1:Hxl6lhQFj4AnOX6MLrsCb/+7tCj7DxP7VA+2rDIq5AU=
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk=
github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2 h1:xisWqjiKEff2B0KfFYGpCqc3M3zdTz+OHQHRc09FeYk=
github.com/golang/gddo v0.0.0-20190904175337-72a348e765d2/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down
4 changes: 2 additions & 2 deletions pipeline/authn/authenticator_jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/http"
"strings"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/pkg/errors"
"go.opentelemetry.io/otel/trace"

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

func (a *AuthenticatorJWT) tryEnrichResultErr(token string, err *herodot.DefaultError) *herodot.DefaultError {
t, _ := jwt.ParseWithClaims(token, jwt.MapClaims{}, nil)
t, _ := jwt.ParseWithClaims(token, jwt.MapClaims{}, nil, jwt.WithIssuedAt())
if t == nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pipeline/authn/authenticator_jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/tidwall/sjson"

"github.com/ory/herodot"
Expand Down
2 changes: 1 addition & 1 deletion pipeline/mutate/mutator_id_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/dgraph-io/ristretto"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"

"github.com/pborman/uuid"
"github.com/pkg/errors"
Expand Down
2 changes: 1 addition & 1 deletion pipeline/mutate/mutator_id_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/ory/oathkeeper/x"
"github.com/ory/x/configx"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"

"github.com/ory/oathkeeper/credentials"
"github.com/ory/oathkeeper/driver/configuration"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/okclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
"time"

"github.com/golang-jwt/jwt/v4"
"github.com/golang-jwt/jwt/v5"
"github.com/square/go-jose"

"github.com/ory/oathkeeper/x"
Expand Down

0 comments on commit 90dc53e

Please sign in to comment.