diff --git a/config/environments/dev.yaml b/config/environments/dev.yaml index 1143af15..fdf49418 100644 --- a/config/environments/dev.yaml +++ b/config/environments/dev.yaml @@ -1,5 +1,5 @@ server: - host: "localhost" + host: "3.231.219.63" apiport: "8081" grpcport: "50051" masterkey: "secretkey" diff --git a/controllers/networkHttpController.go b/controllers/networkHttpController.go index b1f8b07a..2161563c 100644 --- a/controllers/networkHttpController.go +++ b/controllers/networkHttpController.go @@ -9,7 +9,7 @@ import ( "net/http" "strings" "time" - + "os" "github.com/gorilla/mux" "github.com/gravitl/netmaker/config" "github.com/gravitl/netmaker/functions" @@ -83,7 +83,7 @@ func securityCheck(next http.Handler) http.HandlerFunc { //Consider a more secure way of setting master key func authenticateMaster(tokenString string) bool { - if tokenString == config.Config.Server.MasterKey { + if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { return true } return false diff --git a/functions/jwt.go b/functions/jwt.go index 6570af5d..49699f58 100644 --- a/functions/jwt.go +++ b/functions/jwt.go @@ -2,6 +2,7 @@ package functions import ( "time" + "os" "github.com/gravitl/netmaker/config" "github.com/gravitl/netmaker/models" "github.com/dgrijalva/jwt-go" @@ -50,7 +51,7 @@ func CreateUserJWT(username string, isadmin bool) (response string, err error) { func VerifyUserToken(tokenString string) (username string, isadmin bool, err error) { claims := &models.UserClaims{} - if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") { + if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { return "masteradministrator", true, nil } @@ -70,7 +71,7 @@ func VerifyToken(tokenString string) (macaddress string, network string, err err //this may be a stupid way of serving up a master key //TODO: look into a different method. Encryption? - if tokenString == config.Config.Server.MasterKey || os.Getenv("MASTER_KEY") { + if tokenString == config.Config.Server.MasterKey || (tokenString == os.Getenv("MASTER_KEY") && tokenString != "") { return "mastermac", "", nil } diff --git a/main.go b/main.go index a49f8727..44c65c61 100644 --- a/main.go +++ b/main.go @@ -38,6 +38,7 @@ var PortGRPC string //Start MongoDB Connection and start API Request Handler func main() { + var clientmode string var defaultnet string flag.StringVar(&clientmode, "clientmode", "on", "Have a client on the server")