From 2e0edf8f6eb359aef0fdfafe5f0adcf571682147 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 5 Jun 2018 17:31:00 -0400 Subject: [PATCH] Have catalog endpoint return empty if the namespace is disabled --- endpoints/v2/catalog.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/endpoints/v2/catalog.py b/endpoints/v2/catalog.py index 5d29cfffc..c36a6ecee 100644 --- a/endpoints/v2/catalog.py +++ b/endpoints/v2/catalog.py @@ -1,6 +1,6 @@ import features -from flask import jsonify +from flask import jsonify, abort from auth.auth_context import get_authenticated_user from auth.registry_jwt_auth import process_registry_jwt_auth @@ -14,8 +14,14 @@ from endpoints.v2.models_pre_oci import data_model as model @anon_protect @paginate() def catalog_search(limit, offset, pagination_callback): - username = get_authenticated_user().username if get_authenticated_user() else None include_public = bool(features.PUBLIC_CATALOG) + if not include_public and not get_authenticated_user(): + return jsonify({'repositories': []}) + + username = get_authenticated_user().username if get_authenticated_user() else None + if username and not get_authenticated_user().enabled: + return jsonify({'repositories': []}) + visible_repositories = model.get_visible_repositories(username, limit + 1, offset, include_public=include_public) response = jsonify({