Skip to content

Commit

Permalink
Merge pull request #99 from yjinjo/master
Browse files Browse the repository at this point in the history
Add http host for saml
  • Loading branch information
yjinjo authored Jun 10, 2024
2 parents 6c139c2 + 6597673 commit 96ba5eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cloudforet/console_api_v2/conf/global_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@

# SAML Settings
CONSOLE_DOMAIN = ""
CONSOLE_API_V2_ENDPOINT = ""
13 changes: 9 additions & 4 deletions src/cloudforet/console_api_v2/service/auth_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96ba5eb

Please sign in to comment.