Update v1.0.6.5
This commit is contained in:
60
vendor/tymon/jwt-auth/src/Blacklist.php
vendored
60
vendor/tymon/jwt-auth/src/Blacklist.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Tymon\JWTAuth\Providers\Storage\StorageInterface;
|
||||
@@ -11,6 +20,13 @@ class Blacklist
|
||||
*/
|
||||
protected $storage;
|
||||
|
||||
/**
|
||||
* Number of minutes from issue date in which a JWT can be refreshed.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $refreshTTL = 20160;
|
||||
|
||||
/**
|
||||
* @param \Tymon\JWTAuth\Providers\Storage\StorageInterface $storage
|
||||
*/
|
||||
@@ -20,34 +36,38 @@ class Blacklist
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the token (jti claim) to the blacklist
|
||||
* Add the token (jti claim) to the blacklist.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Payload $payload
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function add(Payload $payload)
|
||||
{
|
||||
$exp = Utils::timestamp($payload['exp']);
|
||||
$refreshExp = Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL);
|
||||
|
||||
// there is no need to add the token to the blacklist
|
||||
// if the token has already expired
|
||||
if ($exp->isPast()) {
|
||||
// if the token has already expired AND the refresh_ttl
|
||||
// has gone by
|
||||
if ($exp->isPast() && $refreshExp->isPast()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// add a minute to abate potential overlap
|
||||
$minutes = $exp->diffInMinutes(Utils::now()->subMinute());
|
||||
// Set the cache entry's lifetime to be equal to the amount
|
||||
// of refreshable time it has remaining (which is the larger
|
||||
// of `exp` and `iat+refresh_ttl`), rounded up a minute
|
||||
$cacheLifetime = $exp->max($refreshExp)->addMinute()->diffInMinutes();
|
||||
|
||||
$this->storage->add($payload['jti'], [], $minutes);
|
||||
$this->storage->add($payload['jti'], [], $cacheLifetime);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the token has been blacklisted
|
||||
* Determine whether the token has been blacklisted.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Payload $payload
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function has(Payload $payload)
|
||||
{
|
||||
@@ -55,10 +75,10 @@ class Blacklist
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the token (jti claim) from the blacklist
|
||||
* Remove the token (jti claim) from the blacklist.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Payload $payload
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function remove(Payload $payload)
|
||||
{
|
||||
@@ -66,9 +86,9 @@ class Blacklist
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all tokens from the blacklist
|
||||
* Remove all tokens from the blacklist.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
@@ -76,4 +96,18 @@ class Blacklist
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the refresh time limit.
|
||||
*
|
||||
* @param int
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setRefreshTTL($ttl)
|
||||
{
|
||||
$this->refreshTTL = (int) $ttl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
11
vendor/tymon/jwt-auth/src/Claims/Audience.php
vendored
11
vendor/tymon/jwt-auth/src/Claims/Audience.php
vendored
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Audience extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
31
vendor/tymon/jwt-auth/src/Claims/Claim.php
vendored
31
vendor/tymon/jwt-auth/src/Claims/Claim.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\InvalidClaimException;
|
||||
@@ -7,14 +16,14 @@ use Tymon\JWTAuth\Exceptions\InvalidClaimException;
|
||||
abstract class Claim implements ClaimInterface
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The claim value
|
||||
* The claim value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
@@ -29,7 +38,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the claim value, and call a validate method if available
|
||||
* Set the claim value, and call a validate method if available.
|
||||
*
|
||||
* @param $value
|
||||
* @throws \Tymon\JWTAuth\Exceptions\InvalidClaimException
|
||||
@@ -38,7 +47,7 @@ abstract class Claim implements ClaimInterface
|
||||
public function setValue($value)
|
||||
{
|
||||
if (! $this->validate($value)) {
|
||||
throw new InvalidClaimException('Invalid value provided for claim "' . $this->getName() . '": ' . $value);
|
||||
throw new InvalidClaimException('Invalid value provided for claim "'.$this->getName().'": '.$value);
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
@@ -47,7 +56,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the claim value
|
||||
* Get the claim value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@@ -57,7 +66,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the claim name
|
||||
* Set the claim name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return $this
|
||||
@@ -70,7 +79,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the claim name
|
||||
* Get the claim name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -80,10 +89,10 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the Claim value
|
||||
* Validate the Claim value.
|
||||
*
|
||||
* @param $value
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validate($value)
|
||||
{
|
||||
@@ -91,7 +100,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a key value array comprising of the claim name and value
|
||||
* Build a key value array comprising of the claim name and value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -101,7 +110,7 @@ abstract class Claim implements ClaimInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the claim as a string
|
||||
* Get the claim as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
interface ClaimInterface
|
||||
{
|
||||
/**
|
||||
* Set the claim value, and call a validate method if available
|
||||
* Set the claim value, and call a validate method if available.
|
||||
*
|
||||
* @param mixed
|
||||
* @return Claim
|
||||
@@ -13,14 +22,14 @@ interface ClaimInterface
|
||||
public function setValue($value);
|
||||
|
||||
/**
|
||||
* Get the claim value
|
||||
* Get the claim value.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue();
|
||||
|
||||
/**
|
||||
* Set the claim name
|
||||
* Set the claim name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return Claim
|
||||
@@ -28,7 +37,7 @@ interface ClaimInterface
|
||||
public function setName($name);
|
||||
|
||||
/**
|
||||
* Get the claim name
|
||||
* Get the claim name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
9
vendor/tymon/jwt-auth/src/Claims/Custom.php
vendored
9
vendor/tymon/jwt-auth/src/Claims/Custom.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Custom extends Claim
|
||||
|
15
vendor/tymon/jwt-auth/src/Claims/Expiration.php
vendored
15
vendor/tymon/jwt-auth/src/Claims/Expiration.php
vendored
@@ -1,21 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Expiration extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'exp';
|
||||
|
||||
/**
|
||||
* Validate the expiry claim
|
||||
* Validate the expiry claim.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validate($value)
|
||||
{
|
||||
|
17
vendor/tymon/jwt-auth/src/Claims/Factory.php
vendored
17
vendor/tymon/jwt-auth/src/Claims/Factory.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Factory
|
||||
@@ -14,11 +23,11 @@ class Factory
|
||||
'iss' => 'Tymon\JWTAuth\Claims\Issuer',
|
||||
'jti' => 'Tymon\JWTAuth\Claims\JwtId',
|
||||
'nbf' => 'Tymon\JWTAuth\Claims\NotBefore',
|
||||
'sub' => 'Tymon\JWTAuth\Claims\Subject'
|
||||
'sub' => 'Tymon\JWTAuth\Claims\Subject',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the instance of the claim when passing the name and value
|
||||
* Get the instance of the claim when passing the name and value.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
@@ -34,10 +43,10 @@ class Factory
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the claim exists
|
||||
* Check whether the claim exists.
|
||||
*
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name)
|
||||
{
|
||||
|
15
vendor/tymon/jwt-auth/src/Claims/IssuedAt.php
vendored
15
vendor/tymon/jwt-auth/src/Claims/IssuedAt.php
vendored
@@ -1,21 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class IssuedAt extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'iat';
|
||||
|
||||
/**
|
||||
* Validate the issued at claim
|
||||
* Validate the issued at claim.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validate($value)
|
||||
{
|
||||
|
11
vendor/tymon/jwt-auth/src/Claims/Issuer.php
vendored
11
vendor/tymon/jwt-auth/src/Claims/Issuer.php
vendored
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Issuer extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
11
vendor/tymon/jwt-auth/src/Claims/JwtId.php
vendored
11
vendor/tymon/jwt-auth/src/Claims/JwtId.php
vendored
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class JwtId extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
15
vendor/tymon/jwt-auth/src/Claims/NotBefore.php
vendored
15
vendor/tymon/jwt-auth/src/Claims/NotBefore.php
vendored
@@ -1,21 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class NotBefore extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'nbf';
|
||||
|
||||
/**
|
||||
* Validate the not before claim
|
||||
* Validate the not before claim.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validate($value)
|
||||
{
|
||||
|
11
vendor/tymon/jwt-auth/src/Claims/Subject.php
vendored
11
vendor/tymon/jwt-auth/src/Claims/Subject.php
vendored
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Claims;
|
||||
|
||||
class Subject extends Claim
|
||||
{
|
||||
/**
|
||||
* The claim name
|
||||
* The claim name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Commands;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class InvalidClaimException extends JWTException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 400;
|
||||
}
|
||||
|
@@ -1,17 +1,26 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class JWTException extends \Exception
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 500;
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @param integer $statusCode
|
||||
* @param int $statusCode
|
||||
*/
|
||||
public function __construct($message = 'An error occurred', $statusCode = null)
|
||||
{
|
||||
@@ -23,7 +32,7 @@ class JWTException extends \Exception
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $statusCode
|
||||
* @param int $statusCode
|
||||
*/
|
||||
public function setStatusCode($statusCode)
|
||||
{
|
||||
@@ -31,7 +40,7 @@ class JWTException extends \Exception
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer the status code
|
||||
* @return int the status code
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class PayloadException extends JWTException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 500;
|
||||
}
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class TokenBlacklistedException extends TokenInvalidException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 401;
|
||||
}
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class TokenExpiredException extends JWTException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 401;
|
||||
}
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Exceptions;
|
||||
|
||||
class TokenInvalidException extends JWTException
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 400;
|
||||
}
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
13
vendor/tymon/jwt-auth/src/JWTAuth.php
vendored
13
vendor/tymon/jwt-auth/src/JWTAuth.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
@@ -140,7 +149,7 @@ class JWTAuth
|
||||
*
|
||||
* @param mixed $token
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function invalidate($token = false)
|
||||
{
|
||||
@@ -152,7 +161,7 @@ class JWTAuth
|
||||
/**
|
||||
* Get the token.
|
||||
*
|
||||
* @return boolean|string
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
|
37
vendor/tymon/jwt-auth/src/JWTManager.php
vendored
37
vendor/tymon/jwt-auth/src/JWTManager.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
@@ -24,12 +33,12 @@ class JWTManager
|
||||
protected $payloadFactory;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $blacklistEnabled = true;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $refreshFlow = false;
|
||||
|
||||
@@ -46,7 +55,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a Payload and return the Token
|
||||
* Encode a Payload and return the Token.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Payload $payload
|
||||
* @return \Tymon\JWTAuth\Token
|
||||
@@ -59,7 +68,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a Token and return the Payload
|
||||
* Decode a Token and return the Payload.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Token $token
|
||||
* @return Payload
|
||||
@@ -79,7 +88,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh a Token and return a new Token
|
||||
* Refresh a Token and return a new Token.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Token $token
|
||||
* @return \Tymon\JWTAuth\Token
|
||||
@@ -97,16 +106,16 @@ class JWTManager
|
||||
return $this->encode(
|
||||
$this->payloadFactory->make([
|
||||
'sub' => $payload['sub'],
|
||||
'iat' => $payload['iat']
|
||||
'iat' => $payload['iat'],
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate a Token by adding it to the blacklist
|
||||
* Invalidate a Token by adding it to the blacklist.
|
||||
*
|
||||
* @param Token $token
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function invalidate(Token $token)
|
||||
{
|
||||
@@ -118,7 +127,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PayloadFactory instance
|
||||
* Get the PayloadFactory instance.
|
||||
*
|
||||
* @return \Tymon\JWTAuth\PayloadFactory
|
||||
*/
|
||||
@@ -128,7 +137,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JWTProvider instance
|
||||
* Get the JWTProvider instance.
|
||||
*
|
||||
* @return \Tymon\JWTAuth\Providers\JWT\JWTInterface
|
||||
*/
|
||||
@@ -138,7 +147,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Blacklist instance
|
||||
* Get the Blacklist instance.
|
||||
*
|
||||
* @return \Tymon\JWTAuth\Blacklist
|
||||
*/
|
||||
@@ -148,7 +157,7 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the blacklist is enabled
|
||||
* Set whether the blacklist is enabled.
|
||||
*
|
||||
* @param bool $enabled
|
||||
*/
|
||||
@@ -160,9 +169,9 @@ class JWTManager
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the refresh flow
|
||||
* Set the refresh flow.
|
||||
*
|
||||
* @param boolean $refreshFlow
|
||||
* @param bool $refreshFlow
|
||||
* @return $this
|
||||
*/
|
||||
public function setRefreshFlow($refreshFlow = true)
|
||||
|
@@ -1,20 +1,29 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Middleware;
|
||||
|
||||
use Tymon\JWTAuth\JWTAuth;
|
||||
use Illuminate\Events\Dispatcher;
|
||||
use Illuminate\Routing\ResponseFactory;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Routing\ResponseFactory;
|
||||
|
||||
abstract class BaseMiddleware
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Routing\ResponseFactory
|
||||
* @var \Illuminate\Contracts\Routing\ResponseFactory
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Events\Dispatcher
|
||||
* @var \Illuminate\Contracts\Events\Dispatcher
|
||||
*/
|
||||
protected $events;
|
||||
|
||||
@@ -24,10 +33,10 @@ abstract class BaseMiddleware
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new BaseMiddleware instance
|
||||
* Create a new BaseMiddleware instance.
|
||||
*
|
||||
* @param \Illuminate\Routing\ResponseFactory $response
|
||||
* @param \Illuminate\Events\Dispatcher $events
|
||||
* @param \Illuminate\Contracts\Routing\ResponseFactory $response
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @param \Tymon\JWTAuth\JWTAuth $auth
|
||||
*/
|
||||
public function __construct(ResponseFactory $response, Dispatcher $events, JWTAuth $auth)
|
||||
@@ -38,11 +47,11 @@ abstract class BaseMiddleware
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire event and return the response
|
||||
* Fire event and return the response.
|
||||
*
|
||||
* @param string $event
|
||||
* @param string $error
|
||||
* @param integer $status
|
||||
* @param int $status
|
||||
* @param array $payload
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Middleware;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Middleware;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
@@ -27,7 +36,7 @@ class RefreshToken extends BaseMiddleware
|
||||
}
|
||||
|
||||
// send the refreshed token back to the client
|
||||
$response->headers->set('Authorization', 'Bearer ' . $newToken);
|
||||
$response->headers->set('Authorization', 'Bearer '.$newToken);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
31
vendor/tymon/jwt-auth/src/Payload.php
vendored
31
vendor/tymon/jwt-auth/src/Payload.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Tymon\JWTAuth\Claims\Claim;
|
||||
@@ -9,14 +18,14 @@ use Tymon\JWTAuth\Validators\PayloadValidator;
|
||||
class Payload implements \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* The array of claims
|
||||
* The array of claims.
|
||||
*
|
||||
* @var \Tymon\JWTAuth\Claims\Claim[]
|
||||
*/
|
||||
private $claims = [];
|
||||
|
||||
/**
|
||||
* Build the Payload
|
||||
* Build the Payload.
|
||||
*
|
||||
* @param array $claims
|
||||
* @param \Tymon\JWTAuth\Validators\PayloadValidator $validator
|
||||
@@ -30,7 +39,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of claim instances
|
||||
* Get the array of claim instances.
|
||||
*
|
||||
* @return \Tymon\JWTAuth\Claims\Claim[]
|
||||
*/
|
||||
@@ -40,7 +49,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array of claims
|
||||
* Get the array of claims.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -55,7 +64,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payload
|
||||
* Get the payload.
|
||||
*
|
||||
* @param string $claim
|
||||
* @return mixed
|
||||
@@ -74,10 +83,10 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the payload has the claim
|
||||
* Determine whether the payload has the claim.
|
||||
*
|
||||
* @param \Tymon\JWTAuth\Claims\Claim $claim
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function has(Claim $claim)
|
||||
{
|
||||
@@ -85,7 +94,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the payload as a string
|
||||
* Get the payload as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -117,7 +126,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't allow changing the payload as it should be immutable
|
||||
* Don't allow changing the payload as it should be immutable.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
@@ -130,7 +139,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't allow changing the payload as it should be immutable
|
||||
* Don't allow changing the payload as it should be immutable.
|
||||
*
|
||||
* @param string $key
|
||||
* @throws Exceptions\PayloadException
|
||||
@@ -142,7 +151,7 @@ class Payload implements \ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Magically get a claim value
|
||||
* Magically get a claim value.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
|
47
vendor/tymon/jwt-auth/src/PayloadFactory.php
vendored
47
vendor/tymon/jwt-auth/src/PayloadFactory.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
@@ -29,7 +38,7 @@ class PayloadFactory
|
||||
protected $ttl = 60;
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
protected $refreshFlow = false;
|
||||
|
||||
@@ -56,7 +65,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Payload instance
|
||||
* Create the Payload instance.
|
||||
*
|
||||
* @param array $customClaims
|
||||
* @return \Tymon\JWTAuth\Payload
|
||||
@@ -69,7 +78,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an array of claims to the Payload
|
||||
* Add an array of claims to the Payload.
|
||||
*
|
||||
* @param array $claims
|
||||
* @return $this
|
||||
@@ -84,7 +93,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a claim to the Payload
|
||||
* Add a claim to the Payload.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
@@ -98,7 +107,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the default claims
|
||||
* Build the default claims.
|
||||
*
|
||||
* @param array $customClaims
|
||||
* @return $this
|
||||
@@ -118,7 +127,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Build out the Claim DTO's
|
||||
* Build out the Claim DTO's.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@@ -133,7 +142,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Issuer (iss) claim
|
||||
* Set the Issuer (iss) claim.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -143,37 +152,37 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Issued At (iat) claim
|
||||
* Set the Issued At (iat) claim.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function iat()
|
||||
{
|
||||
return (int) Utils::now()->format('U');
|
||||
return Utils::now()->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Expiration (exp) claim
|
||||
* Set the Expiration (exp) claim.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function exp()
|
||||
{
|
||||
return (int) Utils::now()->addMinutes($this->ttl)->format('U');
|
||||
return Utils::now()->addMinutes($this->ttl)->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Not Before (nbf) claim
|
||||
* Set the Not Before (nbf) claim.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function nbf()
|
||||
{
|
||||
return (int) Utils::now()->format('U');
|
||||
return Utils::now()->timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a unique id (jti) for the token
|
||||
* Set a unique id (jti) for the token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -186,7 +195,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the token ttl (in minutes)
|
||||
* Set the token ttl (in minutes).
|
||||
*
|
||||
* @param int $ttl
|
||||
* @return $this
|
||||
@@ -199,7 +208,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token ttl
|
||||
* Get the token ttl.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@@ -209,9 +218,9 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the refresh flow
|
||||
* Set the refresh flow.
|
||||
*
|
||||
* @param boolean $refreshFlow
|
||||
* @param bool $refreshFlow
|
||||
* @return $this
|
||||
*/
|
||||
public function setRefreshFlow($refreshFlow = true)
|
||||
@@ -222,7 +231,7 @@ class PayloadFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* Magically add a claim
|
||||
* Magically add a claim.
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\Auth;
|
||||
|
||||
interface AuthInterface
|
||||
{
|
||||
/**
|
||||
* Check a user's credentials
|
||||
* Check a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
@@ -13,7 +22,7 @@ interface AuthInterface
|
||||
public function byCredentials(array $credentials = []);
|
||||
|
||||
/**
|
||||
* Authenticate a user via the id
|
||||
* Authenticate a user via the id.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return bool
|
||||
@@ -21,7 +30,7 @@ interface AuthInterface
|
||||
public function byId($id);
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -1,8 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\Auth;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Auth\AuthManager;
|
||||
|
||||
class IlluminateAuthAdapter implements AuthInterface
|
||||
@@ -21,7 +29,7 @@ class IlluminateAuthAdapter implements AuthInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Check a user's credentials
|
||||
* Check a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @return bool
|
||||
@@ -32,22 +40,18 @@ class IlluminateAuthAdapter implements AuthInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Authenticate a user via the id
|
||||
* Authenticate a user via the id.
|
||||
*
|
||||
* @param mixed $id
|
||||
* @return bool
|
||||
*/
|
||||
public function byId($id)
|
||||
{
|
||||
try {
|
||||
return $this->auth->onceUsingId($id);
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
return $this->auth->onceUsingId($id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\JWT;
|
||||
|
||||
interface JWTInterface
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\JWT;
|
||||
|
||||
abstract class JWTProvider
|
||||
@@ -25,7 +34,7 @@ abstract class JWTProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the algorithm used to sign the token
|
||||
* Set the algorithm used to sign the token.
|
||||
*
|
||||
* @param string $algo
|
||||
* @return self
|
||||
@@ -38,7 +47,7 @@ abstract class JWTProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the algorithm used to sign the token
|
||||
* Get the algorithm used to sign the token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\JWT;
|
||||
|
||||
use Exception;
|
||||
@@ -27,7 +36,7 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JSON Web Token
|
||||
* Create a JSON Web Token.
|
||||
*
|
||||
* @return string
|
||||
* @throws \Tymon\JWTAuth\Exceptions\JWTException
|
||||
@@ -39,12 +48,12 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
|
||||
|
||||
return $this->jws->getTokenString();
|
||||
} catch (Exception $e) {
|
||||
throw new JWTException('Could not create token: ' . $e->getMessage());
|
||||
throw new JWTException('Could not create token: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a JSON Web Token
|
||||
* Decode a JSON Web Token.
|
||||
*
|
||||
* @param string $token
|
||||
* @return array
|
||||
@@ -55,7 +64,7 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
|
||||
try {
|
||||
$jws = JWS::load($token);
|
||||
} catch (Exception $e) {
|
||||
throw new TokenInvalidException('Could not decode token: ' . $e->getMessage());
|
||||
throw new TokenInvalidException('Could not decode token: '.$e->getMessage());
|
||||
}
|
||||
|
||||
if (! $jws->verify($this->secret, $this->algo)) {
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers;
|
||||
|
||||
use Tymon\JWTAuth\JWTAuth;
|
||||
@@ -26,7 +35,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
$this->publishes([
|
||||
__DIR__.'/../config/config.php' => config_path('jwt.php')
|
||||
__DIR__.'/../config/config.php' => config_path('jwt.php'),
|
||||
], 'config');
|
||||
|
||||
$this->bootBindings();
|
||||
@@ -35,7 +44,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind some Interfaces and implementations
|
||||
* Bind some Interfaces and implementations.
|
||||
*/
|
||||
protected function bootBindings()
|
||||
{
|
||||
@@ -102,11 +111,11 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
$this->registerPayloadFactory();
|
||||
$this->registerJWTCommand();
|
||||
|
||||
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'jwt');
|
||||
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'jwt');
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the User provider
|
||||
* Register the bindings for the User provider.
|
||||
*/
|
||||
protected function registerUserProvider()
|
||||
{
|
||||
@@ -116,7 +125,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the JSON Web Token provider
|
||||
* Register the bindings for the JSON Web Token provider.
|
||||
*/
|
||||
protected function registerJWTProvider()
|
||||
{
|
||||
@@ -131,7 +140,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the Auth provider
|
||||
* Register the bindings for the Auth provider.
|
||||
*/
|
||||
protected function registerAuthProvider()
|
||||
{
|
||||
@@ -141,7 +150,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the Storage provider
|
||||
* Register the bindings for the Storage provider.
|
||||
*/
|
||||
protected function registerStorageProvider()
|
||||
{
|
||||
@@ -151,7 +160,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the Payload Factory
|
||||
* Register the bindings for the Payload Factory.
|
||||
*/
|
||||
protected function registerClaimFactory()
|
||||
{
|
||||
@@ -161,7 +170,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the JWT Manager
|
||||
* Register the bindings for the JWT Manager.
|
||||
*/
|
||||
protected function registerJWTManager()
|
||||
{
|
||||
@@ -178,7 +187,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the main JWTAuth class
|
||||
* Register the bindings for the main JWTAuth class.
|
||||
*/
|
||||
protected function registerJWTAuth()
|
||||
{
|
||||
@@ -196,17 +205,19 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the main JWTAuth class
|
||||
* Register the bindings for the main JWTAuth class.
|
||||
*/
|
||||
protected function registerJWTBlacklist()
|
||||
{
|
||||
$this->app['tymon.jwt.blacklist'] = $this->app->share(function ($app) {
|
||||
return new Blacklist($app['tymon.jwt.provider.storage']);
|
||||
$instance = new Blacklist($app['tymon.jwt.provider.storage']);
|
||||
|
||||
return $instance->setRefreshTTL($this->config('refresh_ttl'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the payload validator
|
||||
* Register the bindings for the payload validator.
|
||||
*/
|
||||
protected function registerPayloadValidator()
|
||||
{
|
||||
@@ -216,7 +227,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the bindings for the Payload Factory
|
||||
* Register the bindings for the Payload Factory.
|
||||
*/
|
||||
protected function registerPayloadFactory()
|
||||
{
|
||||
@@ -228,7 +239,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the Artisan command
|
||||
* Register the Artisan command.
|
||||
*/
|
||||
protected function registerJWTCommand()
|
||||
{
|
||||
@@ -238,7 +249,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get the config values
|
||||
* Helper to get the config values.
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
@@ -249,7 +260,7 @@ class JWTAuthServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an instantiable configuration instance. Pinched from dingo/api :)
|
||||
* Get an instantiable configuration instance. Pinched from dingo/api :).
|
||||
*
|
||||
* @param mixed $instance
|
||||
* @return object
|
||||
|
@@ -1,9 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\Storage;
|
||||
|
||||
use Illuminate\Cache\CacheManager;
|
||||
use Tymon\JWTAuth\Providers\Storage\StorageInterface;
|
||||
|
||||
class IlluminateCacheAdapter implements StorageInterface
|
||||
{
|
||||
@@ -26,7 +34,7 @@ class IlluminateCacheAdapter implements StorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new item into storage
|
||||
* Add a new item into storage.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
@@ -39,7 +47,7 @@ class IlluminateCacheAdapter implements StorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a key exists in storage
|
||||
* Check whether a key exists in storage.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
@@ -50,7 +58,7 @@ class IlluminateCacheAdapter implements StorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from storage
|
||||
* Remove an item from storage.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool
|
||||
@@ -61,7 +69,7 @@ class IlluminateCacheAdapter implements StorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all items associated with the tag
|
||||
* Remove all items associated with the tag.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -71,7 +79,7 @@ class IlluminateCacheAdapter implements StorageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the cache instance with tags attached
|
||||
* Return the cache instance with tags attached.
|
||||
*
|
||||
* @return \Illuminate\Cache\CacheManager
|
||||
*/
|
||||
|
@@ -1,25 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\Storage;
|
||||
|
||||
interface StorageInterface
|
||||
{
|
||||
/**
|
||||
* @param string $key
|
||||
* @param integer $minutes
|
||||
* @param int $minutes
|
||||
* @return void
|
||||
*/
|
||||
public function add($key, $value, $minutes);
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function has($key);
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function destroy($key);
|
||||
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\User;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -12,7 +21,7 @@ class EloquentUserAdapter implements UserInterface
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Create a new User instance
|
||||
* Create a new User instance.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Model $user
|
||||
*/
|
||||
@@ -22,7 +31,7 @@ class EloquentUserAdapter implements UserInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user by the given key, value
|
||||
* Get the user by the given key, value.
|
||||
*
|
||||
* @param mixed $key
|
||||
* @param mixed $value
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Providers\User;
|
||||
|
||||
interface UserInterface
|
||||
{
|
||||
/**
|
||||
* Get the user by the given key, value
|
||||
* Get the user by the given key, value.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
|
15
vendor/tymon/jwt-auth/src/Token.php
vendored
15
vendor/tymon/jwt-auth/src/Token.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Tymon\JWTAuth\Validators\TokenValidator;
|
||||
@@ -12,7 +21,7 @@ class Token
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* Create a new JSON Web Token
|
||||
* Create a new JSON Web Token.
|
||||
*
|
||||
* @param string $value
|
||||
*/
|
||||
@@ -24,7 +33,7 @@ class Token
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token
|
||||
* Get the token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -34,7 +43,7 @@ class Token
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token when casting to string
|
||||
* Get the token when casting to string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
13
vendor/tymon/jwt-auth/src/Utils.php
vendored
13
vendor/tymon/jwt-auth/src/Utils.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth;
|
||||
|
||||
use Carbon\Carbon;
|
||||
@@ -7,7 +16,7 @@ use Carbon\Carbon;
|
||||
class Utils
|
||||
{
|
||||
/**
|
||||
* Get the Carbon instance for the current time
|
||||
* Get the Carbon instance for the current time.
|
||||
*
|
||||
* @return \Carbon\Carbon
|
||||
*/
|
||||
@@ -17,7 +26,7 @@ class Utils
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Carbon instance for the timestamp
|
||||
* Get the Carbon instance for the timestamp.
|
||||
*
|
||||
* @param int $timestamp
|
||||
* @return \Carbon\Carbon
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Validators;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\JWTException;
|
||||
@@ -12,7 +21,7 @@ abstract class AbstractValidator implements ValidatorInterface
|
||||
protected $refreshFlow = false;
|
||||
|
||||
/**
|
||||
* Helper function to return a boolean
|
||||
* Helper function to return a boolean.
|
||||
*
|
||||
* @param array $value
|
||||
* @return bool
|
||||
@@ -29,7 +38,7 @@ abstract class AbstractValidator implements ValidatorInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the refresh flow flag
|
||||
* Set the refresh flow flag.
|
||||
*
|
||||
* @param bool $refreshFlow
|
||||
* @return $this
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Validators;
|
||||
|
||||
use Tymon\JWTAuth\Utils;
|
||||
@@ -14,12 +23,12 @@ class PayloadValidator extends AbstractValidator
|
||||
protected $requiredClaims = ['iss', 'iat', 'exp', 'nbf', 'sub', 'jti'];
|
||||
|
||||
/**
|
||||
* @var integer
|
||||
* @var int
|
||||
*/
|
||||
protected $refreshTTL = 20160;
|
||||
|
||||
/**
|
||||
* Run the validations on the payload array
|
||||
* Run the validations on the payload array.
|
||||
*
|
||||
* @param array $value
|
||||
* @return void
|
||||
@@ -37,7 +46,7 @@ class PayloadValidator extends AbstractValidator
|
||||
|
||||
/**
|
||||
* Ensure the payload contains the required claims and
|
||||
* the claims have the relevant type
|
||||
* the claims have the relevant type.
|
||||
*
|
||||
* @param array $payload
|
||||
* @throws \Tymon\JWTAuth\Exceptions\TokenInvalidException
|
||||
@@ -53,12 +62,12 @@ class PayloadValidator extends AbstractValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the payload timestamps
|
||||
* Validate the payload timestamps.
|
||||
*
|
||||
* @param array $payload
|
||||
* @throws \Tymon\JWTAuth\Exceptions\TokenExpiredException
|
||||
* @throws \Tymon\JWTAuth\Exceptions\TokenInvalidException
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateTimestamps(array $payload)
|
||||
{
|
||||
@@ -78,14 +87,14 @@ class PayloadValidator extends AbstractValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the token in the refresh flow context
|
||||
* Check the token in the refresh flow context.
|
||||
*
|
||||
* @param $payload
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateRefresh(array $payload)
|
||||
{
|
||||
if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->diffInMinutes(Utils::now()) >= $this->refreshTTL) {
|
||||
if (isset($payload['iat']) && Utils::timestamp($payload['iat'])->addMinutes($this->refreshTTL)->isPast()) {
|
||||
throw new TokenExpiredException('Token has expired and can no longer be refreshed', 400);
|
||||
}
|
||||
|
||||
@@ -93,7 +102,7 @@ class PayloadValidator extends AbstractValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the required claims
|
||||
* Set the required claims.
|
||||
*
|
||||
* @param array $claims
|
||||
*/
|
||||
@@ -105,9 +114,9 @@ class PayloadValidator extends AbstractValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the refresh ttl
|
||||
* Set the refresh ttl.
|
||||
*
|
||||
* @param integer $ttl
|
||||
* @param int $ttl
|
||||
*/
|
||||
public function setRefreshTTL($ttl)
|
||||
{
|
||||
|
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Validators;
|
||||
|
||||
use Tymon\JWTAuth\Exceptions\TokenInvalidException;
|
||||
@@ -7,7 +16,7 @@ use Tymon\JWTAuth\Exceptions\TokenInvalidException;
|
||||
class TokenValidator extends AbstractValidator
|
||||
{
|
||||
/**
|
||||
* Check the structure of the token
|
||||
* Check the structure of the token.
|
||||
*
|
||||
* @param string $value
|
||||
* @return void
|
||||
@@ -20,7 +29,7 @@ class TokenValidator extends AbstractValidator
|
||||
/**
|
||||
* @param string $token
|
||||
* @throws \Tymon\JWTAuth\Exceptions\TokenInvalidException
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateStructure($token)
|
||||
{
|
||||
|
@@ -1,11 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tymon\JWTAuth\Validators;
|
||||
|
||||
interface ValidatorInterface
|
||||
{
|
||||
/**
|
||||
* Perform some checks on the value
|
||||
* Perform some checks on the value.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
@@ -13,7 +22,7 @@ interface ValidatorInterface
|
||||
public function check($value);
|
||||
|
||||
/**
|
||||
* Helper function to return a boolean
|
||||
* Helper function to return a boolean.
|
||||
*
|
||||
* @param array $value
|
||||
* @return bool
|
||||
|
19
vendor/tymon/jwt-auth/src/config/config.php
vendored
19
vendor/tymon/jwt-auth/src/config/config.php
vendored
@@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of jwt-auth.
|
||||
*
|
||||
* (c) Sean Tymon <tymon148@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
@@ -146,9 +155,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'auth' => function ($app) {
|
||||
return new Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter($app['auth']);
|
||||
},
|
||||
'auth' => 'Tymon\JWTAuth\Providers\Auth\IlluminateAuthAdapter',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -159,10 +166,8 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'storage' => function ($app) {
|
||||
return new Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter($app['cache']);
|
||||
}
|
||||
'storage' => 'Tymon\JWTAuth\Providers\Storage\IlluminateCacheAdapter',
|
||||
|
||||
]
|
||||
],
|
||||
|
||||
];
|
||||
|
Reference in New Issue
Block a user