2013-09-20 22:38:17 +00:00
|
|
|
import logging
|
|
|
|
|
2014-03-18 23:21:27 +00:00
|
|
|
from flask.ext.principal import identity_loaded, Permission, Identity, identity_changed
|
|
|
|
from collections import namedtuple, defaultdict
|
2013-09-25 20:46:28 +00:00
|
|
|
from functools import partial
|
2013-09-20 22:38:17 +00:00
|
|
|
|
2014-03-19 22:09:09 +00:00
|
|
|
import scopes
|
|
|
|
|
2013-09-25 16:45:12 +00:00
|
|
|
from data import model
|
2015-01-20 17:43:11 +00:00
|
|
|
from app import app, superusers
|
2013-09-20 22:38:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2013-09-25 20:46:28 +00:00
|
|
|
_ResourceNeed = namedtuple('resource', ['type', 'namespace', 'name', 'role'])
|
|
|
|
_RepositoryNeed = partial(_ResourceNeed, 'repository')
|
2014-03-25 21:26:45 +00:00
|
|
|
_NamespaceWideNeed = namedtuple('namespacewide', ['type', 'namespace', 'role'])
|
|
|
|
_OrganizationNeed = partial(_NamespaceWideNeed, 'organization')
|
|
|
|
_OrganizationRepoNeed = partial(_NamespaceWideNeed, 'organizationrepo')
|
|
|
|
_TeamTypeNeed = namedtuple('teamwideneed', ['type', 'orgname', 'teamname', 'role'])
|
|
|
|
_TeamNeed = partial(_TeamTypeNeed, 'orgteam')
|
|
|
|
_UserTypeNeed = namedtuple('userspecificneed', ['type', 'username', 'role'])
|
|
|
|
_UserNeed = partial(_UserTypeNeed, 'user')
|
2014-04-10 19:51:39 +00:00
|
|
|
_SuperUserNeed = partial(namedtuple('superuserneed', ['type']), 'superuser')
|
2013-09-20 22:38:17 +00:00
|
|
|
|
|
|
|
|
2014-03-12 20:31:37 +00:00
|
|
|
REPO_ROLES = [None, 'read', 'write', 'admin']
|
|
|
|
TEAM_ROLES = [None, 'member', 'creator', 'admin']
|
2015-06-30 14:58:10 +00:00
|
|
|
USER_ROLES = [None, 'read', 'admin']
|
2014-03-12 20:31:37 +00:00
|
|
|
|
2016-08-04 20:23:09 +00:00
|
|
|
TEAM_ORGWIDE_REPO_ROLES = {
|
2014-03-19 18:36:56 +00:00
|
|
|
'admin': 'admin',
|
2016-08-04 20:23:09 +00:00
|
|
|
'creator': None,
|
|
|
|
'member': None,
|
2014-03-19 18:36:56 +00:00
|
|
|
}
|
|
|
|
|
2014-03-18 23:21:27 +00:00
|
|
|
SCOPE_MAX_REPO_ROLES = defaultdict(lambda: None)
|
|
|
|
SCOPE_MAX_REPO_ROLES.update({
|
2014-03-19 22:09:09 +00:00
|
|
|
scopes.READ_REPO: 'read',
|
|
|
|
scopes.WRITE_REPO: 'write',
|
|
|
|
scopes.ADMIN_REPO: 'admin',
|
|
|
|
scopes.DIRECT_LOGIN: 'admin',
|
2014-03-18 23:21:27 +00:00
|
|
|
})
|
2014-03-12 20:31:37 +00:00
|
|
|
|
2014-03-18 23:21:27 +00:00
|
|
|
SCOPE_MAX_TEAM_ROLES = defaultdict(lambda: None)
|
|
|
|
SCOPE_MAX_TEAM_ROLES.update({
|
2014-03-19 22:09:09 +00:00
|
|
|
scopes.CREATE_REPO: 'creator',
|
|
|
|
scopes.DIRECT_LOGIN: 'admin',
|
2014-08-06 00:53:00 +00:00
|
|
|
scopes.ORG_ADMIN: 'admin',
|
2014-03-18 23:21:27 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
SCOPE_MAX_USER_ROLES = defaultdict(lambda: None)
|
|
|
|
SCOPE_MAX_USER_ROLES.update({
|
2014-03-19 22:09:09 +00:00
|
|
|
scopes.READ_USER: 'read',
|
|
|
|
scopes.DIRECT_LOGIN: 'admin',
|
2016-05-09 09:16:01 +00:00
|
|
|
scopes.ADMIN_USER: 'admin',
|
2014-03-18 23:21:27 +00:00
|
|
|
})
|
|
|
|
|
2015-02-19 21:54:23 +00:00
|
|
|
def repository_read_grant(namespace, repository):
|
|
|
|
return _RepositoryNeed(namespace, repository, 'read')
|
|
|
|
|
|
|
|
|
|
|
|
def repository_write_grant(namespace, repository):
|
|
|
|
return _RepositoryNeed(namespace, repository, 'write')
|
|
|
|
|
|
|
|
|
2013-10-15 18:48:49 +00:00
|
|
|
class QuayDeferredPermissionUser(Identity):
|
2015-05-07 19:04:12 +00:00
|
|
|
def __init__(self, uuid, auth_type, auth_scopes, user=None):
|
2014-11-20 23:44:36 +00:00
|
|
|
super(QuayDeferredPermissionUser, self).__init__(uuid, auth_type)
|
2013-10-15 18:48:49 +00:00
|
|
|
|
2016-03-16 20:08:53 +00:00
|
|
|
self._namespace_wide_loaded = set()
|
|
|
|
self._repositories_loaded = set()
|
|
|
|
self._personal_loaded = False
|
|
|
|
|
2015-05-07 19:04:12 +00:00
|
|
|
self._scope_set = auth_scopes
|
|
|
|
self._user_object = user
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def for_id(uuid, auth_scopes=None):
|
2015-07-31 16:36:51 +00:00
|
|
|
auth_scopes = auth_scopes if auth_scopes is not None else {scopes.DIRECT_LOGIN}
|
|
|
|
return QuayDeferredPermissionUser(uuid, 'user_uuid', auth_scopes)
|
2015-05-07 19:04:12 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def for_user(user, auth_scopes=None):
|
2015-07-31 16:36:51 +00:00
|
|
|
auth_scopes = auth_scopes if auth_scopes is not None else {scopes.DIRECT_LOGIN}
|
|
|
|
return QuayDeferredPermissionUser(user.uuid, 'user_uuid', auth_scopes, user=user)
|
2014-03-12 20:31:37 +00:00
|
|
|
|
|
|
|
def _translate_role_for_scopes(self, cardinality, max_roles, role):
|
|
|
|
if self._scope_set is None:
|
|
|
|
return role
|
|
|
|
|
|
|
|
max_for_scopes = max({cardinality.index(max_roles[scope]) for scope in self._scope_set})
|
|
|
|
|
|
|
|
if max_for_scopes < cardinality.index(role):
|
|
|
|
logger.debug('Translated permission %s -> %s', role, cardinality[max_for_scopes])
|
|
|
|
return cardinality[max_for_scopes]
|
|
|
|
else:
|
|
|
|
return role
|
|
|
|
|
|
|
|
def _team_role_for_scopes(self, role):
|
|
|
|
return self._translate_role_for_scopes(TEAM_ROLES, SCOPE_MAX_TEAM_ROLES, role)
|
|
|
|
|
|
|
|
def _repo_role_for_scopes(self, role):
|
|
|
|
return self._translate_role_for_scopes(REPO_ROLES, SCOPE_MAX_REPO_ROLES, role)
|
2013-10-15 18:48:49 +00:00
|
|
|
|
2014-03-18 23:21:27 +00:00
|
|
|
def _user_role_for_scopes(self, role):
|
|
|
|
return self._translate_role_for_scopes(USER_ROLES, SCOPE_MAX_USER_ROLES, role)
|
|
|
|
|
2016-03-16 20:08:53 +00:00
|
|
|
def _populate_user_provides(self, user_object):
|
|
|
|
""" Populates the provides that naturally apply to a user, such as being the admin of
|
|
|
|
their own namespace.
|
|
|
|
"""
|
|
|
|
|
|
|
|
# Add the user specific permissions, only for non-oauth permission
|
|
|
|
user_grant = _UserNeed(user_object.username, self._user_role_for_scopes('admin'))
|
|
|
|
logger.debug('User permission: {0}'.format(user_grant))
|
|
|
|
self.provides.add(user_grant)
|
|
|
|
|
|
|
|
# Every user is the admin of their own 'org'
|
|
|
|
user_namespace = _OrganizationNeed(user_object.username, self._team_role_for_scopes('admin'))
|
|
|
|
logger.debug('User namespace permission: {0}'.format(user_namespace))
|
|
|
|
self.provides.add(user_namespace)
|
|
|
|
|
|
|
|
# Org repo roles can differ for scopes
|
|
|
|
user_repos = _OrganizationRepoNeed(user_object.username, self._repo_role_for_scopes('admin'))
|
|
|
|
logger.debug('User namespace repo permission: {0}'.format(user_repos))
|
|
|
|
self.provides.add(user_repos)
|
|
|
|
|
|
|
|
if ((scopes.SUPERUSER in self._scope_set or scopes.DIRECT_LOGIN in self._scope_set) and
|
|
|
|
superusers.is_superuser(user_object.username)):
|
|
|
|
logger.debug('Adding superuser to user: %s', user_object.username)
|
|
|
|
self.provides.add(_SuperUserNeed())
|
|
|
|
|
|
|
|
def _populate_namespace_wide_provides(self, user_object, namespace_filter):
|
|
|
|
""" Populates the namespace-wide provides for a particular user under a particular namespace.
|
|
|
|
This method does *not* add any provides for specific repositories.
|
|
|
|
"""
|
|
|
|
|
|
|
|
for team in model.permission.get_org_wide_permissions(user_object, org_filter=namespace_filter):
|
|
|
|
team_org_grant = _OrganizationNeed(team.organization.username,
|
|
|
|
self._team_role_for_scopes(team.role.name))
|
|
|
|
logger.debug('Organization team added permission: {0}'.format(team_org_grant))
|
|
|
|
self.provides.add(team_org_grant)
|
|
|
|
|
2016-08-04 20:23:09 +00:00
|
|
|
team_repo_role = TEAM_ORGWIDE_REPO_ROLES[team.role.name]
|
2016-03-16 20:08:53 +00:00
|
|
|
org_repo_grant = _OrganizationRepoNeed(team.organization.username,
|
|
|
|
self._repo_role_for_scopes(team_repo_role))
|
|
|
|
logger.debug('Organization team added repo permission: {0}'.format(org_repo_grant))
|
|
|
|
self.provides.add(org_repo_grant)
|
|
|
|
|
|
|
|
team_grant = _TeamNeed(team.organization.username, team.name,
|
|
|
|
self._team_role_for_scopes(team.role.name))
|
|
|
|
logger.debug('Team added permission: {0}'.format(team_grant))
|
|
|
|
self.provides.add(team_grant)
|
|
|
|
|
|
|
|
def _populate_repository_provides(self, user_object, namespace_filter, repository_name):
|
|
|
|
""" Populates the repository-specific provides for a particular user and repository. """
|
|
|
|
|
|
|
|
if namespace_filter and repository_name:
|
|
|
|
permissions = model.permission.get_user_repository_permissions(user_object, namespace_filter,
|
|
|
|
repository_name)
|
|
|
|
else:
|
|
|
|
permissions = model.permission.get_all_user_repository_permissions(user_object)
|
|
|
|
|
|
|
|
for perm in permissions:
|
|
|
|
repo_grant = _RepositoryNeed(perm.repository.namespace_user.username, perm.repository.name,
|
|
|
|
self._repo_role_for_scopes(perm.role.name))
|
|
|
|
logger.debug('User added permission: {0}'.format(repo_grant))
|
|
|
|
self.provides.add(repo_grant)
|
|
|
|
|
2013-10-15 18:48:49 +00:00
|
|
|
def can(self, permission):
|
2016-03-16 20:08:53 +00:00
|
|
|
logger.debug('Loading user permissions after deferring for: %s', self.id)
|
|
|
|
user_object = self._user_object or model.user.get_user_by_uuid(self.id)
|
|
|
|
if user_object is None:
|
|
|
|
return super(QuayDeferredPermissionUser, self).can(permission)
|
|
|
|
|
|
|
|
# Add the user-specific provides.
|
|
|
|
if not self._personal_loaded:
|
|
|
|
self._populate_user_provides(user_object)
|
|
|
|
self._personal_loaded = True
|
|
|
|
|
|
|
|
# If we now have permission, no need to load any more permissions.
|
|
|
|
if super(QuayDeferredPermissionUser, self).can(permission):
|
|
|
|
return super(QuayDeferredPermissionUser, self).can(permission)
|
|
|
|
|
|
|
|
# Check for namespace and/or repository permissions.
|
2016-03-25 21:47:37 +00:00
|
|
|
perm_namespace = permission.namespace
|
|
|
|
perm_repo_name = permission.repo_name
|
2016-03-16 20:08:53 +00:00
|
|
|
perm_repository = None
|
|
|
|
|
|
|
|
if perm_namespace and perm_repo_name:
|
|
|
|
perm_repository = '%s/%s' % (perm_namespace, perm_repo_name)
|
|
|
|
|
|
|
|
if not perm_namespace and not perm_repo_name:
|
|
|
|
# Nothing more to load, so just check directly.
|
|
|
|
return super(QuayDeferredPermissionUser, self).can(permission)
|
|
|
|
|
|
|
|
# Lazy-load the repository-specific permissions.
|
|
|
|
if perm_repository and perm_repository not in self._repositories_loaded:
|
|
|
|
self._populate_repository_provides(user_object, perm_namespace, perm_repo_name)
|
|
|
|
self._repositories_loaded.add(perm_repository)
|
|
|
|
|
|
|
|
# If we now have permission, no need to load any more permissions.
|
|
|
|
if super(QuayDeferredPermissionUser, self).can(permission):
|
2015-01-12 16:42:09 +00:00
|
|
|
return super(QuayDeferredPermissionUser, self).can(permission)
|
2013-10-15 18:48:49 +00:00
|
|
|
|
2016-03-16 20:08:53 +00:00
|
|
|
# Lazy-load the namespace-wide-only permissions.
|
|
|
|
if perm_namespace and perm_namespace not in self._namespace_wide_loaded:
|
|
|
|
self._populate_namespace_wide_provides(user_object, perm_namespace)
|
|
|
|
self._namespace_wide_loaded.add(perm_namespace)
|
2013-10-15 18:48:49 +00:00
|
|
|
|
|
|
|
return super(QuayDeferredPermissionUser, self).can(permission)
|
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class QuayPermission(Permission):
|
|
|
|
""" Base for all permissions in Quay. """
|
|
|
|
namespace = None
|
|
|
|
repo_name = None
|
|
|
|
|
|
|
|
|
|
|
|
class ModifyRepositoryPermission(QuayPermission):
|
2013-09-20 22:38:17 +00:00
|
|
|
def __init__(self, namespace, name):
|
|
|
|
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
|
|
|
write_need = _RepositoryNeed(namespace, name, 'write')
|
2014-03-19 18:36:56 +00:00
|
|
|
org_admin_need = _OrganizationRepoNeed(namespace, 'admin')
|
|
|
|
org_write_need = _OrganizationRepoNeed(namespace, 'write')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = namespace
|
|
|
|
self.repo_name = name
|
|
|
|
|
2014-03-19 18:36:56 +00:00
|
|
|
super(ModifyRepositoryPermission, self).__init__(admin_need, write_need, org_admin_need,
|
|
|
|
org_write_need)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class ReadRepositoryPermission(QuayPermission):
|
2013-09-20 22:38:17 +00:00
|
|
|
def __init__(self, namespace, name):
|
|
|
|
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
|
|
|
write_need = _RepositoryNeed(namespace, name, 'write')
|
|
|
|
read_need = _RepositoryNeed(namespace, name, 'read')
|
2014-03-19 18:36:56 +00:00
|
|
|
org_admin_need = _OrganizationRepoNeed(namespace, 'admin')
|
|
|
|
org_write_need = _OrganizationRepoNeed(namespace, 'write')
|
|
|
|
org_read_need = _OrganizationRepoNeed(namespace, 'read')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = namespace
|
|
|
|
self.repo_name = name
|
|
|
|
|
2014-03-19 18:36:56 +00:00
|
|
|
super(ReadRepositoryPermission, self).__init__(admin_need, write_need, read_need,
|
|
|
|
org_admin_need, org_read_need, org_write_need)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class AdministerRepositoryPermission(QuayPermission):
|
2013-09-27 17:24:07 +00:00
|
|
|
def __init__(self, namespace, name):
|
|
|
|
admin_need = _RepositoryNeed(namespace, name, 'admin')
|
2014-03-19 18:36:56 +00:00
|
|
|
org_admin_need = _OrganizationRepoNeed(namespace, 'admin')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = namespace
|
|
|
|
self.repo_name = name
|
|
|
|
|
2013-11-04 20:42:08 +00:00
|
|
|
super(AdministerRepositoryPermission, self).__init__(admin_need,
|
|
|
|
org_admin_need)
|
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class CreateRepositoryPermission(QuayPermission):
|
2013-11-04 20:42:08 +00:00
|
|
|
def __init__(self, namespace):
|
|
|
|
admin_org = _OrganizationNeed(namespace, 'admin')
|
|
|
|
create_repo_org = _OrganizationNeed(namespace, 'creator')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = namespace
|
|
|
|
|
2013-11-04 20:42:08 +00:00
|
|
|
super(CreateRepositoryPermission, self).__init__(admin_org,
|
|
|
|
create_repo_org)
|
2013-09-27 17:24:07 +00:00
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class SuperUserPermission(QuayPermission):
|
2014-04-10 04:26:55 +00:00
|
|
|
def __init__(self):
|
|
|
|
need = _SuperUserNeed()
|
|
|
|
super(SuperUserPermission, self).__init__(need)
|
|
|
|
|
2013-09-27 17:24:07 +00:00
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class UserAdminPermission(QuayPermission):
|
2014-03-18 23:21:27 +00:00
|
|
|
def __init__(self, username):
|
|
|
|
user_admin = _UserNeed(username, 'admin')
|
|
|
|
super(UserAdminPermission, self).__init__(user_admin)
|
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class UserReadPermission(QuayPermission):
|
2013-09-20 22:38:17 +00:00
|
|
|
def __init__(self, username):
|
2014-03-18 23:21:27 +00:00
|
|
|
user_admin = _UserNeed(username, 'admin')
|
|
|
|
user_read = _UserNeed(username, 'read')
|
|
|
|
super(UserReadPermission, self).__init__(user_read, user_admin)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class AdministerOrganizationPermission(QuayPermission):
|
2013-11-04 21:18:40 +00:00
|
|
|
def __init__(self, org_name):
|
|
|
|
admin_org = _OrganizationNeed(org_name, 'admin')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = org_name
|
|
|
|
|
2013-11-04 21:18:40 +00:00
|
|
|
super(AdministerOrganizationPermission, self).__init__(admin_org)
|
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class OrganizationMemberPermission(QuayPermission):
|
2013-11-04 21:18:40 +00:00
|
|
|
def __init__(self, org_name):
|
|
|
|
admin_org = _OrganizationNeed(org_name, 'admin')
|
|
|
|
repo_creator_org = _OrganizationNeed(org_name, 'creator')
|
|
|
|
org_member = _OrganizationNeed(org_name, 'member')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = org_name
|
|
|
|
|
2013-11-04 21:18:40 +00:00
|
|
|
super(OrganizationMemberPermission, self).__init__(admin_org, org_member,
|
|
|
|
repo_creator_org)
|
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class ViewTeamPermission(QuayPermission):
|
2013-11-04 21:18:40 +00:00
|
|
|
def __init__(self, org_name, team_name):
|
|
|
|
team_admin = _TeamNeed(org_name, team_name, 'admin')
|
2013-11-04 21:39:52 +00:00
|
|
|
team_creator = _TeamNeed(org_name, team_name, 'creator')
|
|
|
|
team_member = _TeamNeed(org_name, team_name, 'member')
|
2014-11-11 22:22:37 +00:00
|
|
|
admin_org = _OrganizationNeed(org_name, 'admin')
|
2016-03-16 20:08:53 +00:00
|
|
|
|
|
|
|
self.namespace = org_name
|
|
|
|
|
2013-11-04 21:18:40 +00:00
|
|
|
super(ViewTeamPermission, self).__init__(team_admin, team_creator,
|
2013-11-04 21:44:38 +00:00
|
|
|
team_member, admin_org)
|
2013-11-04 21:18:40 +00:00
|
|
|
|
|
|
|
|
2016-03-25 21:47:37 +00:00
|
|
|
class AlwaysFailPermission(QuayPermission):
|
2015-02-19 21:58:13 +00:00
|
|
|
def can(self):
|
|
|
|
return False
|
2015-02-19 21:54:23 +00:00
|
|
|
|
|
|
|
|
2013-09-20 22:38:17 +00:00
|
|
|
@identity_loaded.connect_via(app)
|
|
|
|
def on_identity_loaded(sender, identity):
|
2013-09-25 20:46:28 +00:00
|
|
|
logger.debug('Identity loaded: %s' % identity)
|
2013-09-20 22:38:17 +00:00
|
|
|
# We have verified an identity, load in all of the permissions
|
|
|
|
|
2013-10-15 18:48:49 +00:00
|
|
|
if isinstance(identity, QuayDeferredPermissionUser):
|
2014-11-20 23:44:36 +00:00
|
|
|
logger.debug('Deferring permissions for user with uuid: %s', identity.id)
|
2013-09-26 20:32:09 +00:00
|
|
|
|
2014-11-20 23:44:36 +00:00
|
|
|
elif identity.auth_type == 'user_uuid':
|
|
|
|
logger.debug('Switching username permission to deferred object with uuid: %s', identity.id)
|
2015-05-07 19:04:12 +00:00
|
|
|
switch_to_deferred = QuayDeferredPermissionUser.for_id(identity.id)
|
2013-10-15 18:48:49 +00:00
|
|
|
identity_changed.send(app, identity=switch_to_deferred)
|
2013-09-20 22:38:17 +00:00
|
|
|
|
2013-09-26 20:32:09 +00:00
|
|
|
elif identity.auth_type == 'token':
|
2014-03-17 16:01:13 +00:00
|
|
|
logger.debug('Loading permissions for token: %s', identity.id)
|
2015-07-15 21:25:41 +00:00
|
|
|
token_data = model.token.load_token_data(identity.id)
|
2013-10-16 18:24:10 +00:00
|
|
|
|
2014-09-24 22:01:35 +00:00
|
|
|
repo_grant = _RepositoryNeed(token_data.repository.namespace_user.username,
|
2013-10-16 18:24:10 +00:00
|
|
|
token_data.repository.name,
|
|
|
|
token_data.role.name)
|
2015-06-22 21:40:04 +00:00
|
|
|
logger.debug('Delegate token added permission: %s', repo_grant)
|
2013-10-16 18:24:10 +00:00
|
|
|
identity.provides.add(repo_grant)
|
2013-09-26 20:32:09 +00:00
|
|
|
|
2015-07-06 19:00:07 +00:00
|
|
|
elif identity.auth_type == 'signed_grant' or identity.auth_type == 'signed_jwt':
|
|
|
|
logger.debug('Loaded %s identity for: %s', identity.auth_type, identity.id)
|
2015-02-19 21:54:23 +00:00
|
|
|
|
2013-09-26 20:32:09 +00:00
|
|
|
else:
|
2014-03-17 16:01:13 +00:00
|
|
|
logger.error('Unknown identity auth type: %s', identity.auth_type)
|