Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update several deps #48

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ following list of differences:
- [x] `github.com/form3tech-oss/jwt-go`
- [x] `github.com/dgrijalva/jwt-go`
- Migration of the following dependencies:
- [ ] `github.com/go-jose/go-jose/v3` => `github.com/golang-jwt/jwt/v5`
- [x] `github.com/go-jose/go-jose/v3` => `github.com/go-jose/go-jose/v4`
- [x] `github.com/golang/mock` => `github.com/uber-go/mock`
- [x] `github.com/cristalhq/jwt/v4` => `github.com/golang-jwt/jwt/v5`

Expand Down
2 changes: 1 addition & 1 deletion authorize_request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"
"strings"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/pkg/errors"

"authelia.com/provider/oauth2/i18n"
Expand Down
2 changes: 1 addition & 1 deletion authorize_request_handler_oidc_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"net/url"
"testing"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package oauth2
import (
"context"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"

"authelia.com/provider/oauth2/internal/consts"
)
Expand Down
2 changes: 1 addition & 1 deletion client_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/pkg/errors"

"authelia.com/provider/oauth2/internal/consts"
Expand Down
2 changes: 1 addition & 1 deletion client_authentication_jwks_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/dgraph-io/ristretto"
"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/hashicorp/go-retryablehttp"

"authelia.com/provider/oauth2/internal/errorsx"
Expand Down
2 changes: 1 addition & 1 deletion client_authentication_jwks_strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"time"

"github.com/dgraph-io/ristretto"
"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion client_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ go 1.21

require (
github.com/dgraph-io/ristretto v0.1.1
github.com/go-jose/go-jose/v3 v3.0.1
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/uuid v1.5.0
github.com/go-jose/go-jose/v4 v4.0.1
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.1
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/parnurzeal/gorequest v0.2.16
github.com/parnurzeal/gorequest v0.3.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.8.4
github.com/tidwall/gjson v1.17.0
github.com/stretchr/testify v1.9.0
github.com/tidwall/gjson v1.17.1
go.uber.org/mock v0.4.0
golang.org/x/crypto v0.17.0
golang.org/x/net v0.19.0
golang.org/x/oauth2 v0.15.0
golang.org/x/crypto v0.21.0
golang.org/x/net v0.22.0
golang.org/x/oauth2 v0.18.0
golang.org/x/text v0.14.0
)

Expand All @@ -26,22 +26,22 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/elazarl/goproxy v0.0.0-20221015165544-a0805db90819 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/glog v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/glog v1.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/hashicorp/go-hclog v1.6.2 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moul/http2curl v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/smartystreets/goconvey v1.8.1 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
golang.org/x/sys v0.15.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
golang.org/x/sys v0.18.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
moul.io/http2curl v1.0.0 // indirect
)
125 changes: 68 additions & 57 deletions go.sum

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions handler/rfc7523/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"context"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4"
"github.com/go-jose/go-jose/v4/jwt"

"authelia.com/provider/oauth2"
hoauth2 "authelia.com/provider/oauth2/handler/oauth2"
Expand Down Expand Up @@ -53,7 +53,7 @@ func (c *Handler) HandleTokenEndpointRequest(ctx context.Context, request oauth2
return errorsx.WithStack(oauth2.ErrInvalidRequest.WithHintf("The assertion request parameter must be set when using grant_type of '%s'.", consts.GrantTypeOAuthJWTBearer))
}

