mirror of
https://github.com/grafana/grafana.git
synced 2025-02-03 20:21:01 -06:00
moved back to a main.go file in root
This commit is contained in:
parent
d8d5516e24
commit
50164324f3
3
Makefile
3
Makefile
@ -5,4 +5,7 @@ all: build
|
||||
build:
|
||||
go build ../pkg/cmd/grafana-pro/
|
||||
|
||||
setup:
|
||||
go get github.com/tools/godep
|
||||
|
||||
|
||||
|
@ -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)
|
||||
}
|
@ -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)
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
// Copyright 2014 Unknwon
|
||||
// Copyright 2014 Torkel Ödegaard
|
||||
|
||||
package main
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user