From 17ad692628743f9778aea8f33e276bc0557d68c3 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Sat, 14 Dec 2019 01:15:38 +0000 Subject: [PATCH 1/4] Add missing property for cookie jar --- src/JWTGuard.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/JWTGuard.php b/src/JWTGuard.php index 189646b..4c98b20 100644 --- a/src/JWTGuard.php +++ b/src/JWTGuard.php @@ -52,6 +52,11 @@ class JWTGuard implements Guard */ private $tokenValidator; + /** + * @var \Illuminate\Contracts\Cookie\QueueingFactory + */ + private $cookie; + /** * Create a new authentication guard. * From 9901bbdfdc1ece8d86f3e8ea5c84310f85b9e45f Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Sat, 14 Dec 2019 01:20:10 +0000 Subject: [PATCH 2/4] Add exception header and explicitly convert the UUID to a string --- src/JWTGuard.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/JWTGuard.php b/src/JWTGuard.php index 4c98b20..47acdb0 100644 --- a/src/JWTGuard.php +++ b/src/JWTGuard.php @@ -382,6 +382,12 @@ private function createJwtCookie(Token $token, int $expiry): void ); } + /** + * @param \Illuminate\Contracts\Auth\Authenticatable $user + * + * @return \Lcobucci\JWT\Builder + * @throws \Exception + */ private function generateToken(Authenticatable $user): Builder { if ($this->tokenGenerator !== null) { @@ -394,7 +400,7 @@ private function generateToken(Authenticatable $user): Builder return (new Builder) ->issuedBy(config('app.url')) ->permittedFor(config('app.url')) - ->identifiedBy(Uuid::uuid4()) + ->identifiedBy(Uuid::uuid4()->toString()) ->issuedAt($time->timestamp) ->expiresAt($time->copy()->add($expiry)->timestamp) ->relatedTo($user->getAuthIdentifier()); From 971766b0c1f84303cdbf8dfb8938f88129fb3711 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Sat, 14 Dec 2019 01:22:54 +0000 Subject: [PATCH 3/4] Add check for when user provider isn't available --- src/JWTServiceProvider.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/JWTServiceProvider.php b/src/JWTServiceProvider.php index c63d7f7..ae85d87 100644 --- a/src/JWTServiceProvider.php +++ b/src/JWTServiceProvider.php @@ -5,6 +5,7 @@ use Illuminate\Auth\AuthManager; use Illuminate\Foundation\Application; use Illuminate\Support\ServiceProvider as BaseServiceProvider; +use RuntimeException; class JWTServiceProvider extends BaseServiceProvider { @@ -13,7 +14,13 @@ public function register(): void // Register the JWT driver with Laravel $auth = $this->app->make(AuthManager::class); $auth->extend('jwt', function (Application $app, string $name, array $config) use ($auth) { - $guard = new JWTGuard($auth->createUserProvider($config['provider'] ?? null), $name, $config); + $provider = $auth->createUserProvider($config['provider'] ?? null); + + if ($provider === null) { + throw new RuntimeException('No user provider available'); + } + + $guard = new JWTGuard($provider, $name, $config); $guard // Set the request instance on the guard ->setRequest($app->refresh('request', $guard, 'setRequest')) From 821106e6e616ced004aa90a08e45ab87053846d4 Mon Sep 17 00:00:00 2001 From: Ollie Read Date: Sat, 14 Dec 2019 01:26:16 +0000 Subject: [PATCH 4/4] Update changelog --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4050d5..30628a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.1] - 2019-12-14 +### Fixed +- Added missing property for cookie jar on JWT guard +- Added null check for user provider when instantiating guard +- Updated docblocks for exceptions +- Explicitly call `toString()` method on UUIDs + ## [1.1.0] - 2019-12-14 ### Added - Added HTTP only cookie support @@ -19,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [1.0.0] - 2019-11-19 - Initial release -[Unreleased]: https://github.com/sprocketbox/laravel-jwt/compare/v1.1.0...develop +[Unreleased]: https://github.com/sprocketbox/laravel-jwt/compare/v1.1.1...develop +[1.1.1]: https://github.com/sprocketbox/laravel-jwt/compare/v1.1.0...v1.1.1 [1.1.0]: https://github.com/sprocketbox/laravel-jwt/compare/v1.0...v1.1.0 [1.0.0]: https://github.com/sprocketbox/laravel-jwt/releases/tag/v1.0 \ No newline at end of file