hotfixes for repo. Now works.

This commit is contained in:
afeiszli
2021-03-25 22:29:36 -04:00
parent 6343207ea5
commit e489a18492
25 changed files with 232 additions and 757 deletions

View File

@@ -150,8 +150,14 @@ func authorize(groupCheck bool, authGroup string, next http.Handler) http.Handle
if len(tokenSplit) > 1 {
authToken = tokenSplit[1]
} else {
errorResponse = models.ErrorResponse{
Code: http.StatusUnauthorized, Message: "W1R3: Missing Auth Token.",
}
returnErrorResponse(w, r, errorResponse)
}
//This checks if
//A: the token is the master password
//B: the token corresponds to a mac address, and if so, which one
@@ -159,7 +165,10 @@ func authorize(groupCheck bool, authGroup string, next http.Handler) http.Handle
macaddress, _, err := functions.VerifyToken(authToken)
if err != nil {
return
errorResponse = models.ErrorResponse{
Code: http.StatusUnauthorized, Message: "W1R3: Error Verifying Auth Token.",
}
returnErrorResponse(w, r, errorResponse)
}
var isAuthorized = false
@@ -179,7 +188,10 @@ func authorize(groupCheck bool, authGroup string, next http.Handler) http.Handle
case "group":
node, err := functions.GetNodeByMacAddress(params["group"], macaddress)
if err != nil {
return
errorResponse = models.ErrorResponse{
Code: http.StatusUnauthorized, Message: "W1R3: Missing Auth Token.",
}
returnErrorResponse(w, r, errorResponse)
}
isAuthorized = (node.Group == params["group"])
case "node":
@@ -567,6 +579,8 @@ func uncordonNode(w http.ResponseWriter, r *http.Request) {
mongoconn.GetError(errN, w)
return
}
fmt.Println("Node " + node.Name + " uncordoned.")
json.NewEncoder(w).Encode("SUCCESS")
}