From a156fbe41cc358e927ea2b7dfaac0fa0f5a57033 Mon Sep 17 00:00:00 2001 From: tiannianshou Date: Tue, 30 Jun 2020 10:45:40 +0800 Subject: [PATCH] Modify module path to github.com/go-oauth2/oauth2/v4 --- .travis.yml | 4 +- README.md | 22 ++++---- doc.go | 6 +- errors/error.go | 3 + errors/response.go | 5 -- example/server/server.go | 12 ++-- generates/access.go | 8 +-- generates/access_test.go | 6 +- generates/authorize.go | 6 +- generates/authorize_test.go | 6 +- generates/jwt_access.go | 21 ++++--- generates/jwt_access_test.go | 6 +- go.mod | 17 +++--- go.sum | 38 +++++++++---- manage/manage_test.go | 8 +-- manage/manager.go | 8 +-- manage/util.go | 2 +- manage/util_test.go | 2 +- models/token.go | 2 +- server/config.go | 2 +- server/handler.go | 4 +- server/server.go | 4 +- server/server_config.go | 2 +- server/server_test.go | 12 ++-- store/client.go | 2 +- store/client_test.go | 4 +- store/token.go | 6 +- store/token_test.go | 6 +- utils/uuid/uuid.go | 105 ----------------------------------- 29 files changed, 119 insertions(+), 210 deletions(-) delete mode 100755 utils/uuid/uuid.go diff --git a/.travis.yml b/.travis.yml index 0850e5b..4180c8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: go sudo: false -go_import_path: gopkg.in/oauth2.v4 +go_import_path: github.com/go-oauth2/oauth2/v4 go: - - 1.9 + - 1.13 before_install: - go get -t -v ./... diff --git a/README.md b/README.md index 6de53b5..b4173b0 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ ### Download and install ``` bash -go get -u -v gopkg.in/oauth2.v4/... +go get -u -v github.com/go-oauth2/oauth2/v4/... ``` ### Create file `server.go` @@ -43,11 +43,11 @@ import ( "log" "net/http" - "gopkg.in/oauth2.v4/errors" - "gopkg.in/oauth2.v4/manage" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/server" - "gopkg.in/oauth2.v4/store" + "github.com/go-oauth2/oauth2/v4/errors" + "github.com/go-oauth2/oauth2/v4/manage" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/server" + "github.com/go-oauth2/oauth2/v4/store" ) func main() { @@ -135,7 +135,7 @@ Simulation examples of authorization code model, please check [example](/example ```go import ( - "gopkg.in/oauth2.v4/generates" + "github.com/go-oauth2/oauth2/v4/generates" "github.com/dgrijalva/jwt-go" ) @@ -180,9 +180,9 @@ if !ok || !token.Valid { [Build-Status-Image]: https://travis-ci.org/go-oauth2/oauth2.svg?branch=master [codecov-url]: https://codecov.io/gh/go-oauth2/oauth2 [codecov-image]: https://codecov.io/gh/go-oauth2/oauth2/branch/master/graph/badge.svg -[reportcard-url]: https://goreportcard.com/report/gopkg.in/oauth2.v4 -[reportcard-image]: https://goreportcard.com/badge/gopkg.in/oauth2.v4 -[godoc-url]: https://godoc.org/gopkg.in/oauth2.v4 -[godoc-image]: https://godoc.org/gopkg.in/oauth2.v4?status.svg +[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/oauth2/v4 +[reportcard-image]: https://goreportcard.com/badge/github.com/go-oauth2/oauth2/v4 +[godoc-url]: https://godoc.org/github.com/go-oauth2/oauth2/v4 +[godoc-image]: https://godoc.org/github.com/go-oauth2/oauth2/v4?status.svg [license-url]: http://opensource.org/licenses/MIT [license-image]: https://img.shields.io/npm/l/express.svg diff --git a/doc.go b/doc.go index fd1e7a2..282d0a1 100644 --- a/doc.go +++ b/doc.go @@ -3,9 +3,9 @@ // package main // import ( // "net/http" -// "gopkg.in/oauth2.v4/manage" -// "gopkg.in/oauth2.v4/server" -// "gopkg.in/oauth2.v4/store" +// "github.com/go-oauth2/oauth2/v4/manage" +// "github.com/go-oauth2/oauth2/v4/server" +// "github.com/go-oauth2/oauth2/v4/store" // ) // func main() { // manager := manage.NewDefaultManager() diff --git a/errors/error.go b/errors/error.go index d903519..c106563 100644 --- a/errors/error.go +++ b/errors/error.go @@ -2,6 +2,9 @@ package errors import "errors" +// New returns an error that formats as the given text. +var New = errors.New + // known errors var ( ErrInvalidRedirectURI = errors.New("invalid redirect uri") diff --git a/errors/response.go b/errors/response.go index d8691ba..5ba1199 100644 --- a/errors/response.go +++ b/errors/response.go @@ -5,11 +5,6 @@ import ( "net/http" ) -// Define alias -var ( - New = errors.New -) - // Response error response type Response struct { Error error diff --git a/example/server/server.go b/example/server/server.go index b19bf05..da3993d 100644 --- a/example/server/server.go +++ b/example/server/server.go @@ -9,13 +9,13 @@ import ( "time" "github.com/dgrijalva/jwt-go" + "github.com/go-oauth2/oauth2/v4/errors" + "github.com/go-oauth2/oauth2/v4/generates" + "github.com/go-oauth2/oauth2/v4/manage" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/server" + "github.com/go-oauth2/oauth2/v4/store" "github.com/go-session/session" - "gopkg.in/oauth2.v4/errors" - "gopkg.in/oauth2.v4/generates" - "gopkg.in/oauth2.v4/manage" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/server" - "gopkg.in/oauth2.v4/store" ) func main() { diff --git a/generates/access.go b/generates/access.go index 7bae4a2..a9cf693 100755 --- a/generates/access.go +++ b/generates/access.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/utils/uuid" + "github.com/go-oauth2/oauth2/v4" + "github.com/google/uuid" ) // NewAccessGenerate create to generate the access token instance @@ -26,11 +26,11 @@ func (ag *AccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic, buf.WriteString(data.UserID) buf.WriteString(strconv.FormatInt(data.CreateAt.UnixNano(), 10)) - access := base64.URLEncoding.EncodeToString(uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes()).Bytes()) + access := base64.URLEncoding.EncodeToString([]byte(uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes()).String())) access = strings.ToUpper(strings.TrimRight(access, "=")) refresh := "" if isGenRefresh { - refresh = base64.URLEncoding.EncodeToString(uuid.NewSHA1(uuid.Must(uuid.NewRandom()), buf.Bytes()).Bytes()) + refresh = base64.URLEncoding.EncodeToString([]byte(uuid.NewSHA1(uuid.Must(uuid.NewRandom()), buf.Bytes()).String())) refresh = strings.ToUpper(strings.TrimRight(refresh, "=")) } diff --git a/generates/access_test.go b/generates/access_test.go index bec4f64..691ef36 100644 --- a/generates/access_test.go +++ b/generates/access_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/generates" - "gopkg.in/oauth2.v4/models" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/generates" + "github.com/go-oauth2/oauth2/v4/models" . "github.com/smartystreets/goconvey/convey" ) diff --git a/generates/authorize.go b/generates/authorize.go index 10ab43f..7a57f06 100755 --- a/generates/authorize.go +++ b/generates/authorize.go @@ -6,8 +6,8 @@ import ( "encoding/base64" "strings" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/utils/uuid" + "github.com/go-oauth2/oauth2/v4" + "github.com/google/uuid" ) // NewAuthorizeGenerate create to generate the authorize code instance @@ -23,7 +23,7 @@ func (ag *AuthorizeGenerate) Token(ctx context.Context, data *oauth2.GenerateBas buf := bytes.NewBufferString(data.Client.GetID()) buf.WriteString(data.UserID) token := uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes()) - code := base64.URLEncoding.EncodeToString(token.Bytes()) + code := base64.URLEncoding.EncodeToString([]byte(token.String())) code = strings.ToUpper(strings.TrimRight(code, "=")) return code, nil diff --git a/generates/authorize_test.go b/generates/authorize_test.go index d8a86da..027bba7 100644 --- a/generates/authorize_test.go +++ b/generates/authorize_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/generates" - "gopkg.in/oauth2.v4/models" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/generates" + "github.com/go-oauth2/oauth2/v4/models" . "github.com/smartystreets/goconvey/convey" ) diff --git a/generates/jwt_access.go b/generates/jwt_access.go index b5a3ee8..0f62caf 100755 --- a/generates/jwt_access.go +++ b/generates/jwt_access.go @@ -6,12 +6,10 @@ import ( "strings" "time" - errs "errors" - "github.com/dgrijalva/jwt-go" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/errors" - "gopkg.in/oauth2.v4/utils/uuid" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/errors" + "github.com/google/uuid" ) // JWTAccessClaims jwt claims @@ -30,7 +28,7 @@ func (a *JWTAccessClaims) Valid() error { // NewJWTAccessGenerate create to generate the jwt access token instance func NewJWTAccessGenerate(kid string, key []byte, method jwt.SigningMethod) *JWTAccessGenerate { return &JWTAccessGenerate{ - SignedKeyId: kid, + SignedKeyID: kid, SignedKey: key, SignedMethod: method, } @@ -38,7 +36,7 @@ func NewJWTAccessGenerate(kid string, key []byte, method jwt.SigningMethod) *JWT // JWTAccessGenerate generate the jwt access token type JWTAccessGenerate struct { - SignedKeyId string + SignedKeyID string SignedKey []byte SignedMethod jwt.SigningMethod } @@ -54,8 +52,8 @@ func (a *JWTAccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasi } token := jwt.NewWithClaims(a.SignedMethod, claims) - if a.SignedKeyId != "" { - token.Header["kid"] = a.SignedKeyId + if a.SignedKeyID != "" { + token.Header["kid"] = a.SignedKeyID } var key interface{} if a.isEs() { @@ -73,7 +71,7 @@ func (a *JWTAccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasi } else if a.isHs() { key = a.SignedKey } else { - return "", "", errs.New("unsupported sign method") + return "", "", errors.New("unsupported sign method") } access, err := token.SignedString(key) @@ -83,7 +81,8 @@ func (a *JWTAccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasi refresh := "" if isGenRefresh { - refresh = base64.URLEncoding.EncodeToString(uuid.NewSHA1(uuid.Must(uuid.NewRandom()), []byte(access)).Bytes()) + t := uuid.NewSHA1(uuid.Must(uuid.NewRandom()), []byte(access)).String() + refresh = base64.URLEncoding.EncodeToString([]byte(t)) refresh = strings.ToUpper(strings.TrimRight(refresh, "=")) } diff --git a/generates/jwt_access_test.go b/generates/jwt_access_test.go index 6175995..dc165e0 100644 --- a/generates/jwt_access_test.go +++ b/generates/jwt_access_test.go @@ -7,9 +7,9 @@ import ( "time" "github.com/dgrijalva/jwt-go" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/generates" - "gopkg.in/oauth2.v4/models" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/generates" + "github.com/go-oauth2/oauth2/v4/models" . "github.com/smartystreets/goconvey/convey" ) diff --git a/go.mod b/go.mod index c12bc26..4de99e7 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module gopkg.in/oauth2.v4 +module github.com/go-oauth2/oauth2/v4 go 1.13 @@ -10,26 +10,29 @@ require ( github.com/gavv/httpexpect v2.0.0+incompatible github.com/go-session/session v3.1.2+incompatible github.com/google/go-querystring v1.0.0 // indirect + github.com/google/uuid v1.1.1 github.com/gorilla/websocket v1.4.2 // indirect github.com/imkira/go-interpol v1.1.0 // indirect github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect - github.com/klauspost/compress v1.10.6 // indirect - github.com/mattn/go-colorable v0.1.6 // indirect + github.com/klauspost/compress v1.10.10 // indirect + github.com/mattn/go-colorable v0.1.7 // indirect github.com/moul/http2curl v1.0.0 // indirect - github.com/onsi/ginkgo v1.12.2 // indirect + github.com/onsi/ginkgo v1.13.0 // indirect github.com/sergi/go-diff v1.1.0 // indirect github.com/smartystreets/goconvey v1.6.4 - github.com/stretchr/testify v1.5.1 // indirect + github.com/stretchr/testify v1.6.1 // indirect github.com/tidwall/buntdb v1.1.2 github.com/tidwall/gjson v1.6.0 // indirect github.com/tidwall/pretty v1.0.1 // indirect - github.com/valyala/fasthttp v1.12.0 // indirect + github.com/valyala/fasthttp v1.14.0 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect github.com/yudai/gojsondiff v1.0.0 // indirect github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect - golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect + golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d + golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae // indirect google.golang.org/appengine v1.6.6 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect ) diff --git a/go.sum b/go.sum index 6643a65..d152898 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= +github.com/andybalholm/brotli v1.0.0 h1:7UCwP93aiSfvWpapti8g88vVVGp2qqtGyePsSuDafo4= +github.com/andybalholm/brotli v1.0.0/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -35,6 +37,8 @@ github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= @@ -49,15 +53,15 @@ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQ github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= github.com/klauspost/compress v1.10.4 h1:jFzIFaf586tquEB5EhzQG0HwGNSlgAJpG53G6Ss11wc= github.com/klauspost/compress v1.10.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.10.6 h1:SP6zavvTG3YjOosWePXFDlExpKIWMTO4SE/Y8MZB2vI= -github.com/klauspost/compress v1.10.6/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.10.10 h1:a/y8CglcM7gLGYmlbP/stPE5sR3hbhFRUjCBfd/0B3I= +github.com/klauspost/compress v1.10.10/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= @@ -66,13 +70,14 @@ github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.12.2 h1:Ke9m3h2Hu0wsZ45yewCqhYr3Z+emcNTuLY2nMWCkrSI= -github.com/onsi/ginkgo v1.12.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.13.0 h1:M76yO2HkZASFjXL0HSoZJ1AYEmQxNJmY41Jx1zNUq1Y= +github.com/onsi/ginkgo v1.13.0/go.mod h1:+REjRxOmWfHCjfv9TTWB1jD1Frx4XydAD3zm1lskyM0= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -84,8 +89,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/btree v0.0.0-20191029221954-400434d76274 h1:G6Z6HvJuPjG6XfNGi/feOATzeJrfgTNJY+rGrHbA04E= github.com/tidwall/btree v0.0.0-20191029221954-400434d76274/go.mod h1:huei1BkDWJ3/sLXmO+bsCNELL+Bp2Kks9OLyQFkzvA8= github.com/tidwall/buntdb v1.1.2 h1:noCrqQXL9EKMtcdwJcmuVKSEjqu1ua99RHHgbLTEHRo= @@ -107,8 +112,8 @@ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.12.0 h1:TsB9qkSeiMXB40ELWWSRMjlsE+8IkqXHcs01y2d9aw0= -github.com/valyala/fasthttp v1.12.0/go.mod h1:229t1eWu9UXTPmoUkbpN/fctKPBY4IJoFXQnxHGXy6E= +github.com/valyala/fasthttp v1.14.0 h1:67bfuW9azCMwW/Jlq/C+VeihNpAuJMWkYPBig1gdi3A= +github.com/valyala/fasthttp v1.14.0/go.mod h1:ol1PCaL0dX20wC0htZ7sYCsvCYmrouYra0zHzaclZhE= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= @@ -125,17 +130,19 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDf github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344 h1:vGXIOMxbNfDTk/aXCmfdLgkrSV+Z2tcbze+pEc3v5W4= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -144,6 +151,7 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -152,6 +160,8 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7NkNAQs+6Q8b9WEB/F4= golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae h1:Ih9Yo4hSPImZOpfGuA4bR/ORKTAbhZo2AbWNRCnevdo= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -185,3 +195,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/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= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/manage/manage_test.go b/manage/manage_test.go index 64cf7cb..0e5d68f 100644 --- a/manage/manage_test.go +++ b/manage/manage_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/manage" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/store" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/manage" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/store" . "github.com/smartystreets/goconvey/convey" ) diff --git a/manage/manager.go b/manage/manager.go index bda93db..514bc23 100755 --- a/manage/manager.go +++ b/manage/manager.go @@ -4,10 +4,10 @@ import ( "context" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/errors" - "gopkg.in/oauth2.v4/generates" - "gopkg.in/oauth2.v4/models" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/errors" + "github.com/go-oauth2/oauth2/v4/generates" + "github.com/go-oauth2/oauth2/v4/models" ) // NewDefaultManager create to default authorization management instance diff --git a/manage/util.go b/manage/util.go index 957aaa3..43f32f4 100755 --- a/manage/util.go +++ b/manage/util.go @@ -4,7 +4,7 @@ import ( "net/url" "strings" - "gopkg.in/oauth2.v4/errors" + "github.com/go-oauth2/oauth2/v4/errors" ) type ( diff --git a/manage/util_test.go b/manage/util_test.go index 89e826c..9195cff 100644 --- a/manage/util_test.go +++ b/manage/util_test.go @@ -3,7 +3,7 @@ package manage_test import ( "testing" - "gopkg.in/oauth2.v4/manage" + "github.com/go-oauth2/oauth2/v4/manage" . "github.com/smartystreets/goconvey/convey" ) diff --git a/models/token.go b/models/token.go index baa49df..f841823 100644 --- a/models/token.go +++ b/models/token.go @@ -3,7 +3,7 @@ package models import ( "time" - "gopkg.in/oauth2.v4" + "github.com/go-oauth2/oauth2/v4" ) // NewToken create to token model instance diff --git a/server/config.go b/server/config.go index 3f6b666..f5fc5d2 100644 --- a/server/config.go +++ b/server/config.go @@ -4,7 +4,7 @@ import ( "net/http" "time" - "gopkg.in/oauth2.v4" + "github.com/go-oauth2/oauth2/v4" ) // Config configuration parameters diff --git a/server/handler.go b/server/handler.go index 8f74587..67d9c9f 100755 --- a/server/handler.go +++ b/server/handler.go @@ -4,8 +4,8 @@ import ( "net/http" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/errors" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/errors" ) type ( diff --git a/server/server.go b/server/server.go index 3082513..ca1cd94 100755 --- a/server/server.go +++ b/server/server.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/errors" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/errors" ) // NewDefaultServer create a default authorization server diff --git a/server/server_config.go b/server/server_config.go index 15624ac..d9b740d 100644 --- a/server/server_config.go +++ b/server/server_config.go @@ -1,7 +1,7 @@ package server import ( - "gopkg.in/oauth2.v4" + "github.com/go-oauth2/oauth2/v4" ) // SetTokenType token type diff --git a/server/server_test.go b/server/server_test.go index 7ba09d7..f1c8ed1 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -8,12 +8,12 @@ import ( "testing" "github.com/gavv/httpexpect" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/errors" - "gopkg.in/oauth2.v4/manage" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/server" - "gopkg.in/oauth2.v4/store" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/errors" + "github.com/go-oauth2/oauth2/v4/manage" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/server" + "github.com/go-oauth2/oauth2/v4/store" ) var ( diff --git a/store/client.go b/store/client.go index 9ea9cf6..0001bb2 100755 --- a/store/client.go +++ b/store/client.go @@ -5,7 +5,7 @@ import ( "errors" "sync" - "gopkg.in/oauth2.v4" + "github.com/go-oauth2/oauth2/v4" ) // NewClientStore create client store diff --git a/store/client_test.go b/store/client_test.go index dcc925c..772317d 100644 --- a/store/client_test.go +++ b/store/client_test.go @@ -4,8 +4,8 @@ import ( "context" "testing" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/store" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/store" . "github.com/smartystreets/goconvey/convey" ) diff --git a/store/token.go b/store/token.go index 6e798d2..21b194c 100755 --- a/store/token.go +++ b/store/token.go @@ -5,10 +5,10 @@ import ( "encoding/json" "time" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/google/uuid" "github.com/tidwall/buntdb" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/utils/uuid" ) // NewMemoryTokenStore create a token store instance based on memory diff --git a/store/token_test.go b/store/token_test.go index 228e6c0..88a9d9c 100644 --- a/store/token_test.go +++ b/store/token_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "gopkg.in/oauth2.v4" - "gopkg.in/oauth2.v4/models" - "gopkg.in/oauth2.v4/store" + "github.com/go-oauth2/oauth2/v4" + "github.com/go-oauth2/oauth2/v4/models" + "github.com/go-oauth2/oauth2/v4/store" . "github.com/smartystreets/goconvey/convey" ) diff --git a/utils/uuid/uuid.go b/utils/uuid/uuid.go deleted file mode 100755 index a0dc20b..0000000 --- a/utils/uuid/uuid.go +++ /dev/null @@ -1,105 +0,0 @@ -package uuid - -import ( - "crypto/md5" - "crypto/rand" - "crypto/sha1" - "encoding/hex" - "hash" - "io" -) - -// Nil empty UUID, all zeros -var Nil UUID - -// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC -// 4122. -type UUID [16]byte - -// Bytes returns bytes slice representation of UUID. -func (uuid UUID) Bytes() []byte { - return uuid[:] -} - -// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -// , or "" if uuid is invalid. -func (uuid UUID) String() string { - var buf [36]byte - encodeHex(buf[:], uuid) - return string(buf[:]) -} - -func encodeHex(dst []byte, uuid UUID) { - hex.Encode(dst, uuid[:4]) - dst[8] = '-' - hex.Encode(dst[9:13], uuid[4:6]) - dst[13] = '-' - hex.Encode(dst[14:18], uuid[6:8]) - dst[18] = '-' - hex.Encode(dst[19:23], uuid[8:10]) - dst[23] = '-' - hex.Encode(dst[24:], uuid[10:]) -} - -// Must returns uuid if err is nil and panics otherwise. -func Must(uuid UUID, err error) UUID { - if err != nil { - panic(err) - } - return uuid -} - -// NewRandom returns a Random (Version 4) UUID. -// -// The strength of the UUIDs is based on the strength of the crypto/rand -// package. -// -// A note about uniqueness derived from the UUID Wikipedia entry: -// -// Randomly generated UUIDs have 122 random bits. One's annual risk of being -// hit by a meteorite is estimated to be one chance in 17 billion, that -// means the probability is about 0.00000000006 (6 × 10−11), -// equivalent to the odds of creating a few tens of trillions of UUIDs in a -// year and having one duplicate. -func NewRandom() (UUID, error) { - var uuid UUID - _, err := io.ReadFull(rand.Reader, uuid[:]) - if err != nil { - return Nil, err - } - uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 - uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 - return uuid, nil -} - -// NewHash returns a new UUID derived from the hash of space concatenated with -// data generated by h. The hash should be at least 16 byte in length. The -// first 16 bytes of the hash are used to form the UUID. The version of the -// UUID will be the lower 4 bits of version. -func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { - h.Reset() - h.Write(space[:]) - h.Write(data) - s := h.Sum(nil) - var uuid UUID - copy(uuid[:], s) - uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) - uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant - return uuid -} - -// NewMD5 returns a new MD5 (Version 3) UUID based on the -// supplied name space and data. It is the same as calling: -// -// NewHash(md5.New(), space, data, 3) -func NewMD5(space UUID, data []byte) UUID { - return NewHash(md5.New(), space, data, 3) -} - -// NewSHA1 returns a new SHA1 (Version 5) UUID based on the -// supplied name space and data. It is the same as calling: -// -// NewHash(sha1.New(), space, data, 5) -func NewSHA1(space UUID, data []byte) UUID { - return NewHash(sha1.New(), space, data, 5) -}