Skip to content
This repository was archived by the owner on May 1, 2023. It is now read-only.

Commit 99720fd

Browse files
authored
Update github.com/google/go-github (#53)
migrate github.com/google/go-github from v33.0.0 -> v39.1.0
1 parent 475362d commit 99720fd

File tree

795 files changed

+70299
-21469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

795 files changed

+70299
-21469
lines changed

go.mod

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,34 @@ go 1.15
44

55
require (
66
github.com/BurntSushi/toml v0.3.1
7-
github.com/dgrijalva/jwt-go v2.2.1-0.20150401180636-c48cfd5d9711+incompatible
7+
github.com/dgrijalva/jwt-go v3.2.0+incompatible
88
github.com/elazarl/go-bindata-assetfs v1.0.1
9-
github.com/franela/goblin v0.0.0-20201006155558-6240afcb2eb7
9+
github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2
1010
github.com/gin-gonic/contrib v0.0.0-20201101042839-6a891bf89f19
11-
github.com/gin-gonic/gin v1.6.3
12-
github.com/go-playground/validator/v10 v10.4.1 // indirect
13-
github.com/go-sql-driver/mysql v1.5.0
14-
github.com/golang/protobuf v1.4.3 // indirect
15-
github.com/google/go-github/v33 v33.0.0
11+
github.com/gin-gonic/gin v1.7.2
12+
github.com/go-playground/validator/v10 v10.6.1 // indirect
13+
github.com/go-sql-driver/mysql v1.6.0
14+
github.com/golang/protobuf v1.5.2 // indirect
15+
github.com/google/go-github/v39 v39.1.0
1616
github.com/ianschenck/envflag v0.0.0-20140720210342-9111d830d133
1717
github.com/joho/godotenv v1.3.0
18-
github.com/json-iterator/go v1.1.10 // indirect
18+
github.com/json-iterator/go v1.1.11 // indirect
1919
github.com/koding/cache v0.0.0-20161222233015-e8a81b0b3f20
20-
github.com/lib/pq v1.9.0
20+
github.com/leodido/go-urn v1.2.1 // indirect
21+
github.com/lib/pq v1.10.2
22+
github.com/mattn/go-isatty v0.0.13 // indirect
2123
github.com/mattn/go-sqlite3 v2.0.3+incompatible
2224
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
2325
github.com/modern-go/reflect2 v1.0.1 // indirect
24-
github.com/rubenv/sql-migrate v0.0.0-20150713140751-53184e1edfb4
25-
github.com/russross/meddler v1.0.0
26-
github.com/sirupsen/logrus v1.7.0
27-
github.com/stretchr/testify v1.4.0
28-
github.com/ugorji/go v1.2.1 // indirect
26+
github.com/rubenv/sql-migrate v0.0.0-20210408115534-a32ed26c37ea
27+
github.com/russross/meddler v1.0.1
28+
github.com/sirupsen/logrus v1.8.1
29+
github.com/stretchr/objx v0.3.0 // indirect
30+
github.com/stretchr/testify v1.7.0
31+
github.com/ugorji/go v1.2.6 // indirect
2932
github.com/ziutek/mymysql v1.5.4 // indirect
30-
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c // indirect
31-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3
32-
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be
33-
golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect
34-
google.golang.org/protobuf v1.25.0 // indirect
35-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
36-
gopkg.in/gorp.v1 v1.7.1 // indirect
33+
golang.org/x/net v0.0.0-20210525063256-abc453219eb5
34+
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c
3735
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
38-
gopkg.in/yaml.v2 v2.4.0 // indirect
36+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
3937
)

go.sum

Lines changed: 488 additions & 46 deletions
Large diffs are not rendered by default.

remote/github/github.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88

99
"github.com/go-gitea/lgtm/model"
1010
"github.com/go-gitea/lgtm/shared/httputil"
11-
"github.com/google/go-github/v33/github"
11+
"github.com/google/go-github/v39/github"
1212
log "github.com/sirupsen/logrus"
1313
"golang.org/x/net/context"
1414
"golang.org/x/oauth2"
@@ -148,9 +148,9 @@ func (g *Github) GetPerm(c context.Context, user *model.User, owner, name string
148148
return nil, fmt.Errorf("Error fetching repository. %s", err)
149149
}
150150
m := &model.Perm{}
151-
m.Admin = (*repo.Permissions)["admin"]
152-
m.Push = (*repo.Permissions)["push"]
153-
m.Pull = (*repo.Permissions)["pull"]
151+
m.Admin = repo.Permissions["admin"]
152+
m.Push = repo.Permissions["push"]
153+
m.Pull = repo.Permissions["pull"]
154154
return m, nil
155155
}
156156

