Skip to content

Commit

Permalink
improve identity system speed
Browse files Browse the repository at this point in the history
  • Loading branch information
jturbide committed Dec 27, 2024
1 parent 955f69e commit c713104
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Identity.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) : [];
Expand Down

0 comments on commit c713104

Please sign in to comment.