Skip to content

Commit

Permalink
优化更新
Browse files Browse the repository at this point in the history
  • Loading branch information
deatil committed Mar 10, 2023
1 parent c34a479 commit 834977e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Larke\JWT\Contracts\Signer;
use Larke\JWT\Contracts\Validatable;
use Larke\JWT\Contracts\ValidationData;
use Larke\JWT\Contracts\UnencryptedToken;
use Larke\JWT\Claim\RegisteredHeaders;
use Larke\JWT\Claim\Factory as ClaimFactory;

Expand All @@ -23,7 +24,7 @@ public function __construct(
$this->claimFactory = $claimFactory ?: new ClaimFactory();
}

public function verify(Token $token, Signer $signer, Key $key): bool
public function verify(UnencryptedToken $token, Signer $signer, Key $key): bool
{
if ($token->headers()->get(RegisteredHeaders::ALGORITHM) !== $signer->getAlgorithmId()) {
return false;
Expand All @@ -35,7 +36,7 @@ public function verify(Token $token, Signer $signer, Key $key): bool
return $signer->verify($hash, $payload, $key);
}

public function validate(Token $token, ValidationData $data): bool
public function validate(UnencryptedToken $token, ValidationData $data): bool
{
foreach ($this->getValidatableClaims($token) as $claim) {
if (! $claim->validate($data)) {
Expand All @@ -46,7 +47,7 @@ public function validate(Token $token, ValidationData $data): bool
return true;
}

private function getValidatableClaims(Token $token): Generator
private function getValidatableClaims(UnencryptedToken $token): Generator
{
foreach ($token->claims()->all() as $name => $value) {
$claim = $this->claimFactory->create($name, $value);
Expand Down

0 comments on commit 834977e

Please sign in to comment.