Example #1
6
 /**
  * Invalidate a Token by adding it to the blacklist
  *
  * @param  Token  $token
  * @return boolean
  */
 public function invalidate(Token $token)
 {
     if (!$this->blacklistEnabled) {
         throw new JWTException('You must have the blacklist enabled to invalidate a token.');
     }
     return $this->blacklist->add($this->decode($token));
 }
Example #2
0
 /**
  * Refresh a Token and return a new Token.
  *
  * @param  \Tymon\JWTAuth\Token  $token
  *
  * @return \Tymon\JWTAuth\Token
  */
 public function refresh(Token $token)
 {
     $payload = $this->setRefreshFlow()->decode($token);
     if ($this->blacklistEnabled) {
         // invalidate old token
         $this->blacklist->add($payload);
     }
     // persist the subject and issued at claims
     $claims = array_merge($this->customClaims, ['sub' => $payload['sub'], 'iat' => $payload['iat']]);
     // return the new token
     return $this->encode($this->payloadFactory->customClaims($claims)->make());
 }
 /**
  * Register the bindings for the main JWTAuth class.
  */
 protected function registerJWTBlacklist()
 {
     $this->app['tymon.jwt.blacklist'] = $this->app->share(function ($app) {
         $instance = new Blacklist($app['tymon.jwt.provider.storage']);
         return $instance->setRefreshTTL($this->config('refresh_ttl'));
     });
 }
 /**
  * Register the bindings for the main JWTAuth class
  */
 protected function registerJWTBlacklist()
 {
     $this->app->singleton('tymon.jwt.blacklist', function ($app) {
         $instance = new Blacklist($app['tymon.jwt.provider.storage']);
         return $instance->setGracePeriod($this->config('blacklist_grace_period'))->setRefreshTTL($this->config('refresh_ttl'));
     });
 }