multitenancy working

This commit is contained in:
afeiszli
2021-07-02 00:03:46 -04:00
parent 0164345f85
commit 041b641e17
8 changed files with 184 additions and 27 deletions

View File

@@ -78,8 +78,15 @@ func SecurityCheck(netname, token string) error {
}
//all endpoints here require master so not as complicated
if !hasBearer || !authenticateMaster(authToken) {
_, isadmin, err := functions.VerifyUserToken(authToken)
if err != nil || !isadmin {
_, networks, isadmin, err := functions.VerifyUserToken(authToken)
if err != nil {
return errors.New("Error verifying user token")
}
if !isadmin && netname != ""{
if !functions.SliceContains(networks, netname){
return errors.New("You are unauthorized to access this endpoint")
}
} else if !isadmin {
return errors.New("You are unauthorized to access this endpoint")
}
}