'Check whether Hub-authenticated user or service should be allowed.
Returns the input if the user should be allowed, None otherwise.
Override if you want to check anything other than the username\'s presence in hub_users list.
Args:
model (dict): the user or service model returned from :class:`HubAuth`
Returns:
user_model (dict): The user model if the user should be allowed, None otherwise.'

def check_hub_user(self, model):

    name = model['name']
    kind = model.setdefault('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'):
        if (self.hub_services and (name in self.hub_services)):
            app_log.debug('Allowing    whitelisted    Hub    service    %s', name)
            return model
        else:
            app_log.warning('Not    allowing    Hub    service    %s', name)
            raise UserNotAllowed(model)
    if (self.hub_users and (name in self.hub_users)):
        app_log.debug('Allowing    whitelisted    Hub    user    %s', name)
        return model
    elif (self.hub_groups and set(model['groups']).intersection(self.hub_groups)):
        allowed_groups = set(model['groups']).intersection(self.hub_groups)
        app_log.debug('Allowing    Hub    user    %s    in    group(s)    %s', name, ','.join(sorted(allowed_groups)))
        return model
    else:
        app_log.warning('Not    allowing    Hub    user    %s', name)
        raise UserNotAllowed(model)
