Fix quoting of scopes in WWW-Authenticate header

Fixes part of #2002
This commit is contained in:
Joseph Schorr 2016-10-17 14:32:43 -04:00
parent 18097a1bd6
commit 3439f814b6
2 changed files with 14 additions and 3 deletions

View file

@ -127,9 +127,11 @@ def get_auth_headers(repository=None, scopes=None):
realm_auth_path,
app.config['SERVER_HOSTNAME'])
if repository:
authenticate += ',scope=repository:{0}'.format(repository)
scopes_string = "repository:{0}".format(repository)
if scopes:
authenticate += ':' + ','.join(scopes)
scopes_string += ':' + ','.join(scopes)
authenticate += ',scope="{0}"'.format(scopes_string)
headers['WWW-Authenticate'] = authenticate
headers['Docker-Distribution-API-Version'] = 'registry/2.0'