diff --git a/Makefile b/Makefile index 7dfee462..502f26d5 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,12 @@ HOST ?= root@167.99.223.55 HOSTNAME ?= yolo.berty.io CIRCLE_TOKEN ?= ***REMOVED*** PASSWORD ?= 'xor+=cool' +RUN_OPTS ?= --no-slack --no-ga --no-auth .PHONY: run run: install - yolo -t $(CIRCLE_TOKEN) serve --debug --no-slack --no-ga + yolo -t $(CIRCLE_TOKEN) serve --debug $(RUN_OPTS) .PHONY: install install: diff --git a/cmd/yolo/server.go b/cmd/yolo/server.go index 458fb3af..81d9b9c1 100644 --- a/cmd/yolo/server.go +++ b/cmd/yolo/server.go @@ -34,6 +34,7 @@ func init() { serveCmd.PersistentFlags().BoolVarP(&serverCfg.Debug, "debug", "", false, "debug mode") serveCmd.PersistentFlags().BoolVarP(&serverCfg.NoSlack, "no-slack", "", false, "disable slack") serveCmd.PersistentFlags().BoolVarP(&serverCfg.NoGa, "no-ga", "", false, "disable google analytics") + serveCmd.PersistentFlags().BoolVarP(&serverCfg.NoAuth, "no-auth", "", false, "disable auth") serveCmd.PersistentFlags().StringVarP(&serverCfg.SqlConn, "sql-conn", "", "./yolo.sqlite", "sql connection url") rootCmd.AddCommand(serveCmd) diff --git a/server/server.go b/server/server.go index 56a2c579..91c804b2 100644 --- a/server/server.go +++ b/server/server.go @@ -41,6 +41,7 @@ type ServerConfig struct { Debug bool NoSlack bool NoGa bool + NoAuth bool SqlConn string } @@ -83,6 +84,7 @@ type Server struct { Debug bool NoSlack bool NoGa bool + NoAuth bool // templates/static funcmap *ctxFuncmap @@ -139,6 +141,7 @@ func NewServer(cfg *ServerConfig) (*Server, error) { Debug: cfg.Debug, NoSlack: cfg.NoSlack, NoGa: cfg.NoGa, + NoAuth: cfg.NoAuth, } e.HTTPErrorHandler = func(err error, c echo.Context) { s.sendUserErrorToSlack(c, err) @@ -177,19 +180,21 @@ func NewServer(cfg *ServerConfig) (*Server, error) { oauth.GET("/logout", o.LogoutHandler(s.hostUrl)) release := e.Group("release") - release.Use(o.ProtectMiddleware("/oauth/login", func(profile map[string]interface{}) bool { - if v, ok := profile["https://yolo.berty.io/groups"]; ok { - if groups, ok := v.([]interface{}); ok { - for _, group := range groups { - if g, ok := group.(string); ok && g == "yolo" { - return true + if !cfg.NoAuth { + release.Use(o.ProtectMiddleware("/oauth/login", func(profile map[string]interface{}) bool { + if v, ok := profile["https://yolo.berty.io/groups"]; ok { + if groups, ok := v.([]interface{}); ok { + for _, group := range groups { + if g, ok := group.(string); ok && g == "yolo" { + return true + } } } } - } - return false - })) + return false + })) + } release.GET("/ios", s.ListReleaseIOSBeta) release.GET("/android", s.ListReleaseAndroidBeta) @@ -207,19 +212,21 @@ func NewServer(cfg *ServerConfig) (*Server, error) { desktop.GET("/mac.json", s.ListReleaseDMGJson) staffRelease := e.Group("/release/staff") - staffRelease.Use(o.ProtectMiddleware("/oauth/login", func(profile map[string]interface{}) bool { - if v, ok := profile["https://yolo.berty.io/groups"]; ok { - if groups, ok := v.([]interface{}); ok { - for _, group := range groups { - if g, ok := group.(string); ok && g == "staff" { - return true + if !cfg.NoAuth { + staffRelease.Use(o.ProtectMiddleware("/oauth/login", func(profile map[string]interface{}) bool { + if v, ok := profile["https://yolo.berty.io/groups"]; ok { + if groups, ok := v.([]interface{}); ok { + for _, group := range groups { + if g, ok := group.(string); ok && g == "staff" { + return true + } } } } - } - return false - })) + return false + })) + } staffRelease.GET("/ios/*", s.ReleaseIOS) staffRelease.GET("/ios", s.ListReleaseIOS) staffRelease.GET("/mac", s.ListReleaseDMG)