/** * @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); }
/** * @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); }
/** * @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); }