mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 16:57:51 +08:00
Merge pull request #192 from gravitl/feature_v0.6_multitenancy
Feature v0.6 multitenancy
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user