コード例 #1
0
 /**
  * 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'])->addMinutes($this->refreshTTL)->isPast()) {
         throw new TokenExpiredException('Token has expired and can no longer be refreshed', 400);
     }
     return true;
 }
コード例 #2
0
ファイル: Blacklist.php プロジェクト: modder2/jwt-auth
 /**
  * Add the token (jti claim) to the blacklist
  *
  * @param  \Tymon\JWTAuth\Payload  $payload
  * @return boolean
  */
 public function add(Payload $payload)
 {
     $exp = Utils::timestamp($payload['exp']);
     // there is no need to add the token to the blacklist
     // if the token has already expired
     if ($exp->isPast()) {
         return false;
     }
     // add a minute to abate potential overlap
     $minutes = $exp->diffInMinutes(Utils::now()->subMinute());
     $this->storage->add($payload['jti'], [], $minutes);
     return true;
 }
コード例 #3
0
ファイル: Blacklist.php プロジェクト: w0rd-driven/jwt-auth
 /**
  * Add the token (jti claim) to the blacklist.
  *
  * @param  \Tymon\JWTAuth\Payload  $payload
  * @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 AND the refresh_ttl
     // has gone by
     if ($exp->isPast() && $refreshExp->isPast()) {
         return false;
     }
     // 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'], [], $cacheLifetime);
     return true;
 }
コード例 #4
0
 /**
  * Set the Not Before (nbf) claim
  *
  * @return int
  */
 public function nbf()
 {
     return Utils::now()->format('U');
 }
コード例 #5
0
 /**
  * Set the Not Before (nbf) claim.
  *
  * @return int
  */
 public function nbf()
 {
     return Utils::now()->timestamp;
 }
コード例 #6
0
ファイル: Blacklist.php プロジェクト: earnaway/jwt-auth
 /**
  * Get the timestamp when the blacklist comes into effect
  * This defaults to immediate (0 seconds).
  *
  * @return integer
  */
 protected function getGraceTimestamp()
 {
     return (int) Utils::now()->addSeconds($this->gracePeriod)->format('U');
 }