mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
Fix logging into Github. Add setting default scope even if it not set in config file.
This commit is contained in:
parent
44ec2c3064
commit
9652875129
3 changed files with 13 additions and 1 deletions
|
@ -231,6 +231,11 @@ func (g *GitHub) Hook(r *http.Request) (*common.Hook, error) {
|
|||
}
|
||||
}
|
||||
|
||||
// return default scope for GitHub
|
||||
func (g *GitHub) Scope() string {
|
||||
return DefaultScope
|
||||
}
|
||||
|
||||
// push parses a hook with event type `push` and returns
|
||||
// the commit data.
|
||||
func (g *GitHub) push(r *http.Request) (*common.Hook, error) {
|
||||
|
|
|
@ -44,4 +44,7 @@ type Remote interface {
|
|||
// Hook parses the post-commit hook from the Request body
|
||||
// and returns the required data in a standard format.
|
||||
Hook(r *http.Request) (*common.Hook, error)
|
||||
|
||||
// Default scope for remote
|
||||
Scope() string
|
||||
}
|
||||
|
|
|
@ -134,10 +134,14 @@ func getLoginOauth2(c *gin.Context) {
|
|||
var settings = ToSettings(c)
|
||||
var remote = ToRemote(c)
|
||||
|
||||
var scope = strings.Join(settings.Auth.Scope, ",")
|
||||
if scope == "" {
|
||||
scope = remote.Scope()
|
||||
}
|
||||
var config = &oauth2.Config{
|
||||
ClientId: settings.Auth.Client,
|
||||
ClientSecret: settings.Auth.Secret,
|
||||
Scope: strings.Join(settings.Auth.Scope, ","),
|
||||
Scope: scope,
|
||||
AuthURL: settings.Auth.Authorize,
|
||||
TokenURL: settings.Auth.AccessToken,
|
||||
RedirectURL: fmt.Sprintf("%s/authorize", httputil.GetURL(c.Request)),
|
||||
|
|
Loading…
Reference in a new issue