hasClaim() public method

Returns if the claim is configured
public hasClaim ( string $name ) : boolean
$name string
return boolean
Esempio n. 1
0
 /**
  * @param Jwt $jwt
  * @return bool
  */
 public function validateRequiredClaims(Jwt $jwt)
 {
     foreach ($this->requiredClaims as $claim) {
         if (!$jwt->hasClaim($claim)) {
             return false;
         }
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Get the number of minutes until the token expiry.
  *
  * @param  \Lcobucci\JWT\Token  $token
  *
  * @return int
  */
 protected function getMinutesUntilExpired(Token $token)
 {
     $exp = Carbon::createFromTimestamp($token->getClaim('exp'));
     $iat = Carbon::createFromTimestamp($token->hasClaim('iat') ? $token->getClaim('iat') : 0);
     // get the latter of the two expiration dates and find
     // the number of minutes until the expiration date,
     // plus 1 minute to avoid overlap
     return $exp->max($iat->addMinutes($this->refreshTTL))->addMinute()->diffInMinutes();
 }
Esempio n. 3
0
 /**
  * @test
  *
  * @uses Lcobucci\JWT\Token::__construct
  * @uses Lcobucci\JWT\Claim\Basic
  *
  * @covers Lcobucci\JWT\Token::hasClaim
  */
 public function hasClaimMustReturnFalseWhenItIsNotConfigured()
 {
     $token = new Token([], ['test' => new Basic('test', 'testing')]);
     $this->assertFalse($token->hasClaim('testing'));
 }
Esempio n. 4
0
 /**
  * {@inheritDoc}
  */
 private function shouldTokenBeRefreshed(Token $token) : bool
 {
     if (!$token->hasClaim(self::ISSUED_AT_CLAIM)) {
         return false;
     }
     return $this->timestamp() >= $token->getClaim(self::ISSUED_AT_CLAIM) + $this->refreshTime;
 }