-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for optional profile expiration #153
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean solution grabbing the Expiration
from the API 👍 . Minor comments
:return expiration | ||
""" | ||
try: | ||
return role_response["Credentials"]["Expiration"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming here that aws returns the expiration time in utc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, the value is returned in UTC.
There is existing code that converts this to local when displaying the role to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup yup! I just knew there was a aws config var for setting timestamps. I have had a problem switching from aws cli version 1 to 2 before. A different issue than this, but just wanted to check as those returned different formats. Think we are good then 👍 !
return | ||
|
||
profile_expiration = datetime.fromisoformat(profile_expiration_str) | ||
now = datetime.now(timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not necessary but if it isn't guaranteed to return utc.
now = datetime.now(timezone.utc) | |
now = datetime.now(profile_expiration.tzinfo if profile_espiration.tzinfo else timezone.utc) |
Description
These changes add optional support for profile expiration checking. When enabled with the
--use-profile-expiration
option,tokendito
will store the expiration in each profile. Subsequent authentication requests will then check the expiration to see if it's still valid and bypass the need to re-authenticate.Related Issue
N/A
Motivation and Context
This reduces the friction for our engineering teams when they need to script the use of
tokendito
and MFA is in play.How Has This Been Tested?
Example output:
Types of changes
Checklist: