From 6597673cd88e0407cc5b3a7a73e0ea5a806e441b Mon Sep 17 00:00:00 2001 From: Youngjin Jo Date: Mon, 10 Jun 2024 21:56:13 +0900 Subject: [PATCH] feat: add http host for saml Signed-off-by: Youngjin Jo --- src/cloudforet/console_api_v2/conf/global_conf.py | 1 + .../console_api_v2/service/auth_service.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cloudforet/console_api_v2/conf/global_conf.py b/src/cloudforet/console_api_v2/conf/global_conf.py index 9e29bbe..fe066df 100644 --- a/src/cloudforet/console_api_v2/conf/global_conf.py +++ b/src/cloudforet/console_api_v2/conf/global_conf.py @@ -91,3 +91,4 @@ # SAML Settings CONSOLE_DOMAIN = "" +CONSOLE_API_V2_ENDPOINT = "" diff --git a/src/cloudforet/console_api_v2/service/auth_service.py b/src/cloudforet/console_api_v2/service/auth_service.py index dfb9b08..f45a67a 100644 --- a/src/cloudforet/console_api_v2/service/auth_service.py +++ b/src/cloudforet/console_api_v2/service/auth_service.py @@ -58,7 +58,10 @@ def saml(self, params: dict) -> RedirectResponse: form_data = params.get("form_data") domain_id = params.get("domain_id") - credentials = self._extract_credentials(request, dict(form_data)) + console_api_v2_endpoint = config.get_global("CONSOLE_API_V2_ENDPOINT") + credentials = self._extract_credentials( + request, console_api_v2_endpoint, dict(form_data) + ) refresh_token = self._issue_token(credentials, domain_id) domain_name = self._get_domain_name(domain_id) return self._redirect_response(domain_name, refresh_token) @@ -121,12 +124,14 @@ def _check_app(client_id: str, domain_id: str): ) @staticmethod - def _extract_credentials(request: Request, form_data: dict) -> dict: + def _extract_credentials( + request: Request, console_api_v2_endpoint: str, form_data: dict + ) -> dict: return { - "http_host": request.client.host, - "server_port": str(request.url.port), + "http_host": console_api_v2_endpoint, "script_name": request.url.path, "post_data": form_data, + "https": "on", } @staticmethod