Merge pull request #192 from gravitl/feature_v0.6_multitenancy

Feature v0.6 multitenancy
This commit is contained in:
Alex
2021-07-02 22:04:44 -04:00
committed by GitHub
13 changed files with 222 additions and 50 deletions

View File

@@ -79,8 +79,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")
}
}