-
Notifications
You must be signed in to change notification settings - Fork 119
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
Timezone-aware datetime Object Support #325
base: main
Are you sure you want to change the base?
Conversation
Added ability to use datetime objects that are timezone aware for tim…
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.
Nits,
also please cleanup the commits, needs sign-off line.
Also please squash into a single comment w/o merge stuff and provide a commit message.
# Check for datetime objects | ||
if 'exp' in claims and isinstance(claims['exp'], datetime): | ||
# Check if timezone aware | ||
claims['exp'] = self._check_and_convert_dt(claims['exp'], 'exp') |
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.
I do not think we should modify the array being passed in.
We should instead make a copy in self.claims and modify them there
return dt_timestamp | ||
else: | ||
raise ValueError( | ||
f"'{claim_prop}' datetime object must be timezone aware" |
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.
Why does it need to be timezone-aware? Can't we just assume UTC if no timezone is set?
Please add a test that verifies this si working properly. |
Allows for datetime objects that are timezone-aware to be used for time-based claims: 'exp' and 'nbf' when making a JWT object, converting them to integer unix timestamps.