@@ -165,7 +165,7 @@ func (g *Github) GetRepos(c context.Context, u *model.User) ([]*model.Repo, erro
165165
repos := []*model.Repo{}
166166
for _, repo := range all {
167167
// only list repositories that I can admin
168-
if repo.Permissions == nil || (*repo.Permissions)["admin"] == false {
168+
if repo.Permissions == nil || !repo.Permissions["admin"] {
169169
continue
170170
}
171171
repos = append(repos, &model.Repo{

remote/github/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"net/url"
66

7-
"github.com/google/go-github/v33/github"
7+
"github.com/google/go-github/v39/github"
88
"golang.org/x/net/context"
99
"golang.org/x/oauth2"
1010
)

shared/token/token.go

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ type Token struct {
3333
Text string
3434
}
3535

36-
// Parse parses a raw JWT.
37-
func Parse(raw string, fn SecretFunc) (*Token, error) {
36+
// parse parses a raw JWT.
37+
func parse(raw string, fn SecretFunc) (*Token, error) {
3838
token := &Token{}
3939
parsed, err := jwt.Parse(raw, keyFunc(token, fn))
4040
if err != nil {
@@ -54,14 +54,14 @@ func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
5454
if len(token) != 0 {
5555
token = r.Header.Get("Authorization")
5656
fmt.Sscanf(token, "Bearer %s", &token)
57-
return Parse(token, fn)
57+
return parse(token, fn)
5858
}
5959

6060
// then we attempt to get the token from the
6161
// access_token url query parameter
6262
token = r.FormValue("access_token")
6363
if len(token) != 0 {
64-
return Parse(token, fn)
64+
return parse(token, fn)
6565
}
6666

6767
// and finally we attempt to get the token from
@@ -70,7 +70,7 @@ func ParseRequest(r *http.Request, fn SecretFunc) (*Token, error) {
7070
if err != nil {
7171
return nil, err
7272
}
73-
return Parse(cookie.Value, fn)
73+
return parse(cookie.Value, fn)
7474
}
7575

7676
// CheckCsrf checks the validity of the JWT.
@@ -85,7 +85,7 @@ func CheckCsrf(r *http.Request, fn SecretFunc) error {
8585

8686
// parse the raw CSRF token value and validate
8787
raw := r.Header.Get("X-CSRF-TOKEN")
88-
_, err := Parse(raw, fn)
88+
_, err := parse(raw, fn)
8989
return err
9090
}
9191

@@ -104,11 +104,13 @@ func (t *Token) Sign(secret string) (string, error) {
104104
// with an expiration date.
105105
func (t *Token) SignExpires(secret string, exp int64) (string, error) {
106106
token := jwt.New(jwt.SigningMethodHS256)
107-
token.Claims["type"] = t.Kind
108-
token.Claims["text"] = t.Text
107+
mapClaims := make(jwt.MapClaims)
108+
mapClaims["type"] = t.Kind
109+
mapClaims["text"] = t.Text
109110
if exp > 0 {
110-
token.Claims["exp"] = float64(exp)
111+
mapClaims["exp"] = float64(exp)
111112
}
113+
token.Claims = mapClaims
112114
return token.SignedString([]byte(secret))
113115
}
114116

@@ -119,17 +121,22 @@ func keyFunc(token *Token, fn SecretFunc) jwt.Keyfunc {
119121
return nil, jwt.ErrSignatureInvalid
120122
}
121123

124+
mapClaims, isMapClaims := t.Claims.(jwt.MapClaims)
125+
if !isMapClaims {
126+
return nil, fmt.Errorf("token claims are not stored as map")
127+
}
128+
122129
// extract the token kind and cast to
123130
// the expected type.
124-
kindv, ok := t.Claims["type"]
131+
kindv, ok := mapClaims["type"]
125132
if !ok {
126133
return nil, jwt.ValidationError{}
127134
}
128135
token.Kind, _ = kindv.(string)
129136

130137
// extract the token value and cast to
131138
// exepected type.
132-
textv, ok := t.Claims["text"]
139+
textv, ok := mapClaims["text"]
133140
if !ok {
134141
return nil, jwt.ValidationError{}
135142
}

vendor/github.com/dgrijalva/jwt-go/.travis.yml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/dgrijalva/jwt-go/MIGRATION_GUIDE.md

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)