mirror of
https://github.com/ansible/awx.git
synced 2026-04-14 06:29:25 -02:30
Restore basic auth for subscriptions API
Fallback to basic auth if OAUTH to console.redhat.com fails Notes: Envoy has a timeout of 30 seconds, so the total timeout should be less than that. (5, 20) means 5 seconds to connect to server, 20 seconds to start reading data. Signed-off-by: Seth Foster <fosterbseth@gmail.com> --------- Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
@@ -243,14 +243,23 @@ class Licenser(object):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
def get_rhsm_subs(self, host, client_id, client_secret):
|
def get_rhsm_subs(self, host, client_id, client_secret):
|
||||||
client = OIDCClient(client_id, client_secret)
|
try:
|
||||||
subs = client.make_request(
|
client = OIDCClient(client_id, client_secret)
|
||||||
'GET',
|
subs = client.make_request(
|
||||||
host,
|
'GET',
|
||||||
verify=True,
|
host,
|
||||||
timeout=(31, 31),
|
verify=True,
|
||||||
)
|
timeout=(5, 20),
|
||||||
|
)
|
||||||
|
except requests.RequestException:
|
||||||
|
logger.warning("Failed to connect to console.redhat.com using Service Account credentials. Falling back to basic auth.")
|
||||||
|
subs = requests.request(
|
||||||
|
'GET',
|
||||||
|
host,
|
||||||
|
auth=(client_id, client_secret),
|
||||||
|
verify=True,
|
||||||
|
timeout=(5, 20),
|
||||||
|
)
|
||||||
subs.raise_for_status()
|
subs.raise_for_status()
|
||||||
subs_formatted = []
|
subs_formatted = []
|
||||||
for sku in subs.json()['body']:
|
for sku in subs.json()['body']:
|
||||||
|
|||||||
Reference in New Issue
Block a user