Merge remote-tracking branch 'origin/0.4-database' into 0.4-database
This commit is contained in:
commit
64f8294775
4 changed files with 14 additions and 3 deletions
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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