コード例 #1
6
ファイル: JWTManager.php プロジェクト: dskeba/jwt-auth
 /**
  * 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));
 }
コード例 #2
0
ファイル: Manager.php プロジェクト: a161527/cs319-p2t5
 /**
  * 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());
 }
コード例 #3
0
 /**
  * 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'));
     });
 }
コード例 #4
0
 /**
  * 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'));
     });
 }