diff --git a/CHANGES/1181.misc b/CHANGES/1181.feature similarity index 100% rename from CHANGES/1181.misc rename to CHANGES/1181.feature diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 409f0571ff..74a3bff0fd 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -107,7 +107,10 @@ run_service() { process_init_files /entrypoints.d/* - setup_signing_service + # run setup signing service only if DEV_SOURCE_PATH is set + if [[ -n "$DEV_SOURCE_PATH" ]]; then + setup_signing_service + fi exec "${service_path}" "$@" } @@ -118,7 +121,11 @@ run_manage() { install_local_deps fi - setup_signing_service + # run setup signing service only if DEV_SOURCE_PATH is set + if [[ -n "$DEV_SOURCE_PATH" ]]; then + setup_signing_service + fi + exec django-admin "$@" } diff --git a/galaxy_ng/app/api/ui/serializers/collection.py b/galaxy_ng/app/api/ui/serializers/collection.py index d47c83e7e5..4b5d4b35b1 100644 --- a/galaxy_ng/app/api/ui/serializers/collection.py +++ b/galaxy_ng/app/api/ui/serializers/collection.py @@ -59,10 +59,17 @@ class CollectionMetadataSerializer(Serializer): tags = serializers.SerializerMethodField() signatures = serializers.SerializerMethodField() - @extend_schema_field(serializers.ListField(child=serializers.CharField())) + @extend_schema_field(serializers.ListField(child=serializers.DictField())) def get_signatures(self, obj): """Returns signature pubkey_fingerprint for each signature.""" - return obj.signatures.values_list("pubkey_fingerprint", flat=True) + data = [] + for signature in obj.signatures.all(): + sig = {} + sig["signature"] = bytes(signature.data).decode("utf-8") + sig["pubkey_fingerprint"] = signature.pubkey_fingerprint + sig["signing_service"] = signature.signing_service.name + data.append(sig) + return data @extend_schema_field(serializers.ListField) def get_tags(self, collection_version): @@ -73,7 +80,18 @@ def get_tags(self, collection_version): return [tag.name for tag in collection_version.tags.all()] -class CollectionVersionBaseSerializer(Serializer): +class CollectionVersionSignStateMixin: + + @extend_schema_field(serializers.CharField()) + def get_version_sign_state(self, obj): + """Returns the state of the signature.""" + if obj.signatures.count() == 0: + return "unsigned" + else: + return "signed" + + +class CollectionVersionBaseSerializer(CollectionVersionSignStateMixin, Serializer): namespace = serializers.CharField() name = serializers.CharField() version = serializers.CharField() @@ -81,6 +99,7 @@ class CollectionVersionBaseSerializer(Serializer): created_at = serializers.DateTimeField(source='pulp_created') metadata = CollectionMetadataSerializer(source='*') contents = serializers.ListField(child=ContentSerializer()) + version_sign_state = serializers.SerializerMethodField() class CollectionVersionSerializer(CollectionVersionBaseSerializer): @@ -107,9 +126,10 @@ class CollectionVersionDetailSerializer(CollectionVersionBaseSerializer): docs_blob = serializers.JSONField() -class CollectionVersionSummarySerializer(Serializer): +class CollectionVersionSummarySerializer(CollectionVersionSignStateMixin, Serializer): version = serializers.CharField() created = serializers.CharField(source='pulp_created') + version_sign_state = serializers.SerializerMethodField() class _CollectionSerializer(Serializer): @@ -143,6 +163,10 @@ def get_latest_version(self, obj): class CollectionDetailSerializer(_CollectionSerializer): all_versions = serializers.SerializerMethodField() + sign_state = serializers.CharField() + total_versions = serializers.IntegerField(default=0) + signed_versions = serializers.IntegerField(default=0) + unsigned_versions = serializers.IntegerField(default=0) # TODO: rename field to "version_details" since with # "version" query param this won't always be the latest version diff --git a/galaxy_ng/app/dynaconf_hooks.py b/galaxy_ng/app/dynaconf_hooks.py index d3f89fd1d2..bce8213e33 100644 --- a/galaxy_ng/app/dynaconf_hooks.py +++ b/galaxy_ng/app/dynaconf_hooks.py @@ -19,6 +19,7 @@ def post(settings: Dynaconf) -> Dict[str, Any]: data.update(configure_logging(settings)) data.update(configure_keycloak(settings)) data.update(configure_cors(settings)) + data.update(configure_feature_flags(settings)) return data @@ -268,3 +269,13 @@ def configure_cors(settings: Dynaconf) -> Dict[str, Any]: corsmiddleware = ["galaxy_ng.app.common.openapi.AllowCorsMiddleware"] data["MIDDLEWARE"] = corsmiddleware + settings.get("MIDDLEWARE", []) return data + + +def configure_feature_flags(settings: Dynaconf) -> Dict[str, Any]: + """Adds conditional feature flags""" + data = {} + data["GALAXY_FEATURE_FLAGS__collection_signing"] = settings.get( + "GALAXY_COLLECTION_SIGNING_SERVICE") is not None + data["GALAXY_FEATURE_FLAGS__collection_auto_sign"] = settings.get( + "GALAXY_AUTO_SIGN_COLLECTIONS") is True + return data