示例#1
0
文件: JWT.php 项目: bendbennett/JWT
 /**
  * @param $request
  * @return array
  * @throws \Exception
  */
 public function read($request)
 {
     $token = $this->getAuthorizationHeader($request);
     $this->jws = $this->jws->callLoad($token);
     $algo = $this->algoFactory->make();
     if (!$this->jws->verify($algo->getKeyForVerifying(), $this->algoritihim)) {
         throw new \Exception('JWT algoritihim used for signing does not match algoritihim used for verifying');
     }
     if ($this->jws->isExpired($algo->getKeyForVerifying(), $this->algoritihim)) {
         throw new \Exception('JWT has expired');
     }
     return $this->jws->getPayload();
 }