コード例 #1
0
ファイル: FirebaseParser.php プロジェクト: equip/auth
 /**
  * @inheritDoc
  */
 public function parseToken($token)
 {
     try {
         $metadata = (array) JWT::decode((string) $token, $this->config->getPublicKey(), [$this->config->getAlgorithm()]);
     } catch (ExpiredException $e) {
         throw InvalidException::tokenExpired($token, $e);
     }
     return new Token($token, $metadata);
 }
コード例 #2
0
 /**
  * @inheritDoc
  */
 public function parseToken($token)
 {
     try {
         $metadata = (array) JWT::decode((string) $token, $this->config->getPublicKey(), [$this->config->getAlgorithm()]);
     } catch (ExpiredException $e) {
         throw new InvalidException('Token has expired: ' . $token, InvalidException::CODE_TOKEN_EXPIRED);
     }
     return new Token($token, $metadata);
 }
コード例 #3
0
 /**
  * @param array $claims
  * @return string
  */
 public function getToken(array $claims = [])
 {
     $issuer = (string) $this->request->getUri();
     $issued_at = $this->config->getTimestamp();
     $expiration = $issued_at + $this->config->getTtl();
     $key = $this->config->getPublicKey();
     $algorithm = $this->config->getAlgorithm();
     $claims += ['iss' => $issuer, 'iat' => $issued_at, 'exp' => $expiration];
     return JWT::encode($claims, $key, $algorithm);
 }