mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
Merge pull request #13455 from infamousjoeg/fix-13439-support-conjur-oss
Fixes #13439 Add exception handling for `/api` on url
This commit is contained in:
@@ -68,7 +68,10 @@ def conjur_backend(**kwargs):
|
|||||||
with CertFiles(cacert) as cert:
|
with CertFiles(cacert) as cert:
|
||||||
# https://www.conjur.org/api.html#authentication-authenticate-post
|
# https://www.conjur.org/api.html#authentication-authenticate-post
|
||||||
auth_kwargs['verify'] = cert
|
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)
|
raise_for_status(resp)
|
||||||
token = resp.content.decode('utf-8')
|
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
|
# 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:
|
if version:
|
||||||
ver = "version={}".format(version)
|
ver = "version={}".format(version)
|
||||||
path = '?'.join([path, ver])
|
path = '?'.join([path, ver])
|
||||||
|
path_conjurcloud = '?'.join([path_conjurcloud, ver])
|
||||||
|
|
||||||
with CertFiles(cacert) as cert:
|
with CertFiles(cacert) as cert:
|
||||||
lookup_kwargs['verify'] = 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)
|
raise_for_status(resp)
|
||||||
return resp.text
|
return resp.text
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user