Check existence of expires_in for auth
If a registries doesn't provide an expires_in with their token, the current code fails doing the comparison. If no such header is included, let's assume there is no expire time so we can just use the cached token. If the token expires, we'll reauth as usual. Change-Id: I96ab407ba50e2183141daec3341dbb29545d5beb Closes-Bug: #1912645
This commit is contained in:
parent
f456b465c8
commit
e04774948e
|
@ -312,7 +312,8 @@ class RegistrySessionHelper(object):
|
|||
if data and data.get('issued_at'):
|
||||
token_time = dt_parse(data.get('issued_at'))
|
||||
now = datetime.now(tzlocal())
|
||||
if (now - token_time).seconds < data.get('expires_in'):
|
||||
expires_in = data.get('expires_in')
|
||||
if not expires_in or (now - token_time).seconds < expires_in:
|
||||
return data['token']
|
||||
return None
|
||||
|
||||
|
|
Loading…
Reference in New Issue