diff --git a/backend/_example/memory_store/go.mod b/backend/_example/memory_store/go.mod index d7790ab9..de8472a8 100644 --- a/backend/_example/memory_store/go.mod +++ b/backend/_example/memory_store/go.mod @@ -1,6 +1,6 @@ module github.com/umputun/remark42/memory_store -go 1.14 +go 1.15 require ( github.com/go-pkgz/jrpc v0.2.0 diff --git a/backend/_example/memory_store/go.sum b/backend/_example/memory_store/go.sum index 6812b789..4c74b2df 100644 --- a/backend/_example/memory_store/go.sum +++ b/backend/_example/memory_store/go.sum @@ -94,7 +94,7 @@ github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-pkgz/auth v1.15.1-0.20210507173239-c99a35bd9b94/go.mod h1:+dlGNQ7Y9twgP3gbMnXv2SXWvfkZ54muaTjE1SycmPM= +github.com/go-pkgz/auth v1.17.0/go.mod h1:KhMsOKhNU8fJbWKUYPhfGaYGgnZuSOIs52ojELWxOUk= github.com/go-pkgz/expirable-cache v0.0.3 h1:rTh6qNPp78z0bQE6HDhXBHUwqnV9i09Vm6dksJLXQDc= github.com/go-pkgz/expirable-cache v0.0.3/go.mod h1:+IauqN00R2FqNRLCLA+X5YljQJrwB179PfiAoMPlTlQ= github.com/go-pkgz/jrpc v0.2.0 h1:CLy/eZyekjraVrxZV18N2R1mYLMJ/nWrgdfyIOGPY/E= @@ -136,6 +136,7 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -598,22 +599,22 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/backend/app/cmd/server.go b/backend/app/cmd/server.go index acd21669..22414ae1 100644 --- a/backend/app/cmd/server.go +++ b/backend/app/cmd/server.go @@ -14,10 +14,10 @@ import ( "syscall" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/jrpc" "github.com/go-pkgz/lcw/eventbus" log "github.com/go-pkgz/lgr" + "github.com/golang-jwt/jwt" "github.com/kyokomi/emoji/v2" "github.com/pkg/errors" bolt "go.etcd.io/bbolt" diff --git a/backend/app/cmd/server_test.go b/backend/app/cmd/server_test.go index 779788d9..0edee841 100644 --- a/backend/app/cmd/server_test.go +++ b/backend/app/cmd/server_test.go @@ -15,8 +15,8 @@ import ( "testing" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/auth/token" + "github.com/golang-jwt/jwt" "github.com/umputun/go-flags" "go.uber.org/goleak" diff --git a/backend/app/rest/api/admin_test.go b/backend/app/rest/api/admin_test.go index 6c21108e..e2a2458a 100644 --- a/backend/app/rest/api/admin_test.go +++ b/backend/app/rest/api/admin_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/auth/token" cache "github.com/go-pkgz/lcw" R "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/backend/app/rest/api/rest_private.go b/backend/app/rest/api/rest_private.go index ef8706b9..1e50968f 100644 --- a/backend/app/rest/api/rest_private.go +++ b/backend/app/rest/api/rest_private.go @@ -12,7 +12,6 @@ import ( "strings" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-chi/chi/v5" "github.com/go-chi/render" "github.com/go-pkgz/auth" @@ -20,6 +19,7 @@ import ( cache "github.com/go-pkgz/lcw" log "github.com/go-pkgz/lgr" R "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/hashicorp/go-multierror" "github.com/umputun/remark42/backend/app/notify" diff --git a/backend/app/rest/api/rest_private_test.go b/backend/app/rest/api/rest_private_test.go index e87530ae..e1af1082 100644 --- a/backend/app/rest/api/rest_private_test.go +++ b/backend/app/rest/api/rest_private_test.go @@ -16,11 +16,11 @@ import ( "testing" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-chi/render" "github.com/go-pkgz/auth/token" "github.com/go-pkgz/lgr" R "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -801,7 +801,6 @@ func TestRest_EmailNotification(t *testing.T) { assert.Empty(t, mockDestination.Get()[3].Emails) } - func TestRest_TelegramNotification(t *testing.T) { ts, srv, teardown := startupT(t) defer teardown() diff --git a/backend/go.mod b/backend/go.mod index dc4b030c..05178894 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -6,19 +6,19 @@ require ( github.com/Depado/bfchroma v1.2.0 github.com/PuerkitoBio/goquery v1.5.1 github.com/alecthomas/chroma v0.7.2 - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/didip/tollbooth/v6 v6.1.0 github.com/didip/tollbooth_chi v0.0.0-20200828173446-a7173453ea21 github.com/go-chi/chi/v5 v5.0.2 github.com/go-chi/cors v1.2.0 github.com/go-chi/render v1.0.1 - github.com/go-pkgz/auth v1.15.1-0.20210507173239-c99a35bd9b94 + github.com/go-pkgz/auth v1.17.0 github.com/go-pkgz/jrpc v0.2.0 github.com/go-pkgz/lcw v0.8.1 github.com/go-pkgz/lgr v0.10.4 github.com/go-pkgz/repeater v1.1.3 github.com/go-pkgz/rest v1.9.2 github.com/go-pkgz/syncs v1.1.1 + github.com/golang-jwt/jwt v3.2.1+incompatible github.com/google/uuid v1.1.2 github.com/gorilla/feeds v1.1.1 github.com/hashicorp/go-multierror v1.1.0 diff --git a/backend/go.sum b/backend/go.sum index 46f84abd..c5f83dc9 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -107,8 +107,8 @@ github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1 github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-pkgz/auth v1.15.1-0.20210507173239-c99a35bd9b94 h1:ylLe4PJUqsJSCnb1kVWHwmFOq/dkSzkN/vQd1nnrzJQ= -github.com/go-pkgz/auth v1.15.1-0.20210507173239-c99a35bd9b94/go.mod h1:+dlGNQ7Y9twgP3gbMnXv2SXWvfkZ54muaTjE1SycmPM= +github.com/go-pkgz/auth v1.17.0 h1:m6seF+WbIUlLM96RNZvdq0kKDzZ8ynMOQpANJ1YDviQ= +github.com/go-pkgz/auth v1.17.0/go.mod h1:KhMsOKhNU8fJbWKUYPhfGaYGgnZuSOIs52ojELWxOUk= github.com/go-pkgz/expirable-cache v0.0.3 h1:rTh6qNPp78z0bQE6HDhXBHUwqnV9i09Vm6dksJLXQDc= github.com/go-pkgz/expirable-cache v0.0.3/go.mod h1:+IauqN00R2FqNRLCLA+X5YljQJrwB179PfiAoMPlTlQ= github.com/go-pkgz/jrpc v0.2.0 h1:CLy/eZyekjraVrxZV18N2R1mYLMJ/nWrgdfyIOGPY/E= @@ -156,6 +156,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md b/backend/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md deleted file mode 100644 index 7fc1f793..00000000 --- a/backend/vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md +++ /dev/null @@ -1,97 +0,0 @@ -## Migration Guide from v2 -> v3 - -Version 3 adds several new, frequently requested features. To do so, it introduces a few breaking changes. We've worked to keep these as minimal as possible. This guide explains the breaking changes and how you can quickly update your code. - -### `Token.Claims` is now an interface type - -The most requested feature from the 2.0 verison of this library was the ability to provide a custom type to the JSON parser for claims. This was implemented by introducing a new interface, `Claims`, to replace `map[string]interface{}`. We also included two concrete implementations of `Claims`: `MapClaims` and `StandardClaims`. - -`MapClaims` is an alias for `map[string]interface{}` with built in validation behavior. It is the default claims type when using `Parse`. The usage is unchanged except you must type cast the claims property. - -The old example for parsing a token looked like this.. - -```go - if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil { - fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"]) - } -``` - -is now directly mapped to... - -```go - if token, err := jwt.Parse(tokenString, keyLookupFunc); err == nil { - claims := token.Claims.(jwt.MapClaims) - fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"]) - } -``` - -`StandardClaims` is designed to be embedded in your custom type. You can supply a custom claims type with the new `ParseWithClaims` function. Here's an example of using a custom claims type. - -```go - type MyCustomClaims struct { - User string - *StandardClaims - } - - if token, err := jwt.ParseWithClaims(tokenString, &MyCustomClaims{}, keyLookupFunc); err == nil { - claims := token.Claims.(*MyCustomClaims) - fmt.Printf("Token for user %v expires %v", claims.User, claims.StandardClaims.ExpiresAt) - } -``` - -### `ParseFromRequest` has been moved - -To keep this library focused on the tokens without becoming overburdened with complex request processing logic, `ParseFromRequest` and its new companion `ParseFromRequestWithClaims` have been moved to a subpackage, `request`. The method signatues have also been augmented to receive a new argument: `Extractor`. - -`Extractors` do the work of picking the token string out of a request. The interface is simple and composable. - -This simple parsing example: - -```go - if token, err := jwt.ParseFromRequest(tokenString, req, keyLookupFunc); err == nil { - fmt.Printf("Token for user %v expires %v", token.Claims["user"], token.Claims["exp"]) - } -``` - -is directly mapped to: - -```go - if token, err := request.ParseFromRequest(req, request.OAuth2Extractor, keyLookupFunc); err == nil { - claims := token.Claims.(jwt.MapClaims) - fmt.Printf("Token for user %v expires %v", claims["user"], claims["exp"]) - } -``` - -There are several concrete `Extractor` types provided for your convenience: - -* `HeaderExtractor` will search a list of headers until one contains content. -* `ArgumentExtractor` will search a list of keys in request query and form arguments until one contains content. -* `MultiExtractor` will try a list of `Extractors` in order until one returns content. -* `AuthorizationHeaderExtractor` will look in the `Authorization` header for a `Bearer` token. -* `OAuth2Extractor` searches the places an OAuth2 token would be specified (per the spec): `Authorization` header and `access_token` argument -* `PostExtractionFilter` wraps an `Extractor`, allowing you to process the content before it's parsed. A simple example is stripping the `Bearer ` text from a header - - -### RSA signing methods no longer accept `[]byte` keys - -Due to a [critical vulnerability](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/), we've decided the convenience of accepting `[]byte` instead of `rsa.PublicKey` or `rsa.PrivateKey` isn't worth the risk of misuse. - -To replace this behavior, we've added two helper methods: `ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error)` and `ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error)`. These are just simple helpers for unpacking PEM encoded PKCS1 and PKCS8 keys. If your keys are encoded any other way, all you need to do is convert them to the `crypto/rsa` package's types. - -```go - func keyLookupFunc(*Token) (interface{}, error) { - // Don't forget to validate the alg is what you expect: - if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { - return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) - } - - // Look up key - key, err := lookupPublicKey(token.Header["kid"]) - if err != nil { - return nil, err - } - - // Unpack key from PEM encoded PKCS8 - return jwt.ParseRSAPublicKeyFromPEM(key) - } -``` diff --git a/backend/vendor/github.com/go-pkgz/auth/.golangci.yml b/backend/vendor/github.com/go-pkgz/auth/.golangci.yml index 7d32ccdc..a63783d2 100644 --- a/backend/vendor/github.com/go-pkgz/auth/.golangci.yml +++ b/backend/vendor/github.com/go-pkgz/auth/.golangci.yml @@ -62,13 +62,11 @@ issues: - text: "should have a package comment, unless it's in another file for this package" linters: - golint - - text: "Blacklisted import `crypto/md5`: weak cryptographic primitive" + - text: "G505: Blocklisted import crypto/sha1: weak cryptographic primitive" linters: - gosec - - text: "Blacklisted import `crypto/sha1`: weak cryptographic primitive" - linters: - - gosec - - text: " Use of weak cryptographic primitive" + - text: "Use of weak cryptographic primitive" linters: - gosec + exclude-use-default: false diff --git a/backend/vendor/github.com/go-pkgz/auth/README.md b/backend/vendor/github.com/go-pkgz/auth/README.md index e279e760..b99697ff 100644 --- a/backend/vendor/github.com/go-pkgz/auth/README.md +++ b/backend/vendor/github.com/go-pkgz/auth/README.md @@ -1,7 +1,7 @@ # auth - authentication via oauth2, direct and email [![Build Status](https://github.com/go-pkgz/auth/workflows/build/badge.svg)](https://github.com/go-pkgz/auth/actions) [![Coverage Status](https://coveralls.io/repos/github/go-pkgz/auth/badge.svg?branch=master)](https://coveralls.io/github/go-pkgz/auth?branch=master) [![godoc](https://godoc.org/github.com/go-pkgz/auth?status.svg)](https://pkg.go.dev/github.com/go-pkgz/auth?tab=doc) -This library provides "social login" with Github, Google, Facebook, Microsoft, Twitter, Yandex, Battle.net and Telegram as well as custom auth providers and email verification. +This library provides "social login" with Github, Google, Facebook, Microsoft, Twitter, Yandex, Battle.net, Apple and Telegram as well as custom auth providers and email verification. - Multiple oauth2 providers can be used at the same time - Special `dev` provider allows local testing and development @@ -465,6 +465,63 @@ _instructions for google oauth2 setup borrowed from [oauth2_proxy](https://githu 1. Under **"Facebook login"** / **"Settings"** fill "Valid OAuth redirect URIs" with your callback url constructed as domain + `/auth/facebook/callback` 1. Select **"App Review"** and turn public flag on. This step may ask you to provide a link to your privacy policy. + +#### Apple Auth Provider + +To configure this provider, a user requires an Apple developer account (without it setting up a sign in with Apple is impossible). [Sign in with Apple](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api) lets users log in to your app using their two-factor authentication Apple ID. + +Follow to next steps for configuring on the Apple side: + +1. Log in [to the developer account](https://developer.apple.com/account). +1. If you don't have an App ID yet, [create one](https://developer.apple.com/account/resources/identifiers/add/bundleId). Later on, you'll need **TeamID**, which is an "App ID Prefix" value. +1. Enable the "Sign in with Apple" capability for your App ID in [the Certificates, Identifiers & Profiles](https://developer.apple.com/account/resources/identifiers/list) section. +1. Create [Service ID](https://developer.apple.com/account/resources/identifiers/list/serviceId) and bind with App ID from the previous step. Apple will display the description field value to end-users on sign-in. You'll need that service **Identifier as a ClientID** later on**.** +1. Configure "Sign in with Apple" for created Service ID. Add domain where you will use that auth on to "Domains and subdomains" and its main page URL (like `https://example.com/` to "Return URLs". +1. Register a [New Key](https://developer.apple.com/account/resources/authkeys/list) (private key) for the "Sign in with Apple" feature and download it. Write down the **Key ID**. This key will be used to create [JWT](https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens#3262048) Client Secret. +1. Add your domain name and sender email in the Certificates, Identifiers & Profiles >> [More](https://developer.apple.com/account/resources/services/configure) section as a new Email Source. + +After completing the previous steps, you can proceed with configuring the Apple auth provider. Here are the parameters for AppleConfig: + +- _ClientID_ (**required**) - Service ID identifier which is used for Sign with Apple +- _TeamID_ (**required**) - Identifier a developer account (use as prefix for all App ID) +- _KeyID_ (**required**) - Identifier a generated key for Sign with Apple + + +```go + // apple config parameters + appleCfg := provider.AppleConfig{ + TeamID: os.Getenv("AEXMPL_APPLE_TID"), // developer account identifier + ClientID: os.Getenv("AEXMPL_APPLE_CID"), // service identifier + KeyID: os.Getenv("AEXMPL_APPLE_KEYID"), // private key identifier + } +``` + +Then add an Apple provider that accepts the following parameters: +* `appleConfig (provider.AppleConfig)` created above +* `privateKeyLoader (PrivateKeyLoaderInterface)` + +`PrivateKeyLoaderInterface` [implements](https://github.com/go-pkgz/auth/blob/master/provider/apple.go#L98:L100) a loader for the private key (which you downloaded above) to create a `client_secret`. The user can use a pre-defined function `provider.LoadApplePrivateKeyFromFile(filePath string)` to load the private key from local file. + +`AddAppleProvide` tries to load private key at call and return an error if load failed. Always check error when calling this provider. + +```go + if err := service.AddAppleProvider(appleCfg, provider.LoadApplePrivateKeyFromFile("PATH_TO_PRIVATE_KEY_FILE")); err != nil { + log.Fatalf("[ERROR] failed create to AppleProvider: %v", err) + } +``` + +**Limitation:** + +* Map a userName (if specific scope defined) is only sent in the upon initial user sign up. + Subsequent logins to your app using Sign In with Apple with the same account do not share any user info and will only return a user identifier in IDToken claims. + This behaves correctly until a user delete sign in for you service with Apple ID in own Apple account profile (security section). + It is recommend that you securely cache the at first login containing the user info for bind it with a user UID at next login. + Provider always get user `UID` (`sub` claim) in `IDToken`. + +* Apple doesn't have an API for fetch avatar and user info. + +See [example](https://github.com/go-pkgz/auth/blob/master/_example/main.go#L83:L93) before use. + #### Yandex Auth Provider 1. Create a new **"OAuth App"**: https://oauth.yandex.com/client/new diff --git a/backend/vendor/github.com/go-pkgz/auth/auth.go b/backend/vendor/github.com/go-pkgz/auth/auth.go index 40cfacd6..02f22452 100644 --- a/backend/vendor/github.com/go-pkgz/auth/auth.go +++ b/backend/vendor/github.com/go-pkgz/auth/auth.go @@ -257,6 +257,26 @@ func (s *Service) AddDevProvider(port int) { s.providers = append(s.providers, provider.NewService(provider.NewDev(p))) } +// AddAppleProvider allow SignIn with Apple ID +func (s *Service) AddAppleProvider(appleConfig provider.AppleConfig, privKeyLoader provider.PrivateKeyLoaderInterface) error { + p := provider.Params{ + URL: s.opts.URL, + JwtService: s.jwtService, + Issuer: s.issuer, + AvatarSaver: s.avatarProxy, + L: s.logger, + } + + // Error checking at create need for catch one when apple private key init + appleProvider, err := provider.NewApple(p, appleConfig, privKeyLoader) + if err != nil { + return errors.Wrap(err, "an AppleProvider creating failed") + } + + s.providers = append(s.providers, provider.NewService(appleProvider)) + return nil +} + // AddCustomProvider adds custom provider (e.g. https://gopkg.in/oauth2.v3) func (s *Service) AddCustomProvider(name string, client Client, copts provider.CustomHandlerOpt) { p := provider.Params{ diff --git a/backend/vendor/github.com/go-pkgz/auth/go.mod b/backend/vendor/github.com/go-pkgz/auth/go.mod index debb3667..8baf3f0b 100644 --- a/backend/vendor/github.com/go-pkgz/auth/go.mod +++ b/backend/vendor/github.com/go-pkgz/auth/go.mod @@ -4,9 +4,9 @@ go 1.15 require ( github.com/dghubble/oauth1 v0.7.0 - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/go-pkgz/repeater v1.1.3 github.com/go-pkgz/rest v1.9.2 + github.com/golang-jwt/jwt v3.2.1+incompatible github.com/microcosm-cc/bluemonday v1.0.9 github.com/nullrocks/identicon v0.0.0-20180626043057-7875f45b0022 github.com/pkg/errors v0.9.1 diff --git a/backend/vendor/github.com/go-pkgz/auth/go.sum b/backend/vendor/github.com/go-pkgz/auth/go.sum index cd0d00e0..6e1d8d97 100644 --- a/backend/vendor/github.com/go-pkgz/auth/go.sum +++ b/backend/vendor/github.com/go-pkgz/auth/go.sum @@ -100,6 +100,8 @@ github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWe github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/apple.go b/backend/vendor/github.com/go-pkgz/auth/provider/apple.go new file mode 100644 index 00000000..1e1cfdbd --- /dev/null +++ b/backend/vendor/github.com/go-pkgz/auth/provider/apple.go @@ -0,0 +1,526 @@ +package provider + +// Implementation sign in with Apple for allow users to sign in to web services using their Apple ID. +// For correct work this provider user must has Apple developer account and correct configure "sign in with Apple" at in +// See more: https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api +// and https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_js/incorporating_sign_in_with_apple_into_other_platforms + +import ( + "context" + "crypto" + "crypto/ecdsa" + "crypto/sha1" + "crypto/x509" + "encoding/json" + "encoding/pem" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "os" + "strings" + "time" + + "golang.org/x/oauth2" + + "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" + "github.com/pkg/errors" + + "github.com/go-pkgz/auth/logger" + "github.com/go-pkgz/auth/token" +) + +const ( + // appleAuthURL is the base authentication URL for sign in with Apple ID and fetch request code for user validation request. + appleAuthURL = "https://appleid.apple.com/auth/authorize" + + // appleTokenURL is the endpoint for verifying tokens and get user unique ID and E-mail + appleTokenURL = "https://appleid.apple.com/auth/token" // #nosec + + // appleRequestContentType is the valid type which apple REST API accept only + appleRequestContentType = "application/x-www-form-urlencoded" + + // UserAgent required to every request to Apple REST API + defaultUserAgent = "github.com/go-pkgz/auth" + + // AcceptJSONHeader is the content to accept from response + AcceptJSONHeader = "application/json" +) + +// appleVerificationResponse is based on https://developer.apple.com/documentation/signinwithapplerestapi/tokenresponse +type appleVerificationResponse struct { + // A token used to access allowed user data, but now not implemented public interface for it. + AccessToken string `json:"access_token"` + + // Access token type, always equal the "bearer". + TokenType string `json:"token_type"` + + // Access token expires time in seconds. Always equal 3600 seconds (1 hour) + ExpiresIn int `json:"expires_in"` + + // The refresh token used to regenerate new access tokens. + RefreshToken string `json:"refresh_token"` + + // Main JSON Web Token that contains the user’s identity information. + IDToken string `json:"id_token"` + + // Used to capture any error returned in response. Always check error for empty + Error string `json:"error"` +} + +// AppleConfig is the main oauth2 required parameters for "Sign in with Apple" +type AppleConfig struct { + ClientID string // the identifier Services ID for your app created in Apple developer account. + TeamID string // developer Team ID (10 characters), required for create JWT. It available, after signed in at developer account, by link: https://developer.apple.com/account/#/membership + KeyID string // private key ID assigned to private key obtain in Apple developer account + + scopes []string // for this package allow only username scope and UID in token claims. Apple service API provide only "email" and "name" scope values (https://developer.apple.com/documentation/sign_in_with_apple/clientconfigi/3230955-scope) + privateKey interface{} // private key from Apple obtained in developer account (the keys section). Required for create the Client Secret (https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens#3262048) + publicKey crypto.PublicKey // need for validate sign of token + clientSecret string // is the JWT client secret will create after first call and then used until expired + jwkURL string // URL for fetch JWK Apple keys, need redefine for tests +} + +// AppleHandler implements login via Apple ID +type AppleHandler struct { + Params + + // all of these fields specific to particular oauth2 provider + name string + // infoURL string not implemented at Apple side + endpoint oauth2.Endpoint + + mapUser func(jwt.MapClaims) token.User // map info from InfoURL to User + conf AppleConfig // main config for Apple auth provider + + PrivateKeyLoader PrivateKeyLoaderInterface // custom function interface for load private key + +} + +// PrivateKeyLoaderInterface interface for implement custom loader for Apple private key from user source +type PrivateKeyLoaderInterface interface { + LoadPrivateKey() ([]byte, error) +} + +// LoadFromFileFunc is the type for use pre-defined private key loader function +// Path field must be set with actual path to private key file +type LoadFromFileFunc struct { + Path string +} + +// LoadApplePrivateKeyFromFile return instance for pre-defined loader function from local file +func LoadApplePrivateKeyFromFile(path string) LoadFromFileFunc { + return LoadFromFileFunc{ + Path: path, + } +} + +// LoadPrivateKey implement pre-defined (built-in) PrivateKeyLoaderInterface interface method for load private key from local file +func (lf LoadFromFileFunc) LoadPrivateKey() ([]byte, error) { + if lf.Path == "" { + return nil, errors.New("empty private key path not allowed") + } + + kFile, err := os.Open(lf.Path) + if err != nil { + return nil, err + } + keyValue, err := ioutil.ReadAll(kFile) + if err != nil { + return nil, err + } + err = kFile.Close() + return keyValue, err +} + +// NewApple create new AppleProvider instance with a user parameters +// Private key must be set, when instance create call, for create `client_secret` +func NewApple(p Params, appleCfg AppleConfig, privateKeyLoader PrivateKeyLoaderInterface) (*AppleHandler, error) { + + if p.L == nil { + p.L = logger.NoOp + } + var emptyParams []string + + // check required parameters filled + if appleCfg.ClientID == "" { + emptyParams = append(emptyParams, "ClientID") + } + if appleCfg.TeamID == "" { + emptyParams = append(emptyParams, "TeamID") + } + if appleCfg.KeyID == "" { + emptyParams = append(emptyParams, "KeyID") + } + if len(emptyParams) > 0 { + return nil, fmt.Errorf("required params missed: %s", strings.Join(emptyParams, ", ")) + } + + ah := AppleHandler{ + Params: p, + name: "apple", // static name for an Apple provider + + conf: AppleConfig{ + ClientID: appleCfg.ClientID, + TeamID: appleCfg.TeamID, + KeyID: appleCfg.KeyID, + scopes: []string{"name"}, + jwkURL: appleKeysURL, + }, + + endpoint: oauth2.Endpoint{ + AuthURL: appleAuthURL, + TokenURL: appleTokenURL, + }, + + mapUser: func(claims jwt.MapClaims) token.User { + var usr token.User + if uid, ok := claims["sub"]; ok { + usr.ID = "apple_" + token.HashID(sha1.New(), uid.(string)) + } + return usr + }, + } + + if privateKeyLoader == nil { + return nil, errors.New("private key loader undefined") + } + + ah.PrivateKeyLoader = privateKeyLoader + + err := ah.initPrivateKey() + return &ah, err +} + +// initPrivateKey parse Apple private key and assign to AppleHandler +func (ah *AppleHandler) initPrivateKey() error { + + sKey, err := ah.PrivateKeyLoader.LoadPrivateKey() + if err != nil { + return errors.Wrap(err, "problem with private key loading") + } + + block, _ := pem.Decode(sKey) + if block == nil { + return errors.New("empty block after decoding") + } + ah.conf.privateKey, err = x509.ParsePKCS8PrivateKey(block.Bytes) + if err != nil { + return err + } + ah.conf.publicKey = ah.conf.privateKey.(*ecdsa.PrivateKey).Public() + ah.conf.clientSecret, err = ah.createClientSecret() + if err != nil { + return err + } + return nil +} + +// tokenKeyFunc use for verify JWT sign, it receive the parsed token and should return the key for validating. +func (ah *AppleHandler) tokenKeyFunc(jwtToken *jwt.Token) (interface{}, error) { + if jwtToken == nil { + return nil, errors.New("failed to call token keyFunc, because token is nil") + } + return ah.conf.publicKey, nil // extract public key from private key +} + +// Name of the provider +func (ah *AppleHandler) Name() string { return ah.name } + +// LoginHandler - GET */{provider-name}/login +func (ah *AppleHandler) LoginHandler(w http.ResponseWriter, r *http.Request) { + + ah.Logf("[DEBUG] login with %s", ah.Name()) + // make state (random) and store in session + state, err := randToken() + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to make oauth2 state") + return + } + + cid, err := randToken() + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to make claim's id") + return + } + + claims := token.Claims{ + Handshake: &token.Handshake{ + State: state, + From: r.URL.Query().Get("from"), + }, + SessionOnly: r.URL.Query().Get("session") != "" && r.URL.Query().Get("session") != "0", + StandardClaims: jwt.StandardClaims{ + Id: cid, + Audience: r.URL.Query().Get("site"), + ExpiresAt: time.Now().Add(30 * time.Minute).Unix(), + NotBefore: time.Now().Add(-1 * time.Minute).Unix(), + }, + } + + if _, err = ah.JwtService.Set(w, claims); err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to set token") + return + } + + // return login url + loginURL, err := ah.prepareLoginURL(state, r.URL.Path) + if err != nil { + errMsg := fmt.Sprintf("prepare login url for [%s] provider failed", ah.name) + ah.Logf("[ERROR] %s", errMsg) + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, errMsg) + return + } + ah.Logf("[DEBUG] login url %s, claims=%+v", loginURL, claims) + + http.Redirect(w, r, loginURL, http.StatusFound) +} + +// AuthHandler fills user info and redirects to "from" url. This is callback url redirected locally by browser +// GET /callback +func (ah AppleHandler) AuthHandler(w http.ResponseWriter, r *http.Request) { + + // read response form data + if err := r.ParseForm(); err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "read callback response from data failed") + return + } + + state := r.FormValue("state") // state value which sent with auth request + code := r.FormValue("code") // client code for validation + + // response with user name filed return only one time at first login, next login field user doesn't exist + // until user delete sign with Apple ID in account profile (security section) + // example response: {"name":{"firstName":"Chan","lastName":"Lu"},"email":"user@email.com"} + jUser := r.FormValue("user") // json string with user name + + oauthClaims, _, err := ah.JwtService.Get(r) + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to get token") + return + } + + if oauthClaims.Handshake == nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusForbidden, nil, "invalid handshake token") + return + } + + retrievedState := oauthClaims.Handshake.State + if retrievedState == "" || retrievedState != state { + rest.SendErrorJSON(w, r, ah.L, http.StatusForbidden, nil, "unexpected state") + return + } + + var resp appleVerificationResponse + err = ah.exchange(context.Background(), code, ah.makeRedirURL(r.URL.Path), &resp) + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "exchange failed") + return + } + ah.Logf("[DEBUG] response data %+v", resp) + if resp.Error != "" { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, nil, fmt.Sprintf("fetch IDtoken response error: %s", resp.Error)) + return + } + + // trying to fetch Apple public key (JWK) for verify token signature, it need for verify IDToken received from Apple + keySet, err := fetchAppleJWK(r.Context(), ah.conf.jwkURL) + if err != nil { + ah.L.Logf("[ERROR] failed to fetch JWK from Apple key service: " + err.Error()) + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, nil, fmt.Sprintf("failed to fetch JWK from Apple key service: %s", resp.Error)) + return + } + + // get token claims for extract uid (and email or name if they exist in scope) + tokenClaims := jwt.MapClaims{} + _, err = jwt.ParseWithClaims(resp.IDToken, tokenClaims, keySet.keyFunc) + if err != nil { + ah.L.Logf("[ERROR] failed to get claims: " + err.Error()) + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, nil, fmt.Sprintf("failed to token validation, key is invalid: %s", resp.Error)) + return + } + + u := ah.mapUser(tokenClaims) + + u, err = setAvatar(ah.AvatarSaver, u, &http.Client{Timeout: 5 * time.Second}) + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to save avatar to proxy") + return + } + + // try parse username if one exist at response or noname assign + ah.parseUserData(&u, jUser) + + cid, err := randToken() + if err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to make claim's id") + return + } + + claims := token.Claims{ + User: &u, + StandardClaims: jwt.StandardClaims{ + Issuer: ah.Issuer, + Id: cid, + Audience: oauthClaims.Audience, + }, + SessionOnly: false, + } + + if _, err = ah.JwtService.Set(w, claims); err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusInternalServerError, err, "failed to set token") + return + } + + ah.Logf("[DEBUG] user info %+v", u) + + // redirect to back url if presented in login query params + if oauthClaims.Handshake != nil && oauthClaims.Handshake.From != "" { + http.Redirect(w, r, oauthClaims.Handshake.From, http.StatusTemporaryRedirect) + return + } + rest.RenderJSON(w, &u) + +} + +// LogoutHandler - GET /logout +func (ah AppleHandler) LogoutHandler(w http.ResponseWriter, r *http.Request) { + if _, _, err := ah.JwtService.Get(r); err != nil { + rest.SendErrorJSON(w, r, ah.L, http.StatusForbidden, err, "logout not allowed") + return + } + ah.JwtService.Reset(w) +} + +// exchange sends the validation token request and gets access token and user claims +// (e.g. https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens) +func (ah *AppleHandler) exchange(ctx context.Context, code, redirectURI string, result *appleVerificationResponse) error { + + // check client_secret for valid and recreate new (client_secret JWT) if required + if tkn, err := jwt.Parse(ah.conf.clientSecret, ah.tokenKeyFunc); err != nil || tkn == nil { + ah.conf.clientSecret, err = ah.createClientSecret() + if err != nil { + return errors.Wrap(err, "client secret create failed") + } + } + + data := url.Values{} + data.Set("client_id", ah.conf.ClientID) + data.Set("client_secret", ah.conf.clientSecret) // JWT signed with Apple private key + data.Set("code", code) + data.Set("redirect_uri", redirectURI) // redirect URL can't refer to localhost and must have trusted certificate and https protocol + data.Set("grant_type", "authorization_code") + + client := http.Client{Timeout: time.Second * 5} + req, err := http.NewRequestWithContext(ctx, "POST", ah.endpoint.TokenURL, strings.NewReader(data.Encode())) + if err != nil { + return err + } + + req.Header.Add("content-type", appleRequestContentType) + req.Header.Add("accept", AcceptJSONHeader) + req.Header.Add("user-agent", defaultUserAgent) // apple requires a user agent + + res, err := client.Do(req) + if err != nil { + return err + } + + // Trying to decode (unmarshal json) data of response + err = json.NewDecoder(res.Body).Decode(result) + if err != nil { + return errors.Wrap(err, "unmarshalling data from apple service response failed") + } + + defer func() { + if err = res.Body.Close(); err != nil { + ah.L.Logf("[ERROR] close request body failed when get access token: %v", err) + } + }() + + // If above operation done successfully checking a response code and error descriptions, if one exist. + // Apple service will response either 200 (OK) or 400 (any error). + if res.StatusCode != http.StatusOK || result.Error != "" { + return fmt.Errorf("apple token service error: %s", result.Error) + } + + return err +} + +// createClientSecret use for create the JWT client secret required to make requests to the Apple validation server. +// for more details go to link: https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens#3262048 +func (ah *AppleHandler) createClientSecret() (string, error) { + + if ah.conf.privateKey == nil { + return "", errors.New("private key can't be empty") + } + // Create a claims + now := time.Now() + exp := now.Add(time.Minute * 30).Unix() // default value + + claims := &jwt.StandardClaims{ + Issuer: ah.conf.TeamID, + IssuedAt: now.Unix(), + ExpiresAt: exp, + Audience: "https://appleid.apple.com", + Subject: ah.conf.ClientID, + } + + tkn := jwt.NewWithClaims(jwt.SigningMethodES256, claims) + tkn.Header["alg"] = "ES256" + tkn.Header["kid"] = ah.conf.KeyID + + return tkn.SignedString(ah.conf.privateKey) +} + +func (ah *AppleHandler) parseUserData(user *token.User, jUser string) { + + type UserData struct { + Name struct { + FirstName string `json:"firstName"` + LastName string `json:"lastName"` + } `json:"name"` + Email string `json:"email"` + } + + var userData UserData + + // Catch error for log only. No need break flow if user name doesn't exist + if err := json.Unmarshal([]byte(jUser), &userData); err != nil { + ah.L.Logf("[DEBUG] failed to parse user data %s: %v", user, err) + user.Name = "noname_" + user.ID[6:12] // paste noname if user name failed to parse + return + } + + user.Name = fmt.Sprintf("%s %s", userData.Name.FirstName, userData.Name.LastName) +} + +func (ah *AppleHandler) prepareLoginURL(state, path string) (string, error) { + + scopesList := strings.Join(ah.conf.scopes, " ") + + authURL, err := url.Parse(ah.endpoint.AuthURL) + if err != nil { + return "", err + } + + query := authURL.Query() + query.Set("state", state) + query.Set("response_type", "code") + query.Set("response_mode", "form_post") + query.Set("client_id", ah.conf.ClientID) + query.Set("scope", scopesList) + query.Set("redirect_uri", ah.makeRedirURL(path)) + authURL.RawQuery = query.Encode() + + return authURL.String(), nil + +} + +func (ah AppleHandler) makeRedirURL(path string) string { + elems := strings.Split(path, "/") + newPath := strings.Join(elems[:len(elems)-1], "/") + + return strings.TrimRight(ah.URL, "/") + strings.TrimSuffix(newPath, "/") + urlCallbackSuffix +} diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/apple_pubkeys.go b/backend/vendor/github.com/go-pkgz/auth/provider/apple_pubkeys.go new file mode 100644 index 00000000..a1207391 --- /dev/null +++ b/backend/vendor/github.com/go-pkgz/auth/provider/apple_pubkeys.go @@ -0,0 +1,179 @@ +package provider + +// This is implementation need for fetch and parse Apple public key to verify the ID token signature. +// Apple endpoint can return multiple keys, and the count of keys can vary over time. +// From this set of keys, select the key with the matching key identifier (kid) to verify the signature of any JSON Web Token (JWT) issued by Apple. +// For more details go to link https://developer.apple.com/documentation/sign_in_with_apple/fetch_apple_s_public_key_for_verifying_token_signature + +import ( + "context" + "crypto/rsa" + "encoding/base64" + "encoding/json" + "fmt" + "io/ioutil" + "math/big" + "net/http" + "time" + + "github.com/golang-jwt/jwt" + "github.com/pkg/errors" +) + +// appleKeysURL is the endpoint URL for fetch Apple’s public key +const appleKeysURL = "https://appleid.apple.com/auth/keys" + +// applePublicKey is the Apple public key object +// Apple public key is a data structure that represents a cryptographic key as JSON Web Key (JWK) +// based on RFC-7517 https://datatracker.ietf.org/doc/html/rfc7517 +type applePublicKey struct { + ID string `json:"id"` + KeyType string `json:"kty"` + Usage string `json:"use"` + Algorithm string `json:"alg"` + + publicKey *rsa.PublicKey +} + +// appleRawKey is raw json object +type appleRawKey struct { + KTY string `json:"kty"` + KID string `json:"kid"` + Use string `json:"use"` + Alg string `json:"alg"` + N string `json:"n"` + E string `json:"e"` +} + +// fetchAppleJWK to make web request to Apple service for get Apple public keys (JWK) +func fetchAppleJWK(ctx context.Context, keyURL string) (set appleKeySet, err error) { + client := http.Client{Timeout: time.Second * 5} + + if keyURL == "" { + keyURL = appleKeysURL + } + + req, err := http.NewRequestWithContext(ctx, "GET", keyURL, nil) + + if err != nil { + return set, errors.Wrap(err, "failed to prepare new request for fetch Apple public keys") + } + + req.Header.Add("accept", AcceptJSONHeader) + req.Header.Add("user-agent", defaultUserAgent) // apple requires a user agent + + res, err := client.Do(req) + if err != nil { + return set, errors.Wrap(err, "failed to fetch Apple public keys") + } + + data, err := ioutil.ReadAll(res.Body) + if err != nil { + return set, errors.Wrap(err, "failed read data after Apple public key fetched") + } + defer func() { _ = res.Body.Close() }() + + set, err = parseAppleJWK(data) + if err != nil { + return set, errors.Wrap(err, "get set of apple public key failed") + } + + return set, nil +} + +// parseAppleJWK try parse keys data for return set of Apple public keys, if no errors +func parseAppleJWK(keyData []byte) (set appleKeySet, err error) { + + var rawKeys struct { + Keys []appleRawKey `json:"keys"` + } + + set = appleKeySet{} // init key sets + keys := make(map[string]*applePublicKey) + + if err = json.Unmarshal(keyData, &rawKeys); err != nil { + return set, errors.Wrap(err, "parse json data with Apple keys failed") + } + for _, rawKey := range rawKeys.Keys { + key, err := parseApplePublicKey(rawKey) + if err != nil { + return set, err // no idea to continue iterate keys if at least one return error, need will check all public keys + } + keys[key.ID] = key + } + + set.keys = keys + return set, nil +} + +// parseApplePublicKey to make parse JWK data for create an Apple public key +func parseApplePublicKey(rawKey appleRawKey) (key *applePublicKey, err error) { + + key = &applePublicKey{ + KeyType: rawKey.KTY, + ID: rawKey.KID, + Usage: rawKey.Use, + Algorithm: rawKey.Alg, + } + + // parse and create public key + if err := key.createApplePublicKey(rawKey.N, rawKey.E); err != nil { + return nil, err + } + + return key, nil +} + +// createApplePublicKey need to decodes a base64-encoded larger integer from Apple's key format. +func (apk *applePublicKey) createApplePublicKey(n, e string) error { + + bufferN, err := base64.URLEncoding.WithPadding(base64.NoPadding).DecodeString(n) // decode modulus + if err != nil { + return errors.Wrap(err, "failed to decode Apple public key modulus (n)") + } + + bufferE, err := base64.URLEncoding.WithPadding(base64.NoPadding).DecodeString(e) // decode exponent + if err != nil { + return errors.Wrap(err, "failed to decode Apple public key exponent (e)") + } + + // create rsa public key from JWK data + apk.publicKey = &rsa.PublicKey{ + N: big.NewInt(0).SetBytes(bufferN), + E: int(big.NewInt(0).SetBytes(bufferE).Int64()), + } + return nil +} + +// appleKeySet is a set of Apple public keys +type appleKeySet struct { + keys map[string]*applePublicKey +} + +// get return Apple public key with specific KeyID (kid) +func (aks *appleKeySet) get(kid string) (keys *applePublicKey, err error) { + if aks.keys == nil || len(aks.keys) == 0 { + return nil, errors.New("failed to get key in appleKeySet, key set is nil or empty") + } + + if val, ok := aks.keys[kid]; ok { + return val, nil + } + return nil, fmt.Errorf("key with ID %s not found", kid) +} + +// keyFunc use for JWT verify with specific public key +func (aks *appleKeySet) keyFunc(token *jwt.Token) (interface{}, error) { + + keyID, ok := token.Header["kid"].(string) + if !ok { + return nil, errors.New("get JWT kid header not found") + } + key, err := aks.get(keyID) + + if err != nil { + return nil, err + } + + return key.publicKey, nil +} diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/direct.go b/backend/vendor/github.com/go-pkgz/auth/provider/direct.go index 70e22ea2..a0fdcaea 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/direct.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/direct.go @@ -1,14 +1,14 @@ package provider import ( - "crypto/sha1" + "crypto/sha1" //nolint "encoding/json" "mime" "net/http" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/pkg/errors" "github.com/go-pkgz/auth/logger" diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/oauth1.go b/backend/vendor/github.com/go-pkgz/auth/provider/oauth1.go index 5d227d00..73cb11f9 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/oauth1.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/oauth1.go @@ -9,8 +9,8 @@ import ( "time" "github.com/dghubble/oauth1" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/go-pkgz/auth/logger" "github.com/go-pkgz/auth/token" @@ -176,7 +176,7 @@ func (h Oauth1Handler) makeRedirURL(path string) string { elems := strings.Split(path, "/") newPath := strings.Join(elems[:len(elems)-1], "/") - return strings.TrimRight(h.URL, "/") + strings.TrimRight(newPath, "/") + urlCallbackSuffix + return strings.TrimSuffix(h.URL, "/") + strings.TrimSuffix(newPath, "/") + urlCallbackSuffix } // initOauth2Handler makes oauth1 handler for given provider diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/oauth2.go b/backend/vendor/github.com/go-pkgz/auth/provider/oauth2.go index 4d404849..644de4af 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/oauth2.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/oauth2.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "golang.org/x/oauth2" "github.com/go-pkgz/auth/logger" @@ -77,7 +77,7 @@ func initOauth2Handler(p Params, service Oauth2Handler) Oauth2Handler { // Name returns provider name func (p Oauth2Handler) Name() string { return p.name } -// LoginHandler - GET /login?from=redirect-back-url&site=siteID&session=1 +// LoginHandler - GET /login?from=redirect-back-url&[site|aud]=siteID&session=1&noava=1 func (p Oauth2Handler) LoginHandler(w http.ResponseWriter, r *http.Request) { p.Logf("[DEBUG] login with %s", p.Name()) @@ -94,6 +94,11 @@ func (p Oauth2Handler) LoginHandler(w http.ResponseWriter, r *http.Request) { return } + aud := r.URL.Query().Get("site") // legacy, for back compat + if aud == "" { + aud = r.URL.Query().Get("aud") + } + claims := token.Claims{ Handshake: &token.Handshake{ State: state, @@ -102,10 +107,11 @@ func (p Oauth2Handler) LoginHandler(w http.ResponseWriter, r *http.Request) { SessionOnly: r.URL.Query().Get("session") != "" && r.URL.Query().Get("session") != "0", StandardClaims: jwt.StandardClaims{ Id: cid, - Audience: r.URL.Query().Get("site"), + Audience: aud, ExpiresAt: time.Now().Add(30 * time.Minute).Unix(), NotBefore: time.Now().Add(-1 * time.Minute).Unix(), }, + NoAva: r.URL.Query().Get("noava") == "1", } if _, err := p.JwtService.Set(w, claims); err != nil { @@ -180,6 +186,9 @@ func (p Oauth2Handler) AuthHandler(w http.ResponseWriter, r *http.Request) { p.Logf("[DEBUG] got raw user info %+v", jData) u := p.mapUser(jData, data) + if oauthClaims.NoAva { + u.Picture = "" // reset picture on no avatar request + } u, err = setAvatar(p.AvatarSaver, u, client) if err != nil { rest.SendErrorJSON(w, r, p.L, http.StatusInternalServerError, err, "failed to save avatar to proxy") @@ -199,6 +208,7 @@ func (p Oauth2Handler) AuthHandler(w http.ResponseWriter, r *http.Request) { Audience: oauthClaims.Audience, }, SessionOnly: oauthClaims.SessionOnly, + NoAva: oauthClaims.NoAva, } if _, err = p.JwtService.Set(w, claims); err != nil { @@ -229,5 +239,5 @@ func (p Oauth2Handler) makeRedirURL(path string) string { elems := strings.Split(path, "/") newPath := strings.Join(elems[:len(elems)-1], "/") - return strings.TrimRight(p.URL, "/") + strings.TrimRight(newPath, "/") + urlCallbackSuffix + return strings.TrimSuffix(p.URL, "/") + strings.TrimSuffix(newPath, "/") + urlCallbackSuffix } diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/providers.go b/backend/vendor/github.com/go-pkgz/auth/provider/providers.go index 10d96b6b..08d3c16f 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/providers.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/providers.go @@ -2,7 +2,7 @@ package provider import ( - "crypto/sha1" + "crypto/sha1" //nolint "encoding/json" "fmt" diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/sender/email.go b/backend/vendor/github.com/go-pkgz/auth/provider/sender/email.go index 2990879f..7a33e364 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/sender/email.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/sender/email.go @@ -122,6 +122,7 @@ func (em *Email) client() (c *smtp.Client, err error) { tlsConf := &tls.Config{ InsecureSkipVerify: false, ServerName: em.Host, + MinVersion: tls.VersionTLS12, } conn, e := tls.Dial("tcp", srvAddress, tlsConf) if e != nil { diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/telegram.go b/backend/vendor/github.com/go-pkgz/auth/provider/telegram.go index 6a367606..178c9bdc 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/telegram.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/telegram.go @@ -14,9 +14,9 @@ import ( "sync" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/repeater" "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/pkg/errors" "github.com/go-pkgz/auth/logger" diff --git a/backend/vendor/github.com/go-pkgz/auth/provider/verify.go b/backend/vendor/github.com/go-pkgz/auth/provider/verify.go index 9adde3a3..d58e07e8 100644 --- a/backend/vendor/github.com/go-pkgz/auth/provider/verify.go +++ b/backend/vendor/github.com/go-pkgz/auth/provider/verify.go @@ -8,8 +8,8 @@ import ( "text/template" "time" - "github.com/dgrijalva/jwt-go" "github.com/go-pkgz/rest" + "github.com/golang-jwt/jwt" "github.com/pkg/errors" "github.com/go-pkgz/auth/avatar" diff --git a/backend/vendor/github.com/go-pkgz/auth/token/jwt.go b/backend/vendor/github.com/go-pkgz/auth/token/jwt.go index 8e0cd3e4..95ae1fee 100644 --- a/backend/vendor/github.com/go-pkgz/auth/token/jwt.go +++ b/backend/vendor/github.com/go-pkgz/auth/token/jwt.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/dgrijalva/jwt-go" + "github.com/golang-jwt/jwt" "github.com/pkg/errors" ) @@ -24,6 +24,7 @@ type Claims struct { User *User `json:"user,omitempty"` // user info SessionOnly bool `json:"sess_only,omitempty"` Handshake *Handshake `json:"handshake,omitempty"` // used for oauth handshake + NoAva bool `json:"no-ava,omitempty"` // disable avatar, always use identicon } // Handshake used for oauth handshake diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/.gitignore b/backend/vendor/github.com/golang-jwt/jwt/.gitignore similarity index 68% rename from backend/vendor/github.com/dgrijalva/jwt-go/.gitignore rename to backend/vendor/github.com/golang-jwt/jwt/.gitignore index 80bed650..09573e01 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/.gitignore +++ b/backend/vendor/github.com/golang-jwt/jwt/.gitignore @@ -1,4 +1,4 @@ .DS_Store bin - +.idea/ diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/.travis.yml b/backend/vendor/github.com/golang-jwt/jwt/.travis.yml similarity index 65% rename from backend/vendor/github.com/dgrijalva/jwt-go/.travis.yml rename to backend/vendor/github.com/golang-jwt/jwt/.travis.yml index 1027f56c..036a862f 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/.travis.yml +++ b/backend/vendor/github.com/golang-jwt/jwt/.travis.yml @@ -5,9 +5,7 @@ script: - go test -v ./... go: - - 1.3 - - 1.4 - - 1.5 - - 1.6 - 1.7 - - tip + - 1.8 + - 1.9 + - 1.10 diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/LICENSE b/backend/vendor/github.com/golang-jwt/jwt/LICENSE similarity index 96% rename from backend/vendor/github.com/dgrijalva/jwt-go/LICENSE rename to backend/vendor/github.com/golang-jwt/jwt/LICENSE index df83a9c2..35dbc252 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/LICENSE +++ b/backend/vendor/github.com/golang-jwt/jwt/LICENSE @@ -1,4 +1,5 @@ Copyright (c) 2012 Dave Grijalva +Copyright (c) 2021 golang-jwt maintainers Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/backend/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md b/backend/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md new file mode 100644 index 00000000..c4efbd2a --- /dev/null +++ b/backend/vendor/github.com/golang-jwt/jwt/MIGRATION_GUIDE.md @@ -0,0 +1,22 @@ +## Migration Guide (v3.2.1) + +Starting from [v3.2.1](https://github.com/golang-jwt/jwt/releases/tag/v3.2.1]), the import path has changed from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt`. Future releases will be using the `github.com/golang-jwt/jwt` import path and continue the existing versioning scheme of `v3.x.x+incompatible`. Backwards-compatible patches and fixes will be done on the `v3` release branch, where as new build-breaking features will be developed in a `v4` release, possibly including a SIV-style import path. + +### go.mod replacement + +In a first step, the easiest way is to use `go mod edit` to issue a replacement. + +``` +go mod edit -replace github.com/dgrijalva/jwt-go=github.com/golang-jwt/jwt@v3.2.1+incompatible +go mod tidy +``` + +This will still keep the old import path in your code but replace it with the new package and also introduce a new indirect dependency to `github.com/golang-jwt/jwt`. Try to compile your project; it should still work. + +### Cleanup + +If your code still consistently builds, you can replace all occurences of `github.com/dgrijalva/jwt-go` with `github.com/golang-jwt/jwt`, either manually or by using tools such as `sed`. Finally, the `replace` directive in the `go.mod` file can be removed. + +## Older releases (before v3.2.0) + +The original migration guide for older releases can be found at https://github.com/dgrijalva/jwt-go/blob/master/MIGRATION_GUIDE.md. \ No newline at end of file diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/README.md b/backend/vendor/github.com/golang-jwt/jwt/README.md similarity index 57% rename from backend/vendor/github.com/dgrijalva/jwt-go/README.md rename to backend/vendor/github.com/golang-jwt/jwt/README.md index d358d881..13c31c09 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/README.md +++ b/backend/vendor/github.com/golang-jwt/jwt/README.md @@ -1,25 +1,27 @@ # jwt-go -[![Build Status](https://travis-ci.org/dgrijalva/jwt-go.svg?branch=master)](https://travis-ci.org/dgrijalva/jwt-go) -[![GoDoc](https://godoc.org/github.com/dgrijalva/jwt-go?status.svg)](https://godoc.org/github.com/dgrijalva/jwt-go) +[![build](https://github.com/golang-jwt/jwt/actions/workflows/build.yml/badge.svg)](https://github.com/golang-jwt/jwt/actions/workflows/build.yml) +[![Go Reference](https://pkg.go.dev/badge/github.com/golang-jwt/jwt.svg)](https://pkg.go.dev/github.com/golang-jwt/jwt) -A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html) +A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](https://datatracker.ietf.org/doc/html/rfc7519). -**NEW VERSION COMING:** There have been a lot of improvements suggested since the version 3.0.0 released in 2016. I'm working now on cutting two different releases: 3.2.0 will contain any non-breaking changes or enhancements. 4.0.0 will follow shortly which will include breaking changes. See the 4.0.0 milestone to get an idea of what's coming. If you have other ideas, or would like to participate in 4.0.0, now's the time. If you depend on this library and don't want to be interrupted, I recommend you use your dependency mangement tool to pin to version 3. +**IMPORT PATH CHANGE:** Starting from [v3.2.1](https://github.com/golang-jwt/jwt/releases/tag/v3.2.1), the import path has changed from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt`. After the original author of the library suggested migrating the maintenance of `jwt-go`, a dedicated team of open source maintainers decided to clone the existing library into this repository. See [dgrijalva/jwt-go#462](https://github.com/dgrijalva/jwt-go/issues/462) for a detailed discussion on this topic. -**SECURITY NOTICE:** Some older versions of Go have a security issue in the cryotp/elliptic. Recommendation is to upgrade to at least 1.8.3. See issue #216 for more detail. +Future releases will be using the `github.com/golang-jwt/jwt` import path and continue the existing versioning scheme of `v3.x.x+incompatible`. Backwards-compatible patches and fixes will be done on the `v3` release branch, where as new build-breaking features will be developed in a `v4` release, possibly including a SIV-style import path. -**SECURITY NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided. +**SECURITY NOTICE:** Some older versions of Go have a security issue in the crypto/elliptic. Recommendation is to upgrade to at least 1.8.3. See issue [dgrijalva/jwt-go#216](https://github.com/dgrijalva/jwt-go/issues/216) for more detail. + +**SECURITY NOTICE:** It's important that you [validate the `alg` presented is what you expect](https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/). This library attempts to make it easy to do the right thing by requiring key types match the expected alg, but you should take the extra step to verify it in your usage. See the examples provided. ## What the heck is a JWT? JWT.io has [a great introduction](https://jwt.io/introduction) to JSON Web Tokens. -In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](http://tools.ietf.org/html/rfc4648) encoded. The last part is the signature, encoded the same way. +In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](https://datatracker.ietf.org/doc/html/rfc4648) encoded. The last part is the signature, encoded the same way. The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used. -The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [the RFC](http://self-issued.info/docs/draft-jones-json-web-token.html) for information about reserved keys and the proper way to add your own. +The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519) for information about reserved keys and the proper way to add your own. ## What's in the box? @@ -27,31 +29,31 @@ This library supports the parsing and verification as well as the generation and ## Examples -See [the project documentation](https://godoc.org/github.com/dgrijalva/jwt-go) for examples of usage: +See [the project documentation](https://pkg.go.dev/github.com/golang-jwt/jwt) for examples of usage: -* [Simple example of parsing and validating a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-Parse--Hmac) -* [Simple example of building and signing a token](https://godoc.org/github.com/dgrijalva/jwt-go#example-New--Hmac) -* [Directory of Examples](https://godoc.org/github.com/dgrijalva/jwt-go#pkg-examples) +* [Simple example of parsing and validating a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-Parse-Hmac) +* [Simple example of building and signing a token](https://pkg.go.dev/github.com/golang-jwt/jwt#example-New-Hmac) +* [Directory of Examples](https://pkg.go.dev/github.com/golang-jwt/jwt#pkg-examples) ## Extensions This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`. -Here's an example of an extension that integrates with the Google App Engine signing tools: https://github.com/someone1/gcp-jwt-go +Here's an example of an extension that integrates with multiple Google Cloud Platform signing tools (AppEngine, IAM API, Cloud KMS): https://github.com/someone1/gcp-jwt-go ## Compliance -This library was last reviewed to comply with [RTF 7519](http://www.rfc-editor.org/info/rfc7519) dated May 2015 with a few notable differences: +This library was last reviewed to comply with [RTF 7519](https://datatracker.ietf.org/doc/html/rfc7519) dated May 2015 with a few notable differences: -* In order to protect against accidental use of [Unsecured JWTs](http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#UnsecuredJWT), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key. +* In order to protect against accidental use of [Unsecured JWTs](https://datatracker.ietf.org/doc/html/rfc7519#section-6), tokens using `alg=none` will only be accepted if the constant `jwt.UnsafeAllowNoneSignatureType` is provided as the key. ## Project Status & Versioning This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason). -This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `master`. Periodically, versions will be tagged from `master`. You can find all the releases on [the project releases page](https://github.com/dgrijalva/jwt-go/releases). +This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `main`. Periodically, versions will be tagged from `main`. You can find all the releases on [the project releases page](https://github.com/golang-jwt/jwt/releases). -While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v3`. It will do the right thing WRT semantic versioning. +While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/golang-jwt/jwt.v3`. It will do the right thing WRT semantic versioning. **BREAKING CHANGES:*** * Version 3.0.0 includes _a lot_ of changes from the 2.x line, including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes is available in `VERSION_HISTORY.md`. See `MIGRATION_GUIDE.md` for more information on updating your code. @@ -79,9 +81,9 @@ Asymmetric signing methods, such as RSA, use different keys for signing and veri Each signing method expects a different object type for its signing keys. See the package documentation for details. Here are the most common ones: -* The [HMAC signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation -* The [RSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation -* The [ECDSA signing method](https://godoc.org/github.com/dgrijalva/jwt-go#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation +* The [HMAC signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodHMAC) (`HS256`,`HS384`,`HS512`) expect `[]byte` values for signing and validation +* The [RSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodRSA) (`RS256`,`RS384`,`RS512`) expect `*rsa.PrivateKey` for signing and `*rsa.PublicKey` for validation +* The [ECDSA signing method](https://pkg.go.dev/github.com/golang-jwt/jwt#SigningMethodECDSA) (`ES256`,`ES384`,`ES512`) expect `*ecdsa.PrivateKey` for signing and `*ecdsa.PublicKey` for validation ### JWT and OAuth @@ -93,8 +95,12 @@ Without going too far down the rabbit hole, here's a description of the interact * OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token. * Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL. +### Troubleshooting + +This library uses descriptive error messages whenever possible. If you are not getting the expected result, have a look at the errors. The most common place people get stuck is providing the correct type of key to the parser. See the above section on signing methods and key types. + ## More -Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go). +Documentation can be found [on pkg.go.dev](https://pkg.go.dev/github.com/golang-jwt/jwt). The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. You'll also find several implementation examples in the documentation. diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md b/backend/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md similarity index 94% rename from backend/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md rename to backend/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md index 63702983..dac737bc 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md +++ b/backend/vendor/github.com/golang-jwt/jwt/VERSION_HISTORY.md @@ -1,5 +1,11 @@ ## `jwt-go` Version History +#### 3.2.1 + +* **Import Path Change**: See MIGRATION_GUIDE.md for tips on updating your code + * Changed the import path from `github.com/dgrijalva/jwt-go` to `github.com/golang-jwt/jwt` +* Fixed type confusing issue between `string` and `[]string` in `VerifyAudience` ([#12](https://github.com/golang-jwt/jwt/pull/12)). This fixes CVE-2020-26160 + #### 3.2.0 * Added method `ParseUnverified` to allow users to split up the tasks of parsing and validation @@ -115,4 +121,4 @@ It is likely the only integration change required here will be to change `func(t * First versioned release * API stabilized * Supports creating, signing, parsing, and validating JWT tokens -* Supports RS256 and HS256 signing methods \ No newline at end of file +* Supports RS256 and HS256 signing methods diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/claims.go b/backend/vendor/github.com/golang-jwt/jwt/claims.go similarity index 83% rename from backend/vendor/github.com/dgrijalva/jwt-go/claims.go rename to backend/vendor/github.com/golang-jwt/jwt/claims.go index f0228f02..f1dba3cb 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/claims.go +++ b/backend/vendor/github.com/golang-jwt/jwt/claims.go @@ -35,18 +35,18 @@ func (c StandardClaims) Valid() error { // The claims below are optional, by default, so if they are set to the // default value in Go, let's not fail the verification for them. - if c.VerifyExpiresAt(now, false) == false { + if !c.VerifyExpiresAt(now, false) { delta := time.Unix(now, 0).Sub(time.Unix(c.ExpiresAt, 0)) vErr.Inner = fmt.Errorf("token is expired by %v", delta) vErr.Errors |= ValidationErrorExpired } - if c.VerifyIssuedAt(now, false) == false { + if !c.VerifyIssuedAt(now, false) { vErr.Inner = fmt.Errorf("Token used before issued") vErr.Errors |= ValidationErrorIssuedAt } - if c.VerifyNotBefore(now, false) == false { + if !c.VerifyNotBefore(now, false) { vErr.Inner = fmt.Errorf("token is not valid yet") vErr.Errors |= ValidationErrorNotValidYet } @@ -61,7 +61,7 @@ func (c StandardClaims) Valid() error { // Compares the aud claim against cmp. // If required is false, this method will return true if the value matches or is unset func (c *StandardClaims) VerifyAudience(cmp string, req bool) bool { - return verifyAud(c.Audience, cmp, req) + return verifyAud([]string{c.Audience}, cmp, req) } // Compares the exp claim against cmp. @@ -90,15 +90,27 @@ func (c *StandardClaims) VerifyNotBefore(cmp int64, req bool) bool { // ----- helpers -func verifyAud(aud string, cmp string, required bool) bool { - if aud == "" { +func verifyAud(aud []string, cmp string, required bool) bool { + if len(aud) == 0 { return !required } - if subtle.ConstantTimeCompare([]byte(aud), []byte(cmp)) != 0 { - return true - } else { - return false + // use a var here to keep constant time compare when looping over a number of claims + result := false + + var stringClaims string + for _, a := range aud { + if subtle.ConstantTimeCompare([]byte(a), []byte(cmp)) != 0 { + result = true + } + stringClaims = stringClaims + a } + + // case where "" is sent in one or many aud claims + if len(stringClaims) == 0 { + return !required + } + + return result } func verifyExp(exp int64, now int64, required bool) bool { diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/doc.go b/backend/vendor/github.com/golang-jwt/jwt/doc.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/doc.go rename to backend/vendor/github.com/golang-jwt/jwt/doc.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/ecdsa.go b/backend/vendor/github.com/golang-jwt/jwt/ecdsa.go similarity index 98% rename from backend/vendor/github.com/dgrijalva/jwt-go/ecdsa.go rename to backend/vendor/github.com/golang-jwt/jwt/ecdsa.go index f9773812..d310af1c 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/ecdsa.go +++ b/backend/vendor/github.com/golang-jwt/jwt/ecdsa.go @@ -88,11 +88,11 @@ func (m *SigningMethodECDSA) Verify(signingString, signature string, key interfa hasher.Write([]byte(signingString)) // Verify the signature - if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus == true { + if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus { return nil - } else { - return ErrECDSAVerification } + + return ErrECDSAVerification } // Implements the Sign method from SigningMethod diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go b/backend/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go similarity index 93% rename from backend/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go rename to backend/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go index d19624b7..db9f4be7 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go +++ b/backend/vendor/github.com/golang-jwt/jwt/ecdsa_utils.go @@ -25,7 +25,9 @@ func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { // Parse the key var parsedKey interface{} if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { - return nil, err + if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { + return nil, err + } } var pkey *ecdsa.PrivateKey diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/errors.go b/backend/vendor/github.com/golang-jwt/jwt/errors.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/errors.go rename to backend/vendor/github.com/golang-jwt/jwt/errors.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/hmac.go b/backend/vendor/github.com/golang-jwt/jwt/hmac.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/hmac.go rename to backend/vendor/github.com/golang-jwt/jwt/hmac.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/map_claims.go b/backend/vendor/github.com/golang-jwt/jwt/map_claims.go similarity index 84% rename from backend/vendor/github.com/dgrijalva/jwt-go/map_claims.go rename to backend/vendor/github.com/golang-jwt/jwt/map_claims.go index 291213c4..ba290f42 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/map_claims.go +++ b/backend/vendor/github.com/golang-jwt/jwt/map_claims.go @@ -10,10 +10,24 @@ import ( // This is the default claims type if you don't supply one type MapClaims map[string]interface{} -// Compares the aud claim against cmp. +// VerifyAudience Compares the aud claim against cmp. // If required is false, this method will return true if the value matches or is unset func (m MapClaims) VerifyAudience(cmp string, req bool) bool { - aud, _ := m["aud"].(string) + var aud []string + switch v := m["aud"].(type) { + case string: + aud = append(aud, v) + case []string: + aud = v + case []interface{}: + for _, a := range v { + vs, ok := a.(string) + if !ok { + return false + } + aud = append(aud, vs) + } + } return verifyAud(aud, cmp, req) } @@ -27,7 +41,7 @@ func (m MapClaims) VerifyExpiresAt(cmp int64, req bool) bool { v, _ := exp.Int64() return verifyExp(v, cmp, req) } - return req == false + return !req } // Compares the iat claim against cmp. @@ -40,7 +54,7 @@ func (m MapClaims) VerifyIssuedAt(cmp int64, req bool) bool { v, _ := iat.Int64() return verifyIat(v, cmp, req) } - return req == false + return !req } // Compares the iss claim against cmp. @@ -60,7 +74,7 @@ func (m MapClaims) VerifyNotBefore(cmp int64, req bool) bool { v, _ := nbf.Int64() return verifyNbf(v, cmp, req) } - return req == false + return !req } // Validates time based claims "exp, iat, nbf". @@ -71,17 +85,17 @@ func (m MapClaims) Valid() error { vErr := new(ValidationError) now := TimeFunc().Unix() - if m.VerifyExpiresAt(now, false) == false { + if !m.VerifyExpiresAt(now, false) { vErr.Inner = errors.New("Token is expired") vErr.Errors |= ValidationErrorExpired } - if m.VerifyIssuedAt(now, false) == false { + if !m.VerifyIssuedAt(now, false) { vErr.Inner = errors.New("Token used before issued") vErr.Errors |= ValidationErrorIssuedAt } - if m.VerifyNotBefore(now, false) == false { + if !m.VerifyNotBefore(now, false) { vErr.Inner = errors.New("Token is not valid yet") vErr.Errors |= ValidationErrorNotValidYet } diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/none.go b/backend/vendor/github.com/golang-jwt/jwt/none.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/none.go rename to backend/vendor/github.com/golang-jwt/jwt/none.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/parser.go b/backend/vendor/github.com/golang-jwt/jwt/parser.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/parser.go rename to backend/vendor/github.com/golang-jwt/jwt/parser.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/rsa.go b/backend/vendor/github.com/golang-jwt/jwt/rsa.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/rsa.go rename to backend/vendor/github.com/golang-jwt/jwt/rsa.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go b/backend/vendor/github.com/golang-jwt/jwt/rsa_pss.go similarity index 71% rename from backend/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go rename to backend/vendor/github.com/golang-jwt/jwt/rsa_pss.go index 10ee9db8..c0147086 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go +++ b/backend/vendor/github.com/golang-jwt/jwt/rsa_pss.go @@ -12,9 +12,14 @@ import ( type SigningMethodRSAPSS struct { *SigningMethodRSA Options *rsa.PSSOptions + // VerifyOptions is optional. If set overrides Options for rsa.VerifyPPS. + // Used to accept tokens signed with rsa.PSSSaltLengthAuto, what doesn't follow + // https://tools.ietf.org/html/rfc7518#section-3.5 but was used previously. + // See https://github.com/dgrijalva/jwt-go/issues/285#issuecomment-437451244 for details. + VerifyOptions *rsa.PSSOptions } -// Specific instances for RS/PS and company +// Specific instances for RS/PS and company. var ( SigningMethodPS256 *SigningMethodRSAPSS SigningMethodPS384 *SigningMethodRSAPSS @@ -24,13 +29,15 @@ var ( func init() { // PS256 SigningMethodPS256 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ + SigningMethodRSA: &SigningMethodRSA{ Name: "PS256", Hash: crypto.SHA256, }, - &rsa.PSSOptions{ + Options: &rsa.PSSOptions{ + SaltLength: rsa.PSSSaltLengthEqualsHash, + }, + VerifyOptions: &rsa.PSSOptions{ SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA256, }, } RegisterSigningMethod(SigningMethodPS256.Alg(), func() SigningMethod { @@ -39,13 +46,15 @@ func init() { // PS384 SigningMethodPS384 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ + SigningMethodRSA: &SigningMethodRSA{ Name: "PS384", Hash: crypto.SHA384, }, - &rsa.PSSOptions{ + Options: &rsa.PSSOptions{ + SaltLength: rsa.PSSSaltLengthEqualsHash, + }, + VerifyOptions: &rsa.PSSOptions{ SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA384, }, } RegisterSigningMethod(SigningMethodPS384.Alg(), func() SigningMethod { @@ -54,13 +63,15 @@ func init() { // PS512 SigningMethodPS512 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ + SigningMethodRSA: &SigningMethodRSA{ Name: "PS512", Hash: crypto.SHA512, }, - &rsa.PSSOptions{ + Options: &rsa.PSSOptions{ + SaltLength: rsa.PSSSaltLengthEqualsHash, + }, + VerifyOptions: &rsa.PSSOptions{ SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA512, }, } RegisterSigningMethod(SigningMethodPS512.Alg(), func() SigningMethod { @@ -94,7 +105,12 @@ func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interf hasher := m.Hash.New() hasher.Write([]byte(signingString)) - return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, m.Options) + opts := m.Options + if m.VerifyOptions != nil { + opts = m.VerifyOptions + } + + return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, opts) } // Implements the Sign method from SigningMethod diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go b/backend/vendor/github.com/golang-jwt/jwt/rsa_utils.go similarity index 95% rename from backend/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go rename to backend/vendor/github.com/golang-jwt/jwt/rsa_utils.go index a5ababf9..14c78c29 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go +++ b/backend/vendor/github.com/golang-jwt/jwt/rsa_utils.go @@ -8,7 +8,7 @@ import ( ) var ( - ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key") + ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be a PEM encoded PKCS1 or PKCS8 key") ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key") ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key") ) diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/signing_method.go b/backend/vendor/github.com/golang-jwt/jwt/signing_method.go similarity index 100% rename from backend/vendor/github.com/dgrijalva/jwt-go/signing_method.go rename to backend/vendor/github.com/golang-jwt/jwt/signing_method.go diff --git a/backend/vendor/github.com/dgrijalva/jwt-go/token.go b/backend/vendor/github.com/golang-jwt/jwt/token.go similarity index 99% rename from backend/vendor/github.com/dgrijalva/jwt-go/token.go rename to backend/vendor/github.com/golang-jwt/jwt/token.go index d637e086..99868d29 100644 --- a/backend/vendor/github.com/dgrijalva/jwt-go/token.go +++ b/backend/vendor/github.com/golang-jwt/jwt/token.go @@ -65,7 +65,7 @@ func (t *Token) SignedString(key interface{}) (string, error) { func (t *Token) SigningString() (string, error) { var err error parts := make([]string, 2) - for i, _ := range parts { + for i := range parts { var jsonValue []byte if i == 0 { if jsonValue, err = json.Marshal(t.Header); err != nil { diff --git a/backend/vendor/modules.txt b/backend/vendor/modules.txt index a2a1cc0f..60bbd4d8 100644 --- a/backend/vendor/modules.txt +++ b/backend/vendor/modules.txt @@ -68,9 +68,6 @@ github.com/davecgh/go-spew/spew # github.com/dghubble/oauth1 v0.7.0 github.com/dghubble/oauth1 github.com/dghubble/oauth1/twitter -# github.com/dgrijalva/jwt-go v3.2.0+incompatible -## explicit -github.com/dgrijalva/jwt-go # github.com/didip/tollbooth/v6 v6.1.0 ## explicit github.com/didip/tollbooth/v6 @@ -96,7 +93,7 @@ github.com/go-chi/cors # github.com/go-chi/render v1.0.1 ## explicit github.com/go-chi/render -# github.com/go-pkgz/auth v1.15.1-0.20210507173239-c99a35bd9b94 +# github.com/go-pkgz/auth v1.17.0 ## explicit github.com/go-pkgz/auth github.com/go-pkgz/auth/avatar @@ -139,6 +136,9 @@ github.com/go-redis/redis/v7/internal/proto github.com/go-redis/redis/v7/internal/util # github.com/go-stack/stack v1.8.0 github.com/go-stack/stack +# github.com/golang-jwt/jwt v3.2.1+incompatible +## explicit +github.com/golang-jwt/jwt # github.com/golang/protobuf v1.4.2 github.com/golang/protobuf/proto # github.com/golang/snappy v0.0.1