mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-04 13:50:39 +00:00
Update markbates/goth library (#3533)
Signed-off-by: Lauris Bukšis-Haberkorns <lauris@nix.lv>
This commit is contained in:
parent
6f751409b4
commit
7b297808ce
11 changed files with 284 additions and 160 deletions
12
vendor/github.com/markbates/goth/providers/bitbucket/bitbucket.go
generated
vendored
12
vendor/github.com/markbates/goth/providers/bitbucket/bitbucket.go
generated
vendored
|
@ -9,9 +9,9 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"fmt"
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -26,10 +26,10 @@ const (
|
|||
// one manually.
|
||||
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "bitbucket",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "bitbucket",
|
||||
}
|
||||
p.config = newConfig(p, scopes)
|
||||
return p
|
||||
|
@ -125,7 +125,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
|
|||
|
||||
func userFromReader(reader io.Reader, user *goth.User) error {
|
||||
u := struct {
|
||||
ID string `json:"uuid"`
|
||||
ID string `json:"uuid"`
|
||||
Links struct {
|
||||
Avatar struct {
|
||||
URL string `json:"href"`
|
||||
|
|
21
vendor/github.com/markbates/goth/providers/dropbox/dropbox.go
generated
vendored
21
vendor/github.com/markbates/goth/providers/dropbox/dropbox.go
generated
vendored
|
@ -8,15 +8,16 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
authURL = "https://www.dropbox.com/1/oauth2/authorize"
|
||||
tokenURL = "https://api.dropbox.com/1/oauth2/token"
|
||||
accountURL = "https://api.dropbox.com/1/account/info"
|
||||
authURL = "https://www.dropbox.com/oauth2/authorize"
|
||||
tokenURL = "https://api.dropbox.com/oauth2/token"
|
||||
accountURL = "https://api.dropbox.com/2/users/get_current_account"
|
||||
)
|
||||
|
||||
// Provider is the implementation of `goth.Provider` for accessing Dropbox.
|
||||
|
@ -40,10 +41,10 @@ type Session struct {
|
|||
// create one manually.
|
||||
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "dropbox",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "dropbox",
|
||||
}
|
||||
p.config = newConfig(p, scopes)
|
||||
return p
|
||||
|
@ -86,7 +87,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
|
|||
return user, fmt.Errorf("%s cannot get user information without accessToken", p.providerName)
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("GET", accountURL, nil)
|
||||
req, err := http.NewRequest("POST", accountURL, nil)
|
||||
if err != nil {
|
||||
return user, err
|
||||
}
|
||||
|
@ -161,7 +162,7 @@ func newConfig(p *Provider, scopes []string) *oauth2.Config {
|
|||
|
||||
func userFromReader(r io.Reader, user *goth.User) error {
|
||||
u := struct {
|
||||
Name string `json:"display_name"`
|
||||
Name string `json:"display_name"`
|
||||
NameDetails struct {
|
||||
NickName string `json:"familiar_name"`
|
||||
} `json:"name_details"`
|
||||
|
|
16
vendor/github.com/markbates/goth/providers/facebook/facebook.go
generated
vendored
16
vendor/github.com/markbates/goth/providers/facebook/facebook.go
generated
vendored
|
@ -11,12 +11,12 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
"crypto/hmac"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -30,10 +30,10 @@ const (
|
|||
// one manually.
|
||||
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "facebook",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "facebook",
|
||||
}
|
||||
p.config = newConfig(p, scopes)
|
||||
return p
|
||||
|
@ -129,7 +129,7 @@ func userFromReader(reader io.Reader, user *goth.User) error {
|
|||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Link string `json:"link"`
|
||||
Picture struct {
|
||||
Picture struct {
|
||||
Data struct {
|
||||
URL string `json:"url"`
|
||||
} `json:"data"`
|
||||
|
|
2
vendor/github.com/markbates/goth/providers/gitlab/gitlab.go
generated
vendored
2
vendor/github.com/markbates/goth/providers/gitlab/gitlab.go
generated
vendored
|
@ -11,9 +11,9 @@ import (
|
|||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"fmt"
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// These vars define the Authentication, Token, and Profile URLS for Gitlab. If
|
||||
|
|
10
vendor/github.com/markbates/goth/providers/gplus/gplus.go
generated
vendored
10
vendor/github.com/markbates/goth/providers/gplus/gplus.go
generated
vendored
|
@ -11,9 +11,9 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
"fmt"
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -27,10 +27,10 @@ const (
|
|||
// one manually.
|
||||
func New(clientKey, secret, callbackURL string, scopes ...string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "gplus",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "gplus",
|
||||
}
|
||||
p.config = newConfig(p, scopes)
|
||||
return p
|
||||
|
|
32
vendor/github.com/markbates/goth/providers/openidConnect/openidConnect.go
generated
vendored
32
vendor/github.com/markbates/goth/providers/openidConnect/openidConnect.go
generated
vendored
|
@ -1,17 +1,17 @@
|
|||
package openidConnect
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/markbates/goth"
|
||||
"golang.org/x/oauth2"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"encoding/base64"
|
||||
"io/ioutil"
|
||||
"errors"
|
||||
"golang.org/x/oauth2"
|
||||
"github.com/markbates/goth"
|
||||
"time"
|
||||
"bytes"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -89,14 +89,14 @@ func New(clientKey, secret, callbackURL, openIDAutoDiscoveryURL string, scopes .
|
|||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
|
||||
UserIdClaims: []string{subjectClaim},
|
||||
NameClaims: []string{NameClaim},
|
||||
NickNameClaims: []string{NicknameClaim, PreferredUsernameClaim},
|
||||
EmailClaims: []string{EmailClaim},
|
||||
AvatarURLClaims:[]string{PictureClaim},
|
||||
FirstNameClaims:[]string{GivenNameClaim},
|
||||
LastNameClaims: []string{FamilyNameClaim},
|
||||
LocationClaims: []string{AddressClaim},
|
||||
UserIdClaims: []string{subjectClaim},
|
||||
NameClaims: []string{NameClaim},
|
||||
NickNameClaims: []string{NicknameClaim, PreferredUsernameClaim},
|
||||
EmailClaims: []string{EmailClaim},
|
||||
AvatarURLClaims: []string{PictureClaim},
|
||||
FirstNameClaims: []string{GivenNameClaim},
|
||||
LastNameClaims: []string{FamilyNameClaim},
|
||||
LocationClaims: []string{AddressClaim},
|
||||
|
||||
providerName: "openid-connect",
|
||||
}
|
||||
|
|
4
vendor/github.com/markbates/goth/providers/openidConnect/session.go
generated
vendored
4
vendor/github.com/markbates/goth/providers/openidConnect/session.go
generated
vendored
|
@ -1,12 +1,12 @@
|
|||
package openidConnect
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/markbates/goth"
|
||||
"encoding/json"
|
||||
"golang.org/x/oauth2"
|
||||
"strings"
|
||||
"time"
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
// Session stores data during the auth process with the OpenID Connect provider.
|
||||
|
|
24
vendor/github.com/markbates/goth/providers/twitter/twitter.go
generated
vendored
24
vendor/github.com/markbates/goth/providers/twitter/twitter.go
generated
vendored
|
@ -9,10 +9,11 @@ import (
|
|||
"io/ioutil"
|
||||
"net/http"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/markbates/goth"
|
||||
"github.com/mrjones/oauth"
|
||||
"golang.org/x/oauth2"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -30,10 +31,10 @@ var (
|
|||
// If you'd like to use authenticate instead of authorize, use NewAuthenticate instead.
|
||||
func New(clientKey, secret, callbackURL string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "twitter",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "twitter",
|
||||
}
|
||||
p.consumer = newConsumer(p, authorizeURL)
|
||||
return p
|
||||
|
@ -43,10 +44,10 @@ func New(clientKey, secret, callbackURL string) *Provider {
|
|||
// NewAuthenticate uses the authenticate URL instead of the authorize URL.
|
||||
func NewAuthenticate(clientKey, secret, callbackURL string) *Provider {
|
||||
p := &Provider{
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "twitter",
|
||||
ClientKey: clientKey,
|
||||
Secret: secret,
|
||||
CallbackURL: callbackURL,
|
||||
providerName: "twitter",
|
||||
}
|
||||
p.consumer = newConsumer(p, authenticateURL)
|
||||
return p
|
||||
|
@ -107,7 +108,7 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
|
|||
|
||||
response, err := p.consumer.Get(
|
||||
endpointProfile,
|
||||
map[string]string{"include_entities": "false", "skip_status": "true"},
|
||||
map[string]string{"include_entities": "false", "skip_status": "true", "include_email": "true"},
|
||||
sess.AccessToken)
|
||||
if err != nil {
|
||||
return user, err
|
||||
|
@ -126,6 +127,9 @@ func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {
|
|||
|
||||
user.Name = user.RawData["name"].(string)
|
||||
user.NickName = user.RawData["screen_name"].(string)
|
||||
if user.RawData["email"] != nil {
|
||||
user.Email = user.RawData["email"].(string)
|
||||
}
|
||||
user.Description = user.RawData["description"].(string)
|
||||
user.AvatarURL = user.RawData["profile_image_url"].(string)
|
||||
user.UserID = user.RawData["id_str"].(string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue