summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeth Foster <fosterseth@users.noreply.github.com>2023-01-31 22:28:31 +0100
committerGitHub <noreply@github.com>2023-01-31 22:28:31 +0100
commit61c7d4e4cace58af3e8ff63c9a9d3b1f4b2cc0e7 (patch)
tree7269d7b219455f1606710e544ce13cf024ea1946
parentFix syntax bug that came from fixing sanity tests (#13473) (diff)
parentFix API Lint Failure - remove bare excepts (diff)
downloadawx-61c7d4e4cace58af3e8ff63c9a9d3b1f4b2cc0e7.tar.xz
awx-61c7d4e4cace58af3e8ff63c9a9d3b1f4b2cc0e7.zip
Merge pull request #13455 from infamousjoeg/fix-13439-support-conjur-oss
Fixes #13439 Add exception handling for `/api` on url
-rw-r--r--awx/main/credential_plugins/conjur.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/awx/main/credential_plugins/conjur.py b/awx/main/credential_plugins/conjur.py
index 79fe740884..5510667d4c 100644
--- a/awx/main/credential_plugins/conjur.py
+++ b/awx/main/credential_plugins/conjur.py
@@ -68,7 +68,10 @@ def conjur_backend(**kwargs):
with CertFiles(cacert) as cert:
# https://www.conjur.org/api.html#authentication-authenticate-post
auth_kwargs['verify'] = cert
- resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)
+ try:
+ resp = requests.post(urljoin(url, '/'.join(['authn', account, username, 'authenticate'])), **auth_kwargs)
+ except requests.exceptions.ConnectionError:
+ resp = requests.post(urljoin(url, '/'.join(['api', 'authn', account, username, 'authenticate'])), **auth_kwargs)
raise_for_status(resp)
token = resp.content.decode('utf-8')
@@ -78,14 +81,19 @@ def conjur_backend(**kwargs):
}
# https://www.conjur.org/api.html#secrets-retrieve-a-secret-get
- path = urljoin(url, '/'.join(['api', 'secrets', account, 'variable', secret_path]))
+ path = urljoin(url, '/'.join(['secrets', account, 'variable', secret_path]))
+ path_conjurcloud = urljoin(url, '/'.join(['api', 'secrets', account, 'variable', secret_path]))
if version:
ver = "version={}".format(version)
path = '?'.join([path, ver])
+ path_conjurcloud = '?'.join([path_conjurcloud, ver])
with CertFiles(cacert) as cert:
lookup_kwargs['verify'] = cert
- resp = requests.get(path, timeout=30, **lookup_kwargs)
+ try:
+ resp = requests.get(path, timeout=30, **lookup_kwargs)
+ except requests.exceptions.ConnectionError:
+ resp = requests.get(path_conjurcloud, timeout=30, **lookup_kwargs)
raise_for_status(resp)
return resp.text