diff --git a/Makefile b/Makefile index fe11beda719..e2fbf75f946 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,7 @@ all: build build: go build ../pkg/cmd/grafana-pro/ +setup: + go get github.com/tools/godep + diff --git a/grafana.go b/main.go similarity index 89% rename from grafana.go rename to main.go index 1d2a7585b3e..95929a39f79 100644 --- a/grafana.go +++ b/main.go @@ -4,8 +4,9 @@ import ( "os" "runtime" - "github.com/codegangsta/cli" "github.com/torkelo/grafana-pro/pkg/cmd" + + "github.com/codegangsta/cli" ) const APP_VER = "0.1.0 Alpha" @@ -19,9 +20,7 @@ func main() { app.Name = "Grafana Pro" app.Usage = "Grafana Pro Service" app.Version = APP_VER - app.Commands = []cli.Command{ - cmd.CmdWeb, - } + app.Commands = []cli.Command{cmd.CmdWeb} app.Flags = append(app.Flags, []cli.Flag{}...) app.Run(os.Args) } diff --git a/pkg/cmd/grafana-pro/grafana-pro.go b/pkg/cmd/grafana-pro/grafana-pro.go deleted file mode 100644 index a4d5af5822e..00000000000 --- a/pkg/cmd/grafana-pro/grafana-pro.go +++ /dev/null @@ -1,24 +0,0 @@ -package main - -import ( - "os" - "runtime" - - "github.com/codegangsta/cli" -) - -const APP_VER = "0.1.0 Alpha" - -func init() { - runtime.GOMAXPROCS(runtime.NumCPU()) -} - -func main() { - app := cli.NewApp() - app.Name = "Grafana Pro" - app.Usage = "Grafana Pro Service" - app.Version = APP_VER - app.Commands = []cli.Command{CmdWeb} - app.Flags = append(app.Flags, []cli.Flag{}...) - app.Run(os.Args) -} diff --git a/pkg/cmd/grafana-pro/web.go b/pkg/cmd/web.go similarity index 99% rename from pkg/cmd/grafana-pro/web.go rename to pkg/cmd/web.go index 9b7541c26a6..24f02d381c4 100644 --- a/pkg/cmd/grafana-pro/web.go +++ b/pkg/cmd/web.go @@ -1,7 +1,7 @@ // Copyright 2014 Unknwon // Copyright 2014 Torkel Ödegaard -package main +package cmd import ( "fmt" diff --git a/pkg/routes/login/login_oauth.go b/pkg/routes/login/login_oauth.go index f2321154b4b..1bf71a5d6c9 100644 --- a/pkg/routes/login/login_oauth.go +++ b/pkg/routes/login/login_oauth.go @@ -32,7 +32,7 @@ func OAuthLogin(ctx *middleware.Context) { log.Info("code: %v", code) // handle call back - transport, err := connect.NewTransportWithCode(code) + transport, err := connect.NewTransportFromCode(code) if err != nil { ctx.Handle(500, "login.OAuthLogin(NewTransportWithCode)", err) return diff --git a/pkg/social/social.go b/pkg/social/social.go index 87231278a74..26e9b5e71b0 100644 --- a/pkg/social/social.go +++ b/pkg/social/social.go @@ -6,10 +6,11 @@ import ( "strconv" "strings" - "github.com/gogits/gogs/models" - "github.com/golang/oauth2" "github.com/torkelo/grafana-pro/pkg/log" + "github.com/torkelo/grafana-pro/pkg/models" "github.com/torkelo/grafana-pro/pkg/setting" + + "github.com/golang/oauth2" ) type BasicUserInfo struct { @@ -25,7 +26,7 @@ type SocialConnector interface { UserInfo(transport *oauth2.Transport) (*BasicUserInfo, error) AuthCodeURL(state, accessType, prompt string) string - NewTransportWithCode(code string) (*oauth2.Transport, error) + NewTransportFromCode(code string) (*oauth2.Transport, error) } var ( @@ -58,15 +59,13 @@ func NewOAuthService() { continue } - opts := &oauth2.Options{ - ClientID: info.ClientId, - ClientSecret: info.ClientSecret, - RedirectURL: strings.TrimSuffix(setting.AppUrl, "/") + SocialBaseUrl + name, - Scopes: info.Scopes, - } - setting.OAuthService.OAuthInfos[name] = info - config, err := oauth2.NewConfig(opts, info.AuthUrl, info.TokenUrl) + options, err := oauth2.New( + oauth2.Client(info.ClientId, info.ClientSecret), + oauth2.Scope(info.Scopes...), + oauth2.Endpoint(info.AuthUrl, info.TokenUrl), + oauth2.RedirectURL(strings.TrimSuffix(setting.AppUrl, "/")+SocialBaseUrl+name), + ) if err != nil { log.Error(3, "Failed to init oauth service", err) @@ -76,19 +75,19 @@ func NewOAuthService() { // GitHub. if name == "github" { setting.OAuthService.GitHub = true - SocialMap["github"] = &SocialGithub{Config: config} + SocialMap["github"] = &SocialGithub{Options: options} } // Google. if name == "google" { setting.OAuthService.Google = true - SocialMap["google"] = &SocialGoogle{Config: config} + SocialMap["google"] = &SocialGoogle{Options: options} } } } type SocialGithub struct { - *oauth2.Config + *oauth2.Options } func (s *SocialGithub) Type() int { @@ -130,7 +129,7 @@ func (s *SocialGithub) UserInfo(transport *oauth2.Transport) (*BasicUserInfo, er // \/ /_____/ \/ type SocialGoogle struct { - *oauth2.Config + *oauth2.Options } func (s *SocialGoogle) Type() int {