Make images belong to one repository only. Add a description field to the repository. Fix a bug with access tokens. Fix an embarrasing bug with multiple select criteria in peewee. Update the test db.
This commit is contained in:
parent
5caa54ffb3
commit
23cbcb2979
6 changed files with 79 additions and 67 deletions
19
auth/auth.py
19
auth/auth.py
|
@ -27,7 +27,7 @@ def process_basic_auth():
|
|||
normalized = [part.strip() for part in auth.split(' ') if part]
|
||||
if normalized[0].lower() != 'basic' or len(normalized) != 2:
|
||||
logger.debug('Invalid basic auth format.')
|
||||
return False
|
||||
return
|
||||
|
||||
credentials = b64decode(normalized[1]).split(':')
|
||||
|
||||
|
@ -43,10 +43,11 @@ def process_basic_auth():
|
|||
|
||||
identity_changed.send(app, identity=Identity(authenticated.username))
|
||||
|
||||
return True
|
||||
return
|
||||
|
||||
# We weren't able to authenticate via basic auth.
|
||||
return False
|
||||
logger.debug('Basic auth present but could not be validated.')
|
||||
abort(401)
|
||||
|
||||
|
||||
def process_token():
|
||||
|
@ -56,19 +57,19 @@ def process_token():
|
|||
normalized = [part.strip() for part in auth.split(' ') if part]
|
||||
if normalized[0].lower() != 'token' or len(normalized) != 2:
|
||||
logger.debug('Invalid token format.')
|
||||
return False
|
||||
return
|
||||
|
||||
token_details = normalized[1].split(',')
|
||||
|
||||
if len(token_details) != 2:
|
||||
logger.debug('Invalid token format.')
|
||||
return False
|
||||
return
|
||||
|
||||
token_vals = {val[0]: val[1] for val in
|
||||
(detail.split('=') for detail in token_details)}
|
||||
if ('signature' not in token_vals or 'repository' not in token_vals):
|
||||
logger.debug('Invalid token components.')
|
||||
return False
|
||||
return
|
||||
|
||||
unquoted = token_vals['repository'][1:-1]
|
||||
namespace, repository = parse_namespace_repository(unquoted)
|
||||
|
@ -86,11 +87,11 @@ def process_token():
|
|||
|
||||
identity_changed.send(app, identity=Identity(validated.code))
|
||||
|
||||
return True
|
||||
return
|
||||
|
||||
# WE weren't able to authenticate the token
|
||||
logger.debug('Token could not be validated.')
|
||||
return False
|
||||
logger.debug('Token present but could not be validated.')
|
||||
abort(401)
|
||||
|
||||
|
||||
def process_auth(f):
|
||||
|
|
Reference in a new issue