Skip to content

Commit

Permalink
Updating
Browse files Browse the repository at this point in the history
  • Loading branch information
jboucourt committed Aug 6, 2024
1 parent 960425f commit 74ad6c0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions gestalt/vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,18 @@ def scheme(self) -> str:
def _validate_token_expiration(self):
token_details = self.vault_client.auth.token.lookup_self()
if token_details['data'] is not None:

expire_time = None
if 'expire_time' not in token_details['data']['expire_time']:
print("Key 'expire_time' does not exist in token_details['data']")
return None

# Validate expire_time is present
if token_details['data'] is None or token_details['data']['expire_time'] is None:
print(f"Cannot parse expire_time, value is None: {token_details['data']}")
if expire_time is None:
print("Cannot parse expire_time, value is None")
return None

expire_time = datetime.fromisoformat(str(token_details['data']['expire_time']))
expire_time = str(expire_time)
threshold = timedelta(days=EXPIRATION_THRESHOLD_DAYS)
delta_time = expire_time - datetime.now()
if delta_time < threshold:
Expand Down

0 comments on commit 74ad6c0

Please sign in to comment.