Skip to content

Commit 9520c83

Browse files
authored
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 <[email protected]> --------- Signed-off-by: Seth Foster <[email protected]>
1 parent 144f08f commit 9520c83

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

awx/main/utils/licensing.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,23 @@ def validate_rh(self, user, pw):
243243
return []
244244

245245
def get_rhsm_subs(self, host, client_id, client_secret):
246-
client = OIDCClient(client_id, client_secret)
247-
subs = client.make_request(
248-
'GET',
249-
host,
250-
verify=True,
251-
timeout=(31, 31),
252-
)
253-
246+
try:
247+
client = OIDCClient(client_id, client_secret)
248+
subs = client.make_request(
249+
'GET',
250+
host,
251+
verify=True,
252+
timeout=(5, 20),
253+
)
254+
except requests.RequestException:
255+
logger.warning("Failed to connect to console.redhat.com using Service Account credentials. Falling back to basic auth.")
256+
subs = requests.request(
257+
'GET',
258+
host,
259+
auth=(client_id, client_secret),
260+
verify=True,
261+
timeout=(5, 20),
262+
)
254263
subs.raise_for_status()
255264
subs_formatted = []
256265
for sku in subs.json()['body']:

0 commit comments

Comments
 (0)