Skip to content

Commit

Permalink
Merge branch 'release/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ollieread committed Dec 14, 2019
2 parents 777e564 + 821106e commit 054305e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
13 changes: 12 additions & 1 deletion src/JWTGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class JWTGuard implements Guard
*/
private $tokenValidator;

/**
* @var \Illuminate\Contracts\Cookie\QueueingFactory
*/
private $cookie;

/**
* Create a new authentication guard.
*
Expand Down Expand Up @@ -377,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) {
Expand All @@ -389,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());
Expand Down
9 changes: 8 additions & 1 deletion src/JWTServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Auth\AuthManager;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use RuntimeException;

class JWTServiceProvider extends BaseServiceProvider
{
Expand All @@ -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'))
Expand Down

0 comments on commit 054305e

Please sign in to comment.