Fix Docker Auth and our V2 registry paths to support library (i.e. namespace-less) repositories.
This support is placed behind a feature flag.
This commit is contained in:
parent
06b0f756bd
commit
e4ffaff869
37 changed files with 270 additions and 148 deletions
44
app.py
44
app.py
|
@ -50,15 +50,6 @@ DOCKER_V2_SIGNINGKEY_FILENAME = 'docker_v2.pem'
|
|||
app = Flask(__name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RegexConverter(BaseConverter):
|
||||
def __init__(self, url_map, *items):
|
||||
super(RegexConverter, self).__init__(url_map)
|
||||
self.regex = items[0]
|
||||
|
||||
|
||||
app.url_map.converters['regex'] = RegexConverter
|
||||
|
||||
# Instantiate the configuration.
|
||||
is_testing = 'TEST' in os.environ
|
||||
is_kubernetes = 'KUBERNETES_SERVICE_HOST' in os.environ
|
||||
|
@ -126,6 +117,41 @@ if app.config['SECRET_KEY'] is None:
|
|||
|
||||
features.import_features(app.config)
|
||||
|
||||
# Register custom converters.
|
||||
class RegexConverter(BaseConverter):
|
||||
""" Converter for handling custom regular expression patterns in paths. """
|
||||
def __init__(self, url_map, *items):
|
||||
super(RegexConverter, self).__init__(url_map)
|
||||
self.regex = items[0]
|
||||
|
||||
class RepositoryPathConverter(BaseConverter):
|
||||
""" Converter for handling repository paths. Handles both library and non-library paths (if
|
||||
configured).
|
||||
"""
|
||||
def __init__(self, url_map, *items):
|
||||
super(RepositoryPathConverter, self).__init__(url_map)
|
||||
self.weight = 200
|
||||
|
||||
if features.LIBRARY_SUPPORT:
|
||||
# Allow names without namespaces.
|
||||
self.regex = r'[^/]+(/[^/]+)?'
|
||||
else:
|
||||
self.regex = r'([^/]+/[^/]+)'
|
||||
|
||||
|
||||
class APIRepositoryPathConverter(BaseConverter):
|
||||
""" Converter for handling repository paths. Does not handle library paths.
|
||||
"""
|
||||
def __init__(self, url_map, *items):
|
||||
super(APIRepositoryPathConverter, self).__init__(url_map)
|
||||
self.weight = 200
|
||||
self.regex = r'([^/]+/[^/]+)'
|
||||
|
||||
|
||||
app.url_map.converters['regex'] = RegexConverter
|
||||
app.url_map.converters['repopath'] = RepositoryPathConverter
|
||||
app.url_map.converters['apirepopath'] = APIRepositoryPathConverter
|
||||
|
||||
Principal(app, use_sessions=False)
|
||||
|
||||
avatar = Avatar(app)
|
||||
|
|
Reference in a new issue