Fix login with robot to quay-appr

This commit is contained in:
Antoine Legrand 2017-04-13 14:25:47 +02:00
parent f5ab03070c
commit 578f87f94c
6 changed files with 63 additions and 52 deletions

View file

@ -8,10 +8,10 @@ from cnr.exception import raise_package_not_found, raise_channel_not_found
from six import add_metaclass
from app import storage
from app import storage, authentication
from data import model, oci_model
from data.database import Tag, Manifest, MediaType, Blob, Repository, Channel
from util.names import parse_robot_username
class BlobDescriptor(namedtuple('Blob', ['mediaType', 'size', 'digest', 'urls'])):
""" BlobDescriptor describes a blob with its mediatype, size and digest.
@ -427,6 +427,16 @@ class OCIAppModel(AppRegistryDataInterface):
return ChannelView(current=channel.linked_tag.name,
name=channel.name)
def get_user(self, username, password):
err_msg = None
if parse_robot_username(username) is not None:
try:
user = model.user.verify_robot(username, password)
except model.InvalidRobotException as exc:
return (None, exc.message)
else:
user, err_msg = authentication.verify_and_link_user(username, password)
return (user, err_msg)
def _strip_sha256_header(digest):
if digest.startswith('sha256:'):