diff --git a/src/JWT.php b/src/JWT.php index efa533c..6a252a1 100644 --- a/src/JWT.php +++ b/src/JWT.php @@ -143,18 +143,23 @@ public function encode(array $payload, array $header = []): string * Decode JWT token and return original payload. * * @param string $token + * @param bool $verify * * @throws JWTException * * @return array */ - public function decode(string $token): array + public function decode(string $token, bool $verify = true): array { if (\substr_count($token, '.') < 2) { throw new JWTException('Invalid token: Incomplete segments', static::ERROR_TOKEN_INVALID); } $token = \explode('.', $token, 3); + if (!$verify) { + return (array) $this->urlSafeDecode($token[1]); + } + $this->validateHeader((array) $this->urlSafeDecode($token[0])); // Validate signature.