diff --git a/cmd/drone-server/drone.go b/cmd/drone-server/drone.go index a8099ff1..9f34453d 100644 --- a/cmd/drone-server/drone.go +++ b/cmd/drone-server/drone.go @@ -4,7 +4,6 @@ import ( "flag" "html/template" "net/http" - "os" "github.com/drone/drone/Godeps/_workspace/src/github.com/gin-gonic/gin" @@ -45,7 +44,7 @@ func main() { panic(err) } - store, err := store.New(os.Getenv("DATABASE")) + store, err := store.New(settings.Database.Driver + "://" + settings.Database.Datasource) if err != nil { panic(err) } diff --git a/pkg/remote/builtin/github/github.go b/pkg/remote/builtin/github/github.go index b7fb1f82..1f50bf13 100644 --- a/pkg/remote/builtin/github/github.go +++ b/pkg/remote/builtin/github/github.go @@ -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) { diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index a195f416..8f95572a 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -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 } diff --git a/pkg/server/login.go b/pkg/server/login.go index 266f5ec6..5e73129e 100644 --- a/pkg/server/login.go +++ b/pkg/server/login.go @@ -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)),