diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2018-11-11 00:55:36 +0100 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-11-10 18:55:36 -0500 |
commit | 4c1f1f96465e809161f7d634a07eb60b4511db35 (patch) | |
tree | 923ab95c7c96c133ce39fce7ca2b9872f116fb2c /vendor/github.com/markbates | |
parent | b3000ae623c30a58d3eb25c9fd7104db274381b7 (diff) | |
download | gitea-4c1f1f96465e809161f7d634a07eb60b4511db35.tar.gz gitea-4c1f1f96465e809161f7d634a07eb60b4511db35.zip |
Remove x/net/context vendor by using std package (#5202)
* Update dep github.com/markbates/goth
* Update dep github.com/blevesearch/bleve
* Update dep golang.org/x/oauth2
* Fix github.com/blevesearch/bleve to c74e08f039e56cef576e4336382b2a2d12d9e026
* Update dep golang.org/x/oauth2
Diffstat (limited to 'vendor/github.com/markbates')
-rw-r--r-- | vendor/github.com/markbates/goth/provider.go | 2 | ||||
-rw-r--r-- | vendor/github.com/markbates/goth/providers/facebook/facebook.go | 53 |
2 files changed, 39 insertions, 16 deletions
diff --git a/vendor/github.com/markbates/goth/provider.go b/vendor/github.com/markbates/goth/provider.go index 58d0d60bbf..294679d2aa 100644 --- a/vendor/github.com/markbates/goth/provider.go +++ b/vendor/github.com/markbates/goth/provider.go @@ -1,10 +1,10 @@ package goth import ( + "context" "fmt" "net/http" - "golang.org/x/net/context" "golang.org/x/oauth2" ) diff --git a/vendor/github.com/markbates/goth/providers/facebook/facebook.go b/vendor/github.com/markbates/goth/providers/facebook/facebook.go index 266bbe2208..5c80ca747b 100644 --- a/vendor/github.com/markbates/goth/providers/facebook/facebook.go +++ b/vendor/github.com/markbates/goth/providers/facebook/facebook.go @@ -4,17 +4,18 @@ package facebook import ( "bytes" + "crypto/hmac" + "crypto/sha256" + "encoding/hex" "encoding/json" "errors" + "fmt" "io" "io/ioutil" "net/http" "net/url" + "strings" - "crypto/hmac" - "crypto/sha256" - "encoding/hex" - "fmt" "github.com/markbates/goth" "golang.org/x/oauth2" ) @@ -22,7 +23,7 @@ import ( const ( authURL string = "https://www.facebook.com/dialog/oauth" tokenURL string = "https://graph.facebook.com/oauth/access_token" - endpointProfile string = "https://graph.facebook.com/me?fields=email,first_name,last_name,link,about,id,name,picture,location" + endpointProfile string = "https://graph.facebook.com/me?fields=" ) // New creates a new Facebook provider, and sets up important connection details. @@ -68,9 +69,9 @@ func (p *Provider) Debug(debug bool) {} // BeginAuth asks Facebook for an authentication end-point. func (p *Provider) BeginAuth(state string) (goth.Session, error) { - url := p.config.AuthCodeURL(state) + authUrl := p.config.AuthCodeURL(state) session := &Session{ - AuthURL: url, + AuthURL: authUrl, } return session, nil } @@ -96,7 +97,15 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) { hash.Write([]byte(sess.AccessToken)) appsecretProof := hex.EncodeToString(hash.Sum(nil)) - response, err := p.Client().Get(endpointProfile + "&access_token=" + url.QueryEscape(sess.AccessToken) + "&appsecret_proof=" + appsecretProof) + reqUrl := fmt.Sprint( + endpointProfile, + strings.Join(p.config.Scopes, ","), + "&access_token=", + url.QueryEscape(sess.AccessToken), + "&appsecret_proof=", + appsecretProof, + ) + response, err := p.Client().Get(reqUrl) if err != nil { return user, err } @@ -168,17 +177,31 @@ func newConfig(provider *Provider, scopes []string) *oauth2.Config { }, Scopes: []string{ "email", + "first_name", + "last_name", + "link", + "about", + "id", + "name", + "picture", + "location", }, } - defaultScopes := map[string]struct{}{ - "email": {}, - } - - for _, scope := range scopes { - if _, exists := defaultScopes[scope]; !exists { - c.Scopes = append(c.Scopes, scope) + // creates possibility to invoke field method like 'picture.type(large)' + var found bool + for _, sc := range scopes { + sc := sc + for i, defScope := range c.Scopes { + if defScope == strings.Split(sc, ".")[0] { + c.Scopes[i] = sc + found = true + } + } + if !found { + c.Scopes = append(c.Scopes, sc) } + found = false } return c |