Skip to content

Commit

Permalink
fix: servicenow provider timeout in validate scopes (#2436)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Nov 11, 2024
1 parent 8d34713 commit 19f47e3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions keep/providers/servicenow_provider/servicenow_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def validate_scopes(self):
Validates that the user has the required scopes to use the provider.
"""
try:
self.logger.info("Validating ServiceNow scopes")
url = f"{self.authentication_config.service_now_base_url}/api/now/table/sys_user_role?sysparm_query=user_name={self.authentication_config.username}"
response = requests.get(
url,
Expand All @@ -86,19 +87,23 @@ def validate_scopes(self):
self.authentication_config.password,
),
verify=False,
timeout=10,
)
if response.status_code == 200:
roles = response.json()
roles_names = [role.get("name") for role in roles.get("result")]
if "itil" in roles_names:
self.logger.info("User has ITIL role")
scopes = {
"itil": True,
}
else:
self.logger.info("User does not have ITIL role")
scopes = {
"itil": "This user does not have the ITIL role",
}
else:
self.logger.info("Failed to get roles from ServiceNow")
scopes["itil"] = "Failed to get roles from ServiceNow"
except Exception as e:
self.logger.exception("Error validating scopes")
Expand Down

0 comments on commit 19f47e3

Please sign in to comment.