Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
bohanyang committed Sep 22, 2023
1 parent 28ab32b commit 3cd1c21
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/mango/Jose/CustomClaimChecker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace Mango\Jose;

use Jose\Component\Checker\ClaimChecker;
use Jose\Component\Checker\InvalidClaimException;

final class CustomClaimChecker implements ClaimChecker
{
public function __construct(
private readonly string $name,
private readonly mixed $value,
) {
}

public function checkClaim(mixed $value): void
{
if ($value !== $this->value) {
throw new InvalidClaimException('Invalid value.', $this->name, $value);
}
}

public function supportedClaim(): string
{
return $this->name;
}
}
2 changes: 1 addition & 1 deletion packages/mango/Jose/JWTHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Jose\Component\Core\Util\JsonConverter;
use Jose\Component\Signature\JWSVerifier;
use Jose\Component\Signature\Serializer\CompactSerializer as JWSCompactSerializer;
use LogicException;
use Psr\Log\LoggerInterface;
use RuntimeException;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
Expand All @@ -32,6 +31,7 @@ public function __construct(
private ClaimCheckerManager $claimCheckerManager,
#[Autowire(service: 'jose.jws_verifier.access_token')]
private JWSVerifier $jwsLoader,
#[Autowire(param: 'jose.access_token.mandatory_claims')]
private array $mandatoryClaims = [],
private ?LoggerInterface $logger = null,
private string $userIdClaim = 'sub',
Expand Down

0 comments on commit 3cd1c21

Please sign in to comment.