diff --git a/AUTHORS.txt b/AUTHORS.txt index 10f2719..24f0707 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -4,6 +4,7 @@ Douglas Danger Manley Duncan Crawford Elijah Oyekunle Fabrizio Moscon +Gagan Kalra Joey Lee Jon Bretman Josh Hornby diff --git a/CHANGELOG.md b/CHANGELOG.md index f8415b9..bd58975 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changes +## 2.8 + +JWT functionality has been removed. We did not want to continue to support +functionality that may break or be compromised easily, and is difficult to use +correctly. + +To achieve the same functionality, you can integrate your own JWT code, or look +at the first draft of pull request #99. + +## 2.7 + +Dependency update + ## 2.6 Add "incoming" option for VoiceGrant. diff --git a/go.mod b/go.mod index faf8945..b31cbd9 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,11 @@ module github.com/kevinburke/twilio-go go 1.22 require ( - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/kevinburke/go-types v0.0.0-20210723172823-2deba1f80ba7 github.com/kevinburke/handlers v0.0.0-20231107221000-2cbf18acad0d github.com/kevinburke/rest v0.0.0-20240617045629-3ed0ad3487f0 github.com/ttacon/libphonenumber v1.2.1 - golang.org/x/net v0.26.0 + golang.org/x/net v0.27.0 golang.org/x/sync v0.7.0 golang.org/x/text v0.16.0 ) @@ -16,12 +15,12 @@ require ( require ( github.com/go-stack/stack v1.8.1 // indirect github.com/gofrs/uuid v4.4.0+incompatible // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/inconshreveable/log15 v3.0.0-testing.5+incompatible // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect - golang.org/x/sys v0.21.0 // indirect - golang.org/x/term v0.21.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/term v0.22.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect ) diff --git a/go.sum b/go.sum index f2f8e3d..4eba98c 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,9 @@ -github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/inconshreveable/log15 v3.0.0-testing.5+incompatible h1:VryeOTiaZfAzwx8xBcID1KlJCeoWSIpsNbSk+/D2LNk= @@ -20,30 +17,28 @@ github.com/kevinburke/rest v0.0.0-20240617045629-3ed0ad3487f0/go.mod h1:dcLMT8KO github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 h1:5u+EJUQiosu3JFX0XS0qTf5FznsMOzTjGqavBGuCbo0= github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2/go.mod h1:4kyMkleCiLkgY6z8gK5BkI01ChBtxR0ro3I1ZDcGM3w= github.com/ttacon/libphonenumber v1.2.1 h1:fzOfY5zUADkCkbIafAed11gL1sW+bJ26p6zWLBMElR4= github.com/ttacon/libphonenumber v1.2.1/go.mod h1:E0TpmdVMq5dyVlQ7oenAkhsLu86OkUl+yR4OAxyEg/M= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= -golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= diff --git a/token/access_token_grant_test.go b/token/access_token_grant_test.go index e9364c6..70ccbc6 100644 --- a/token/access_token_grant_test.go +++ b/token/access_token_grant_test.go @@ -12,6 +12,7 @@ const ( PUSH_CRED_SID = "cde3xsw2zaq1vfr4bgtnhy6mju78ijhgtf" PROFILE_SID = "erfergrtugdifuovudsfhguidhgouidrhg" ROOM_SID = "erfergrtugdifuovudsfhguidhgouidrhd" + APP_SID = "asdfghjkl" ) func TestIPMessageGrant(t *testing.T) { diff --git a/token/access_token_test.go b/token/access_token_test.go deleted file mode 100644 index fbf50cb..0000000 --- a/token/access_token_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package token - -import ( - "testing" - "time" - - jwt "github.com/dgrijalva/jwt-go" -) - -const ( - ACC_SID = "123456" - API_KEY = "abcdef" - API_SECRET = "asdfghjklqwertyuiopzxcvbnm" - IDENTITY = "johnsmith" - APP_SID = "asdfghjkl" -) - -type myCustomClaims struct { - Grants map[string]interface{} `json:"grants"` - *jwt.StandardClaims -} - -func TestJWT(t *testing.T) { - t.Parallel() - - accTkn := New(ACC_SID, API_KEY, API_SECRET, IDENTITY, time.Hour) - accTkn.NotBefore = time.Now() - convGrant := NewConversationsGrant(APP_SID) - - accTkn.AddGrant(convGrant) - jwtString, err := accTkn.JWT() - - if err != nil { - t.Error("Unexpected error when generating the token", err) - } - expected := "eyJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIiwidHlwIjoiSldUIn0.eyJncmFudHMiOnsiaWRlbnRpdHkiOiJqb2huc21pdGgiLCJydGMiOnsiY29uZmlndXJhdGlvbl9wcm9maWxlX3NpZCI6ImFzZGZnaGprbCJ9fSwiZXhwIjoxNTM0OTUwNjA3LCJqdGkiOiJhYmNkZWYtMTUzNDk0NzAwNyIsImlhdCI6MTUzNDk0NzAwNywiaXNzIjoiYWJjZGVmIiwibmJmIjoxNTM0OTQ3MDA3LCJzdWIiOiIxMjM0NTYifQ.IeDnzbr9ENCtwY-qPZFQ0B_YsUmI4feH0lYZcd79Fk4" - _ = expected // not an exact match due to time.Now timestamps - if jwtString == "" { - t.Error("token returned is empty") - } - - token, err := jwt.ParseWithClaims(jwtString, &myCustomClaims{}, func(tkn *jwt.Token) (interface{}, error) { - return []byte(API_SECRET), nil - }) - if err != nil { - t.Error("Unexpected error when generating the token", err) - } - - claims := token.Claims.(*myCustomClaims) - - if claims.StandardClaims == nil { - t.Error("Claim doesn't contain a standard claims struct") - } - - if claims.StandardClaims.ExpiresAt == 0 { - t.Error("ExpiredAt is not set") - } - - if claims.StandardClaims.Id == "" { - t.Error("ID is not set") - } - - if claims.StandardClaims.IssuedAt == 0 { - t.Error("IssuedAt is not set") - } - - if claims.StandardClaims.NotBefore == 0 { - t.Error("NotBefore is not set") - } - - if claims.StandardClaims.Issuer != API_KEY { - t.Errorf("Issuer expected to be: %s, got %s\n", API_KEY, claims.StandardClaims.Issuer) - } - - if claims.StandardClaims.Subject != ACC_SID { - t.Errorf("Subject expected to be: %s, got %s\n", ACC_SID, claims.StandardClaims.Subject) - } - - if claims.Grants == nil { - t.Error("Expected Grants to exist") - } - - if claims.Grants["identity"] != IDENTITY { - t.Errorf("Grants identity expected to be %s, got %s\n", IDENTITY, claims.Grants["identity"]) - } -} diff --git a/twilioclient/capabilities_test.go b/twilioclient/capabilities_test.go deleted file mode 100644 index 2d81e01..0000000 --- a/twilioclient/capabilities_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package twilioclient - -import ( - "testing" - "time" - - jwt "github.com/dgrijalva/jwt-go" -) - -type customTestClaim struct { - *jwt.StandardClaims - Scope string `json:"scope"` -} - -func TestCapability(t *testing.T) { - t.Parallel() - cap := NewCapability("AC123", "123") - cap.AllowClientIncoming("client-name") - tok, err := cap.GenerateToken(time.Hour) - if err != nil { - t.Fatal(err) - } - cc := new(customTestClaim) - _, err = jwt.ParseWithClaims(tok, cc, func(tkn *jwt.Token) (interface{}, error) { - return []byte("123"), nil - }) - if err != nil { - t.Fatal(err) - } - if cc.StandardClaims.Issuer != "AC123" { - t.Errorf("bad Issuer") - } - if cc.Scope != "scope:client:incoming?clientName=client-name" { - t.Errorf("bad Scope") - } -}