Add option to provide current time when decoding JWT - #267
Conversation
Codecov Report
@@ Coverage Diff @@## master #267 +/- ##
=======================================
Coverage 92.94% 92.94% =======================================
Files 15 15 Lines 1418 1418 =======================================
Hits 1318 1318 Misses 100 100
Continue to review full report at Codecov.
|
blag
left a comment
There was a problem hiding this comment.
Dependency injection to ease testing? 👍
Dependency injection to improve usability? 👍
Code churn for no discernible reason? 👎
If you have a good reason for prepending the now parameter like you did, I'll definitely consider it, but I haven't seen a good reason for it yet. Please point me to it if I missed it. 😅
Uh oh!
There was an error while loading. Please reload this page.
| def _validate_claims(claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None): | ||
| def _validate_claims(now, claims, audience=None, issuer=None, subject=None, algorithm=None, access_token=None, options=None): |
There was a problem hiding this comment.
Why change the function signature? Wouldn't it be easier to append now=None to the end of the parameter list and keep the function signature the same? And then use
now=nowordatetime.utcnow()to default to datetime.utcnow(), just in case anybody is using these private methods.
I realize that they're private methods, and people are signing up to keep their code up-to-date when they use these private methods, but there's no point in code churn without a good reason.
There was a problem hiding this comment.
It was not part of the public API (this particular function does not even have docstring to serve as a documentation), so there was no hesitation to change the signature. Making now (required) positional argument better states the intention to me.
Either way, updated.
7a66496 to
9667b78Comparejojolebarjos
commented
May 30, 2025
Hi folks, this feature would be very welcome, any chance this gets accepted? |
9667b78 to
8fd0ed9CompareZipFile
commented
May 31, 2025
Rebased with latest |
freezegun:freeze_timeorunittest.mock:patch. Less monkey patching == better code.