コード例 #1
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);
 }
コード例 #2
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->getPrivateKey();
     foreach ($claims as $name => $value) {
         $this->builder->set($name, $value);
     }
     $token = $this->builder->setIssuer($issuer)->setIssuedAt($issued_at)->setExpiration($expiration)->sign($this->signer, $key)->getToken();
     return (string) $token;
 }