-
Notifications
You must be signed in to change notification settings - Fork 113
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
Fix Carbon not accepting string values #272
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.
LGTM, I just see a problem where people who already published their config files would still have this problem, maybe in a new major version we could use config()->integer()
which would be a breaking change for who uses laravel versions <11.
I guess that's the case for anyone who publishes any vendor file, whether that's config or views etc. They would need to sync with latest changes if they wanna keep getting the benefits. |
I'll wait if anyone else has something to say and approve. If not I'll merge it by the weekend. |
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'm not saying the proposed changed here a wrong, but setTtl()
, which receives the JWT_TTL config value already performs a cast
jwt-auth/src/Claims/Factory.php
Lines 200 to 204 in de2b4f2
public function setTTL($ttl) | |
{ | |
$this->ttl = $ttl ? (int) $ttl : $ttl; | |
return $this; |
I rather see inconsistencies with other casts, e.g. we've
\PHPOpenSourceSaver\JWTAuth\Blacklist::setRefreshTTL
which has a castLines 224 to 226 in 83653d5
public function setRefreshTTL($ttl) { $this->refreshTTL = (int) $ttl; - but then
\PHPOpenSourceSaver\JWTAuth\Validators\PayloadValidator::setRefreshTTL
which has no castjwt-auth/src/Validators/PayloadValidator.php
Lines 114 to 116 in 1fa7f7d
public function setRefreshTTL($ttl) { $this->refreshTTL = $ttl;
Again, I'm not against this change but it feels like the fixes are better provided in other places, which would also make working with the library as API directly safer.
How exactly did you produce this, can you provide a full stacktrace?
Description
Carbon methods are strongly typed. So, you can't provide
seconds
as astring
.This is what you get if you try to override
JWT_TTL
in your.env
:This PR fixes the issue by casting the config after reading it from
.env
as is common in Laravel's config files.Fixes #271
Checklist:
CHANGELOG.md