Have the auth realm url computed based on the request url.

This commit is contained in:
Jake Moshenko 2015-07-16 17:05:18 -04:00
parent bc29561f8f
commit f2508fb48a

View file

@ -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