v2: send proper scopes for authorization failures

Fixes #1278.
This commit is contained in:
Jimmy Zelinskie 2016-03-09 18:09:20 -05:00
parent bb46cc933d
commit ea2e17cc11
9 changed files with 91 additions and 71 deletions

View file

@ -1,7 +1,10 @@
class V2RegistryException(Exception):
def __init__(self, error_code_str, message, detail, http_status_code=400):
def __init__(self, error_code_str, message, detail, http_status_code=400,
repository=None, scopes=None):
super(V2RegistryException, self).__init__(message)
self.http_status_code = http_status_code
self.repository = repository
self.scopes = scopes
self._error_code_str = error_code_str
self._detail = detail
@ -104,11 +107,13 @@ class TagInvalid(V2RegistryException):
class Unauthorized(V2RegistryException):
def __init__(self, detail=None):
def __init__(self, detail=None, repository=None, scopes=None):
super(Unauthorized, self).__init__('UNAUTHORIZED',
'access to the requested resource is not authorized',
detail,
401)
401,
repository=repository,
scopes=scopes)
class Unsupported(V2RegistryException):