2
0
Ubuntu 4 жил өмнө
parent
commit
fa3faf778d

+ 1 - 1
config/environments/dev.yaml

@@ -1,5 +1,5 @@
 server:
-  host: "localhost"
+  host: "3.231.219.63"
   apiport: "8081"
   grpcport: "50051"
   masterkey: "secretkey"

+ 2 - 2
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

+ 3 - 2
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
     }
 

+ 1 - 0
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")