From d8b0c0ea155d8dfa457aec5226ffc547227d9349 Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 16 Dec 2024 10:36:26 +0100 Subject: [PATCH 1/2] Changed Location headers --- .../core/apiinvokerenrolmentdetails.py | 4 ++-- .../core/provider_enrolment_details_api.py | 4 ++-- .../capif_events/core/events_apis.py | 2 +- .../api_invocation_logs/core/invocationlogs.py | 3 +-- .../published_apis/core/serviceapidescriptions.py | 4 ++-- .../capif_security/core/servicesecurity.py | 7 +++---- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py index 038b97c..af08e7e 100644 --- a/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py +++ b/services/TS29222_CAPIF_API_Invoker_Management_API/api_invoker_management/core/apiinvokerenrolmentdetails.py @@ -14,6 +14,7 @@ from api_invoker_management.models.api_invoker_enrolment_details import APIInvok from .redis_event import RedisEvent from .redis_internal_event import RedisInternalEvent from .publisher import Publisher +import os publisher_ops = Publisher() @@ -101,8 +102,7 @@ class InvokerManagementOperations(Resource): res = make_response(object=serialize_clean_camel_case( apiinvokerenrolmentdetail), status=201) - res.headers['Location'] = "/api-invoker-management/v1/onboardedInvokers/" + \ - str(api_invoker_id) + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/api-invoker-management/v1/onboardedInvokers/{str(api_invoker_id)}" if res.status_code == 201: current_app.logger.info("Invoker Created") diff --git a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py index de8b08f..459361c 100644 --- a/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py +++ b/services/TS29222_CAPIF_API_Provider_Management_API/api_provider_management/core/provider_enrolment_details_api.py @@ -11,6 +11,7 @@ from .auth_manager import AuthManager from api_provider_management.models.api_provider_enrolment_details import APIProviderEnrolmentDetails # noqa: E501 from .redis_internal_event import RedisInternalEvent +import os class ProviderManagementOperations(Resource): @@ -73,8 +74,7 @@ class ProviderManagementOperations(Resource): res = make_response(object=serialize_clean_camel_case( api_provider_enrolment_details), status=201) - res.headers['Location'] = "/api-provider-management/v1/registrations/" + \ - str(api_provider_enrolment_details.api_prov_dom_id) + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/api-provider-management/v1/registrations/{str(api_provider_enrolment_details.api_prov_dom_id)}" return res except Exception as e: diff --git a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py index f0226d0..3555281 100644 --- a/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py +++ b/services/TS29222_CAPIF_Events_API/capif_events/core/events_apis.py @@ -83,7 +83,7 @@ class EventSubscriptionsOperations(Resource): self.auth_manager.add_auth_event(subscription_id, subscriber_id) res = make_response(object=serialize_clean_camel_case(event_subscription), status=201) - res.headers['Location'] = f"http://{os.getenv("CAPIF_HOSTNAME")}/capif-events/v1/{str(subscriber_id)}/subscriptions/{str(subscription_id)}" + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/capif-events/v1/{str(subscriber_id)}/subscriptions/{str(subscription_id)}" return res diff --git a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py index 345076c..92f7c27 100644 --- a/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py +++ b/services/TS29222_CAPIF_Logging_API_Invocation_API/api_invocation_logs/core/invocationlogs.py @@ -136,9 +136,8 @@ class LoggingInvocationOperations(Resource): log.api_id: log.api_name for log in invocationlog.logs} current_app.logger.debug(f"Added log entry to apis: {apis_added}") + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/api-invocation-logs/v1/{str(aef_id)}/logs/{str(log_id)}" - res.headers['Location'] = "https://{}/api-invocation-logs/v1/{}/logs/{}".format( - os.getenv('CAPIF_HOSTNAME'), str(aef_id), str(log_id)) return res except Exception as e: diff --git a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py index 83d5f7b..fd2d196 100644 --- a/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py +++ b/services/TS29222_CAPIF_Publish_Service_API/published_apis/core/serviceapidescriptions.py @@ -13,6 +13,7 @@ from ..models.service_api_description import ServiceAPIDescription import json from ..encoder import CustomJSONEncoder from ..vendor_specific import add_vend_spec_fields +import os publisher_ops = Publisher() @@ -127,8 +128,7 @@ class PublishServiceOperations(Resource): res = make_response(object=clean_n_camel_case( serviceapidescription_dict), status=201) - res.headers['Location'] = "http://localhost:8080/published-apis/v1/" + \ - str(apf_id) + "/service-apis/" + str(api_id) + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/published-apis/v1/{str(apf_id)}/service-apis/{str(api_id)}" if res.status_code == 201: current_app.logger.info("Service published") diff --git a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py index e4ecc12..e030457 100644 --- a/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py +++ b/services/TS29222_CAPIF_Security_API/capif_security/core/servicesecurity.py @@ -197,8 +197,7 @@ class SecurityOperations(Resource): mycol.insert_one(rec) res = make_response(object=serialize_clean_camel_case(service_security), status=201) - res.headers['Location'] = "https://{}/capif-security/v1/trustedInvokers/{}".format( - os.getenv('CAPIF_HOSTNAME'), str(api_invoker_id)) + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/capif-security/v1/trustedInvokers/{str(api_invoker_id)}" return res @@ -356,8 +355,8 @@ class SecurityOperations(Resource): current_app.logger.debug("Updated security context") res= make_response(object=dict_to_camel_case(clean_empty(result)), status=200) - res.headers['Location'] = "https://{}/capif-security/v1/trustedInvokers/{}".format( - os.getenv('CAPIF_HOSTNAME'), str(api_invoker_id)) + res.headers['Location'] = f"https://{os.getenv("CAPIF_HOSTNAME")}/capif-security/v1/trustedInvokers/{str(api_invoker_id)}" + return res except Exception as e: exception = "An exception occurred in update security info" -- GitLab From b686ecb2d9a9119f16619eb7ce8c350f27a582ee Mon Sep 17 00:00:00 2001 From: Pelayo Torres Date: Mon, 16 Dec 2024 16:53:33 +0100 Subject: [PATCH 2/2] fix CAPIF HOSTNAME Variable --- services/docker-compose-capif.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/docker-compose-capif.yml b/services/docker-compose-capif.yml index 8aa7d02..45de9c3 100644 --- a/services/docker-compose-capif.yml +++ b/services/docker-compose-capif.yml @@ -48,6 +48,7 @@ services: - fluent-bit:host-gateway - otel-collector:host-gateway environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=access-control-policy - MONITORING=${MONITORING} - LOG_LEVEL=${LOG_LEVEL} @@ -70,6 +71,7 @@ services: - otel-collector:host-gateway - vault:host-gateway environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=api-invoker-management - MONITORING=${MONITORING} - VAULT_HOSTNAME=vault @@ -96,6 +98,7 @@ services: - vault:host-gateway image: labs.etsi.org:5050/ocf/capif/api-provider-management-api:v2.x.x-release environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=api-provider-management - MONITORING=${MONITORING} - VAULT_HOSTNAME=vault @@ -120,6 +123,7 @@ services: restart: unless-stopped image: labs.etsi.org:5050/ocf/capif/auditing-api:v2.x.x-release environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=api-auditing - MONITORING=${MONITORING} - LOG_LEVEL=${LOG_LEVEL} @@ -140,6 +144,7 @@ services: - otel-collector:host-gateway image: labs.etsi.org:5050/ocf/capif/discover-service-api:v2.x.x-release environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=services-apis - MONITORING=${MONITORING} - LOG_LEVEL=${LOG_LEVEL} @@ -155,6 +160,7 @@ services: - ./TS29222_CAPIF_Events_API:/usr/src/app image: labs.etsi.org:5050/ocf/capif/events-api:v2.x.x-release environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=api-events - MONITORING=${MONITORING} - LOG_LEVEL=${LOG_LEVEL} @@ -201,6 +207,7 @@ services: - fluent-bit:host-gateway - otel-collector:host-gateway environment: + - CAPIF_HOSTNAME=${CAPIF_HOSTNAME} - CONTAINER_NAME=api-publish-apis - MONITORING=${MONITORING} - LOG_LEVEL=${LOG_LEVEL} -- GitLab