Skip to content
This repository was archived by the owner on Sep 12, 2018. It is now read-only.

Commit d596aa6

Browse files
committed
Merge pull request #344 from shin-/master
Private layers fix
2 parents 0e19438 + e52cc60 commit d596aa6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docker_registry/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def put_image_json(image_id):
403403
parent_id = data.get('parent')
404404
if parent_id and not store.exists(store.image_json_path(data['parent'])):
405405
return toolkit.api_error('Image depends on a non existing parent')
406-
elif not toolkit.validate_parent_access(parent_id):
406+
elif parent_id and not toolkit.validate_parent_access(parent_id):
407407
return toolkit.api_error('Image depends on an unauthorized parent')
408408
json_path = store.image_json_path(image_id)
409409
mark_path = store.image_mark_path(image_id)

docker_registry/toolkit.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,27 @@ def validate_parent_access(parent_id):
101101
return False
102102
full_repos_name = auth.get('repository', '').split('/')
103103
if len(full_repos_name) != 2:
104-
logger.debug('validate_token: Invalid repository field')
104+
logger.debug('validate_parent: Invalid repository field')
105105
return False
106106
index_endpoint = cfg.index_endpoint
107107
if index_endpoint is None:
108108
index_endpoint = 'https://index.docker.io'
109109
index_endpoint = index_endpoint.strip('/')
110-
url = '{0}/v1/images/{1}/{2}/layer/{3}/access'.format(
110+
url = '{0}/v1/repositories/{1}/{2}/layer/{3}/access'.format(
111111
index_endpoint, full_repos_name[0], full_repos_name[1], parent_id
112112
)
113113
headers = {'Authorization': flask.request.headers.get('authorization')}
114114
resp = requests.get(url, verify=True, headers=headers)
115115
if resp.status_code != 200:
116-
logger.debug('validate_parent_access: index returns status {0}'.format(
116+
logger.debug('validate_parent: index returns status {0}'.format(
117117
resp.status_code
118118
))
119119
return False
120120
try:
121+
logger.debug('validate_parent: Content: {0}'.format(resp.text))
121122
return json.loads(resp.text).get('access', False)
122-
123123
except json.JSONDecodeError:
124-
logger.debug('validate_parent_access: Wrong response format')
124+
logger.debug('validate_parent: Wrong response format')
125125
return False
126126

127127

0 commit comments

Comments
 (0)