Merge pull request #1255 from jzelinskie/wwwauth
v2: always send www-authn headers on unauthorized
This commit is contained in:
commit
01b9606481
2 changed files with 7 additions and 1 deletions
|
@ -30,7 +30,10 @@ def handle_registry_v2_exception(error):
|
||||||
response = jsonify({
|
response = jsonify({
|
||||||
'errors': [error.as_dict()]
|
'errors': [error.as_dict()]
|
||||||
})
|
})
|
||||||
|
|
||||||
response.status_code = error.http_status_code
|
response.status_code = error.http_status_code
|
||||||
|
if response.status_code == 401:
|
||||||
|
response.headers.extend(get_auth_headers())
|
||||||
logger.debug('sending response: %s', response.get_data())
|
logger.debug('sending response: %s', response.get_data())
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
|
@ -1319,7 +1319,10 @@ class V2RegistryTests(V2RegistryPullMixin, V2RegistryPushMixin, RegistryTestsMix
|
||||||
self.assertEquals(len(data['tags']), 1)
|
self.assertEquals(len(data['tags']), 1)
|
||||||
|
|
||||||
# Try to get tags before a repo exists.
|
# Try to get tags before a repo exists.
|
||||||
self.conduct('GET', '/v2/devtable/doesnotexist/tags/list', auth='jwt', expected_code=401)
|
response = self.conduct('GET', '/v2/devtable/doesnotexist/tags/list', auth='jwt', expected_code=401)
|
||||||
|
|
||||||
|
# Assert 401s to non-auth endpoints also get the WWW-Authenticate header.
|
||||||
|
self.assertIn('WWW-Authenticate', response.headers)
|
||||||
|
|
||||||
def test_one_five_blacklist(self):
|
def test_one_five_blacklist(self):
|
||||||
self.conduct('GET', '/v2/', expected_code=404, user_agent='Go 1.1 package http')
|
self.conduct('GET', '/v2/', expected_code=404, user_agent='Go 1.1 package http')
|
||||||
|
|
Reference in a new issue