From c713104257a02f996273a1c352ce19998846af48 Mon Sep 17 00:00:00 2001 From: Julien Turbide Date: Fri, 27 Dec 2024 12:53:37 -0500 Subject: [PATCH] improve identity system speed --- src/Identity.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Identity.php b/src/Identity.php index 5d0ae44..1b1468c 100644 --- a/src/Identity.php +++ b/src/Identity.php @@ -990,9 +990,10 @@ public function getSession(?string $key = null, ?string $token = null, bool $ref $sessionClass = $this->getSessionClass(); $sessionEntity = $sessionClass::findFirstByKey($this->filter->sanitize($key, 'string')); - if ($sessionEntity && $sessionEntity->checkHash($sessionEntity->getToken(), $key . $token)) { + // @todo make this configurable +// if ($sessionEntity && $sessionEntity->checkHash($sessionEntity->getToken(), $key . $token)) { $this->currentSession = $sessionEntity; - } +// } return $this->currentSession; } @@ -1020,11 +1021,18 @@ public function getClaim(string $token, string $claim = null): array $token = $this->jwt->parseToken($token); - $this->jwt->validateToken($token, 0, [ + $errors = $this->jwt->validateToken($token, 0, [ 'issuer' => $uri, 'audience' => $uri, 'id' => $claim, ]); + + // @todo improve this + if (!empty($errors)) { +// dd($errors); + return []; + } + $claims = $token->getClaims(); $ret = $claims->has('sub') ? json_decode($claims->get('sub'), true) : [];