Fix login with robot to quay-appr
This commit is contained in:
parent
f5ab03070c
commit
578f87f94c
6 changed files with 63 additions and 52 deletions
|
@ -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:'):
|
||||
|
|
Reference in a new issue