token, err := jwt.ParseSigned(assertion)
token, err := jwt.ParseSigned(assertion, []jose.SignatureAlgorithm{jose.HS256, jose.HS384, jose.HS512, jose.RS256, jose.RS384, jose.RS512, jose.PS256, jose.PS384, jose.PS512, jose.ES256, jose.ES384, jose.ES512})
if err != nil {
return errorsx.WithStack(oauth2.ErrInvalidGrant.
WithHint(`Unable to parse JSON Web Token passed in "assertion" request parameter.`).
Expand Down
6 changes: 3 additions & 3 deletions handler/rfc7523/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4"
"github.com/go-jose/go-jose/v4/jwt"
"github.com/stretchr/testify/suite"
"go.uber.org/mock/gomock"

Expand Down Expand Up @@ -759,7 +759,7 @@ func (s *AuthorizeJWTGrantRequestHandlerTestSuite) createTestAssertion(cl jwt.Cl
s.FailNowf("failed to create test assertion", "failed to create signer: %s", err.Error())
}

raw, err := jwt.Signed(sig).Claims(cl).CompactSerialize()
raw, err := jwt.Signed(sig).Claims(cl).Serialize()
if err != nil {
s.FailNowf("failed to create test assertion", "failed to sign assertion: %s", err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion handler/rfc7523/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"context"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
)

// RFC7523KeyStorage holds information needed to validate jwt assertion in authorization grants.
Expand Down
2 changes: 1 addition & 1 deletion integration/authorize_jwt_bearer_required_iat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4/jwt"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion integration/authorize_jwt_bearer_required_jti_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4/jwt"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion integration/authorize_jwt_bearer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4/jwt"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
6 changes: 3 additions & 3 deletions integration/clients/jwt_bearer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"net/url"
"strings"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4"
"github.com/go-jose/go-jose/v4/jwt"

"authelia.com/provider/oauth2/internal/consts"
)
Expand Down Expand Up @@ -69,7 +69,7 @@ func (c *JWTBearer) GetToken(ctx context.Context, payloadData *JWTBearerPayload,
Claims(payloadData.Claims).
Claims(payloadData.PrivateClaims)

assertion, err := builder.CompactSerialize()
assertion, err := builder.Serialize()
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion integration/helper_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/gorilla/mux"
xoauth2 "golang.org/x/oauth2"
"golang.org/x/oauth2/clientcredentials"
Expand Down
2 changes: 1 addition & 1 deletion integration/introspect_jwt_bearer_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4/jwt"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion internal/oauth2_auth_jwt_storage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion storage/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"

"authelia.com/provider/oauth2"
"authelia.com/provider/oauth2/internal"
Expand Down
2 changes: 1 addition & 1 deletion token/jwt/claims_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"errors"
"time"

jjson "github.com/go-jose/go-jose/v3/json"
jjson "github.com/go-jose/go-jose/v4/json"

"authelia.com/provider/oauth2/internal/consts"
"authelia.com/provider/oauth2/internal/errorsx"
Expand Down
2 changes: 1 addition & 1 deletion token/jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"crypto/sha256"
"strings"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/pkg/errors"

"authelia.com/provider/oauth2/internal/errorsx"
Expand Down
2 changes: 1 addition & 1 deletion token/jwt/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"testing"
"time"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v4"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
41 changes: 27 additions & 14 deletions token/jwt/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ package jwt
import (
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"reflect"

"github.com/go-jose/go-jose/v3"
"github.com/go-jose/go-jose/v3/jwt"
"github.com/go-jose/go-jose/v4"
"github.com/go-jose/go-jose/v4/jwt"

"authelia.com/provider/oauth2/internal/consts"
"authelia.com/provider/oauth2/internal/errorsx"
Expand Down Expand Up @@ -109,7 +110,7 @@ func (t *Token) SignedString(k any) (rawToken string, err error) {
// go-jose CompactSerialize() only support explicit maps
// as claims or structs but not type aliases from maps.
claims := map[string]any(t.Claims)
rawToken, err = jwt.Signed(signer).Claims(claims).CompactSerialize()
rawToken, err = jwt.Signed(signer).Claims(claims).Serialize()
if err != nil {
err = &ValidationError{Errors: ValidationErrorClaimsInvalid, Inner: err}
return
Expand Down Expand Up @@ -158,22 +159,32 @@ func newToken(parsedToken *jwt.JSONWebToken, claims MapClaims) (*Token, error) {
return token, nil
}

// Parse methods use this callback function to supply
// the key for verification. The function receives the parsed,
// but unverified Token. This allows you to use properties in the
// Header of the token (such as `kid`) to identify which key to use.
// Keyfunc is used by parsing methods to supply the key for verification. The function receives the parsed, but
// unverified Token. This allows you to use properties in the Header of the token (such as `kid`) to identify which key
// to use.
type Keyfunc func(*Token) (any, error)

// Parse is an overload for ParseCustom which accepts all normal algs including 'none'.
func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
return ParseWithClaims(tokenString, MapClaims{}, keyFunc)
return ParseCustom(tokenString, keyFunc, "none", jose.HS256, jose.HS384, jose.HS512, jose.RS256, jose.RS384, jose.RS512, jose.PS256, jose.PS384, jose.PS512, jose.ES256, jose.ES384, jose.ES512)
}

// ParseWithClaims parses, validates, and returns a token.
// keyFunc will receive the parsed token and should return the key for validating.
// If everything is kosher, err will be nil
// ParseCustom parses, validates, and returns a token. The keyFunc will receive the parsed token and should
// return the key for validating. If everything is kosher, err will be nil.
func ParseCustom(tokenString string, keyFunc Keyfunc, algs ...jose.SignatureAlgorithm) (*Token, error) {
return ParseCustomWithClaims(tokenString, MapClaims{}, keyFunc, algs...)
}

// ParseWithClaims is an overload for ParseCustomWithClaims which accepts all normal algs including 'none'.
func ParseWithClaims(rawToken string, claims MapClaims, keyFunc Keyfunc) (*Token, error) {
return ParseCustomWithClaims(rawToken, claims, keyFunc, "none", jose.HS256, jose.HS384, jose.HS512, jose.RS256, jose.RS384, jose.RS512, jose.PS256, jose.PS384, jose.PS512, jose.ES256, jose.ES384, jose.ES512)
}

// ParseCustomWithClaims parses, validates, and returns a token with its respective claims. The keyFunc will receive the parsed token and should
// return the key for validating. If everything is kosher, err will be nil.
func ParseCustomWithClaims(rawToken string, claims MapClaims, keyFunc Keyfunc, algs ...jose.SignatureAlgorithm) (*Token, error) {
// Parse the token.
parsedToken, err := jwt.ParseSigned(rawToken)
parsedToken, err := jwt.ParseSigned(rawToken, algs)
if err != nil {
return &Token{}, &ValidationError{Errors: ValidationErrorMalformed, text: err.Error()}
}
Expand All @@ -196,17 +207,19 @@ func ParseWithClaims(rawToken string, claims MapClaims, keyFunc Keyfunc) (*Token
}

if keyFunc == nil {
// keyFunc was not provided. short circuiting validation
return token, &ValidationError{Errors: ValidationErrorUnverifiable, text: "no Keyfunc was provided."}
}

// Call keyFunc callback to get verification key
verificationKey, err := keyFunc(token)
if err != nil {
// keyFunc returned an error
if ve, ok := err.(*ValidationError); ok {
var ve *ValidationError

if errors.As(err, &ve) {
return token, ve
}

return token, &ValidationError{Errors: ValidationErrorUnverifiable, Inner: err}
}
if verificationKey == nil {
Expand Down
Loading
Loading