Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: servicenow provider timeout in validate scopes #2436

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading