Skip to content

Commit ac27f11

Browse files
committed
refactor(IdP): log error response of SAML request
1 parent e3f673f commit ac27f11

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

redshift_connector/plugin/adfs_credentials_provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ def form_based_authentication(self: "AdfsCredentialsProvider") -> str:
3333
response: "requests.Response" = requests.get(url, verify=self.do_verify_ssl_cert())
3434
response.raise_for_status()
3535
except requests.exceptions.HTTPError as e:
36+
if "response" in vars():
37+
_logger.debug("form_based_authentication https response: {}".format(response.text)) # type: ignore
38+
else:
39+
_logger.debug("form_based_authentication could not receive https response due to an error")
3640
_logger.error("Request for SAML assertion when refreshing credentials was unsuccessful. {}".format(str(e)))
3741
raise InterfaceError(e)
3842
except requests.exceptions.Timeout as e:

redshift_connector/plugin/azure_credentials_provider.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ def azure_oauth_based_authentication(self: "AzureCredentialsProvider") -> str:
7474
)
7575
response.raise_for_status()
7676
except requests.exceptions.HTTPError as e:
77+
if "response" in vars():
78+
_logger.debug(
79+
"azure_oauth_based_authentication https response: {}".format(response.text) # type: ignore
80+
)
81+
else:
82+
_logger.debug("azure_oauth_based_authentication could not receive https response due to an error")
7783
_logger.error("Request for authentication from Azure was unsuccessful. {}".format(str(e)))
7884
raise InterfaceError(e)
7985
except requests.exceptions.Timeout as e:

redshift_connector/plugin/browser_azure_credentials_provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def fetch_saml_response(self: "BrowserAzureCredentialsProvider", token):
117117
response = requests.post(url, data=payload, headers=headers, verify=self.do_verify_ssl_cert())
118118
response.raise_for_status()
119119
except requests.exceptions.HTTPError as e:
120+
if "response" in vars():
121+
_logger.debug("fetch_saml_response https response: {}".format(response.text)) # type: ignore
122+
else:
123+
_logger.debug("fetch_saml_response could not receive https response due to an error")
120124
_logger.error("Request for authentication from Microsoft was unsuccessful. {}".format(str(e)))
121125
raise InterfaceError(e)
122126
except requests.exceptions.Timeout as e:

redshift_connector/plugin/okta_credentials_provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def okta_authentication(self: "OktaCredentialsProvider") -> str:
4444
)
4545
response.raise_for_status()
4646
except requests.exceptions.HTTPError as e:
47+
if "response" in vars():
48+
_logger.debug("okta_authentication https response: {}".format(response.text)) # type: ignore
49+
else:
50+
_logger.debug("okta_authentication could not receive https response due to an error")
4751
_logger.error("Request for authentication from Okta was unsuccessful. {}".format(str(e)))
4852
raise InterfaceError(e)
4953
except requests.exceptions.Timeout as e:

redshift_connector/plugin/ping_credentials_provider.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def get_saml_assertion(self: "PingCredentialsProvider") -> str:
3535
response: "requests.Response" = requests.get(url, verify=self.do_verify_ssl_cert())
3636
response.raise_for_status()
3737
except requests.exceptions.HTTPError as e:
38+
if "response" in vars():
39+
_logger.debug("get_saml_assertion https response: {}".format(response.text)) # type: ignore
40+
else:
41+
_logger.debug("get_saml_assertion could not receive https response due to an error")
3842
_logger.error("Request for SAML assertion when refreshing credentials was unsuccessful. {}".format(str(e)))
3943
raise InterfaceError(e)
4044
except requests.exceptions.Timeout as e:

0 commit comments

Comments
 (0)