diff --git a/endpoints/v2/__init__.py b/endpoints/v2/__init__.py index c88252b94..0de3dc539 100644 --- a/endpoints/v2/__init__.py +++ b/endpoints/v2/__init__.py @@ -3,8 +3,9 @@ import logging -from flask import Blueprint, make_response +from flask import Blueprint, make_response, url_for, request from functools import wraps +from urlparse import urlparse from endpoints.decorators import anon_protect, anon_allowed from auth.jwt_auth import process_jwt_auth @@ -54,7 +55,10 @@ def v2_support_enabled(): if get_grant_user_context() is None: response = make_response('true', 401) - response.headers['WWW-Authenticate'] = 'Bearer realm="192.168.59.3:5000/v2/auth",service="quay"' + realm_hostname = urlparse(request.url).netloc + realm_auth_path = url_for('v2.generate_registry_jwt') + authenticate = 'Bearer realm="{0}{1}",service="quay"'.format(realm_hostname, realm_auth_path) + response.headers['WWW-Authenticate'] = authenticate response.headers['Docker-Distribution-API-Version'] = 'registry/2.0' return response