Fix the formats for some errors.
This commit is contained in:
parent
3542a520f5
commit
1ae04658ef
1 changed files with 8 additions and 8 deletions
16
auth/auth.py
16
auth/auth.py
|
@ -84,13 +84,13 @@ def process_token(auth):
|
|||
|
||||
if len(token_details) != 1:
|
||||
logger.warning('Invalid token format: %s' % auth)
|
||||
abort(401, message="Invalid token format: %(auth)", issue='invalid-auth-token', auth=auth)
|
||||
abort(401, message='Invalid token format: %(auth)s', issue='invalid-auth-token', auth=auth)
|
||||
|
||||
token_vals = {val[0]: val[1] for val in
|
||||
(detail.split('=') for detail in token_details)}
|
||||
if 'signature' not in token_vals:
|
||||
logger.warning('Token does not contain signature: %s' % auth)
|
||||
abort(401, message="Token does not contain a valid signature: %(auth)",
|
||||
abort(401, message='Token does not contain a valid signature: %(auth)s',
|
||||
issue='invalid-auth-token', auth=auth)
|
||||
|
||||
try:
|
||||
|
@ -98,7 +98,7 @@ def process_token(auth):
|
|||
|
||||
except model.InvalidTokenException:
|
||||
logger.warning('Token could not be validated: %s', token_vals['signature'])
|
||||
abort(401, message="Token could not be validated: %(auth)", issue='invalid-auth-token',
|
||||
abort(401, message='Token could not be validated: %(auth)s', issue='invalid-auth-token',
|
||||
auth=auth)
|
||||
|
||||
logger.debug('Successfully validated token: %s', token_data.code)
|
||||
|
@ -125,7 +125,7 @@ def process_oauth(f):
|
|||
'WWW-Authenticate': ('Bearer error="invalid_token", '
|
||||
'error_description="The access token is invalid"'),
|
||||
}
|
||||
abort(401, message="OAuth access token could not be validated: %(token)",
|
||||
abort(401, message='OAuth access token could not be validated: %(token)s',
|
||||
issue='invalid-oauth-token', token=token, header=authenticate_header)
|
||||
elif validated.expires_at <= datetime.now():
|
||||
logger.info('OAuth access with an expired token: %s', token)
|
||||
|
@ -133,8 +133,8 @@ def process_oauth(f):
|
|||
'WWW-Authenticate': ('Bearer error="invalid_token", '
|
||||
'error_description="The access token expired"'),
|
||||
}
|
||||
abort(401, message="OAuth access token has expired: %(token)", issue='invalid-oauth-token',
|
||||
token=token, headers=authenticate_header)
|
||||
abort(401, message='OAuth access token has expired: %(token)s',
|
||||
issue='invalid-oauth-token', token=token, headers=authenticate_header)
|
||||
|
||||
# We have a valid token
|
||||
scope_set = scopes.scopes_from_scope_string(validated.scope)
|
||||
|
@ -151,7 +151,7 @@ def process_oauth(f):
|
|||
loaded = QuayDeferredPermissionUser(current_user.get_id(), 'username')
|
||||
identity_changed.send(app, identity=loaded)
|
||||
else:
|
||||
logger.debug('No auth header or user session.')
|
||||
logger.debug('No auth header or login cookie.')
|
||||
return f(*args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
|
@ -177,7 +177,7 @@ def extract_namespace_repo_from_session(f):
|
|||
def wrapper(*args, **kwargs):
|
||||
if 'namespace' not in session or 'repository' not in session:
|
||||
logger.error('Unable to load namespace or repository from session: %s' % session)
|
||||
abort(400, message="Missing namespace in request")
|
||||
abort(400, message='Missing namespace in request')
|
||||
|
||||
return f(session['namespace'], session['repository'], *args, **kwargs)
|
||||
return wrapper
|
||||
|
|
Reference in a new issue