diff --git a/auth/auth.py b/auth/auth.py index b21800896..f2b512121 100644 --- a/auth/auth.py +++ b/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 diff --git a/endpoints/api/robot.py b/endpoints/api/robot.py index 6bcc34027..67737a9f2 100644 --- a/endpoints/api/robot.py +++ b/endpoints/api/robot.py @@ -35,10 +35,8 @@ class UserRobot(ApiResource): """ Create a new user robot with the specified name. """ parent = get_authenticated_user() robot, password = model.create_robot(robot_shortname, parent) - resp = robot_view(robot.username, password) log_action('create_robot', parent.username, {'robot': robot_shortname}) - resp.status_code = 201 - return resp + return robot_view(robot.username, password), 201 @nickname('deleteUserRobot') def delete(self, robot_shortname): diff --git a/endpoints/api/user.py b/endpoints/api/user.py index 1d5ccf13e..b1d9a5800 100644 --- a/endpoints/api/user.py +++ b/endpoints/api/user.py @@ -226,22 +226,22 @@ class ConvertToOrganization(ApiResource): 'type': 'object', 'description': 'Information required to convert a user to an organization.', 'required': [ - 'username', - 'password', - 'email', + 'adminUser', + 'adminPassword', + 'plan', ], 'properties': { - 'username': { + 'adminUser': { 'type': 'string', - 'description': 'The user\'s username', + 'description': 'The user who will become an org admin\'s username', }, - 'password': { + 'adminPassword': { 'type': 'string', - 'description': 'The user\'s password', + 'description': 'The user who will become an org admin\'s password', }, - 'email': { + 'plan': { 'type': 'string', - 'description': 'The user\'s email address', + 'description': 'The plan to which the organizatino should be subscribed', }, }, },