implement admin-access with OAuth

This commit is contained in:
Min RK
2017-03-30 19:15:43 +02:00
parent ff6a68112e
commit 4bb8e47f3b
7 changed files with 18 additions and 25 deletions

View File

@@ -503,6 +503,7 @@ class HubAuthenticated(object):
hub_services = None # set of allowed services
hub_users = None # set of allowed users
hub_groups = None # set of allowed groups
allow_admin = False # allow any admin user access
@property
def allow_all(self):
@@ -546,13 +547,17 @@ class HubAuthenticated(object):
Returns:
user_model (dict): The user model if the user should be allowed, None otherwise.
"""
name = model['name']
kind = model.get('kind', 'user')
if self.allow_all:
app_log.debug("Allowing Hub %s %s (all Hub users and services allowed)", kind, name)
return model
if self.allow_admin and model.get('admin', False):
app_log.debug("Allowing Hub admin %s", name)
return model
if kind == 'service':
# it's a service, check hub_services
if self.hub_services and name in self.hub_services: