forked from forgejo/forgejo
go1.16 (#14783)
This commit is contained in:
parent
030646eea4
commit
47f6a4ec3f
947 changed files with 26119 additions and 7062 deletions
14
vendor/github.com/markbates/goth/providers/discord/discord.go
generated
vendored
14
vendor/github.com/markbates/goth/providers/discord/discord.go
generated
vendored
|
@ -162,9 +162,21 @@ func userFromReader(r io.Reader, user *goth.User) error {
|
|||
return err
|
||||
}
|
||||
|
||||
//If this prefix is present, the image should be available as a gif,
|
||||
//See : https://discord.com/developers/docs/reference#image-formatting
|
||||
//Introduced by : Yyewolf
|
||||
|
||||
if u.AvatarID != "" {
|
||||
avatarExtension := ".jpg"
|
||||
prefix := "a_"
|
||||
if len(u.AvatarID) >= len(prefix) && u.AvatarID[0:len(prefix)] == prefix {
|
||||
avatarExtension = ".gif"
|
||||
}
|
||||
user.AvatarURL = "https://media.discordapp.net/avatars/" + u.ID + "/" + u.AvatarID + avatarExtension
|
||||
}
|
||||
|
||||
user.Name = u.Name
|
||||
user.Email = u.Email
|
||||
user.AvatarURL = "https://media.discordapp.net/avatars/" + u.ID + "/" + u.AvatarID + ".jpg"
|
||||
user.UserID = u.ID
|
||||
|
||||
return nil
|
||||
|
|
10
vendor/github.com/markbates/goth/providers/google/google.go
generated
vendored
10
vendor/github.com/markbates/goth/providers/google/google.go
generated
vendored
|
@ -184,3 +184,13 @@ func (p *Provider) SetHostedDomain(hd string) {
|
|||
}
|
||||
p.authCodeOptions = append(p.authCodeOptions, oauth2.SetAuthURLParam("hd", hd))
|
||||
}
|
||||
|
||||
// SetLoginHint sets the login_hint parameter for the google OAuth call.
|
||||
// Use this to prompt the user to login with a specific account.
|
||||
// See https://developers.google.com/identity/protocols/oauth2/openid-connect#login-hint
|
||||
func (p *Provider) SetLoginHint(loginHint string) {
|
||||
if loginHint == "" {
|
||||
return
|
||||
}
|
||||
p.authCodeOptions = append(p.authCodeOptions, oauth2.SetAuthURLParam("login_hint", loginHint))
|
||||
}
|
||||
|
|
17
vendor/github.com/markbates/goth/providers/openidConnect/openidConnect.go
generated
vendored
17
vendor/github.com/markbates/goth/providers/openidConnect/openidConnect.go
generated
vendored
|
@ -54,8 +54,8 @@ type Provider struct {
|
|||
Secret string
|
||||
CallbackURL string
|
||||
HTTPClient *http.Client
|
||||
OpenIDConfig *OpenIDConfig
|
||||
config *oauth2.Config
|
||||
openIDConfig *OpenIDConfig
|
||||
providerName string
|
||||
|
||||
UserIdClaims []string
|
||||
|
@ -74,7 +74,12 @@ type OpenIDConfig struct {
|
|||
AuthEndpoint string `json:"authorization_endpoint"`
|
||||
TokenEndpoint string `json:"token_endpoint"`
|
||||
UserInfoEndpoint string `json:"userinfo_endpoint"`
|
||||
Issuer string `json:"issuer"`
|
||||
|
||||
// If OpenID discovery is enabled, the end_session_endpoint field can optionally be provided
|
||||
// in the discovery endpoint response according to OpenID spec. See:
|
||||
// https://openid.net/specs/openid-connect-session-1_0-17.html#OPMetadata
|
||||
EndSessionEndpoint string `json:"end_session_endpoint, omitempty"`
|
||||
Issuer string `json:"issuer"`
|
||||
}
|
||||
|
||||
// New creates a new OpenID Connect provider, and sets up important connection details.
|
||||
|
@ -106,7 +111,7 @@ func New(clientKey, secret, callbackURL, openIDAutoDiscoveryURL string, scopes .
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.openIDConfig = openIDConfig
|
||||
p.OpenIDConfig = openIDConfig
|
||||
|
||||
p.config = newConfig(p, scopes, openIDConfig)
|
||||
return p, nil
|
||||
|
@ -216,7 +221,7 @@ func (p *Provider) validateClaims(claims map[string]interface{}) (time.Time, err
|
|||
}
|
||||
|
||||
issuer := getClaimValue(claims, []string{issuerClaim})
|
||||
if issuer != p.openIDConfig.Issuer {
|
||||
if issuer != p.OpenIDConfig.Issuer {
|
||||
return time.Time{}, errors.New("issuer in token does not match issuer in OpenIDConfig discovery")
|
||||
}
|
||||
|
||||
|
@ -245,11 +250,11 @@ func (p *Provider) userFromClaims(claims map[string]interface{}, user *goth.User
|
|||
|
||||
func (p *Provider) getUserInfo(accessToken string, claims map[string]interface{}) error {
|
||||
// skip if there is no UserInfoEndpoint or is explicitly disabled
|
||||
if p.openIDConfig.UserInfoEndpoint == "" || p.SkipUserInfoRequest {
|
||||
if p.OpenIDConfig.UserInfoEndpoint == "" || p.SkipUserInfoRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
userInfoClaims, err := p.fetchUserInfo(p.openIDConfig.UserInfoEndpoint, accessToken)
|
||||
userInfoClaims, err := p.fetchUserInfo(p.OpenIDConfig.UserInfoEndpoint, accessToken)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue