forked from forgejo/forgejo
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
This commit is contained in:
parent
b3000ae623
commit
4c1f1f9646
40 changed files with 1492 additions and 644 deletions
2
vendor/github.com/markbates/goth/provider.go
generated
vendored
2
vendor/github.com/markbates/goth/provider.go
generated
vendored
|
@ -1,10 +1,10 @@
|
|||
package goth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
|
|
53
vendor/github.com/markbates/goth/providers/facebook/facebook.go
generated
vendored
53
vendor/github.com/markbates/goth/providers/facebook/facebook.go
generated
vendored
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue