Custom bearer token expiration validation#475
Merged
Conversation
Pull Request Test Coverage Report for Build 16067802947Details
💛 - Coveralls |
MarcelGeo
approved these changes
Jul 4, 2025
Collaborator
MarcelGeo
left a comment
There was a problem hiding this comment.
Yeah, we are now depending on hardocded value in expire. But it's more precise.
tomasMizera
reviewed
Jul 4, 2025
| try: | ||
| expire = datetime.fromisoformat(token_data.get("expire")) | ||
| except (ValueError, TypeError): | ||
| raise BadSignature("Invalid token") |
Collaborator
There was a problem hiding this comment.
Should we consider this as critical failure and log it so we can find it in logs in case something like this would happen? 🤔
tomasMizera
reviewed
Jul 4, 2025
| except (ValueError, TypeError): | ||
| raise BadSignature("Invalid token") | ||
|
|
||
| if expire < datetime.now(timezone.utc): |
Collaborator
There was a problem hiding this comment.
When we build the token, we use pytz.utc, here when decoding we use timezone.utc -- I guess that is allright, right @varmar05?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously we validated all access tokens with the same expiration value but since SSO we have two types of access token with different expiration period. Therefore, we use
expirefield to validate if token is still valid (instead of built-in max_age validation).