| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Facile\OpenIDClient\Token; |
| 6 |
|
| 7 |
use Facile\JoseVerifier\IdTokenVerifierInterface; |
| 8 |
use Facile\OpenIDClient\Client\ClientInterface; |
| 9 |
use Override; |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
final class IdTokenVerifierBuilder implements IdTokenVerifierBuilderInterface |
| 15 |
{ |
| 16 |
private bool $aadIssValidation = false; |
| 17 |
|
| 18 |
private int $clockTolerance = 0; |
| 19 |
|
| 20 |
public function setAadIssValidation(bool $aadIssValidation): self |
| 21 |
{ |
| 22 |
$this->aadIssValidation = $aadIssValidation; |
| 23 |
|
| 24 |
return $this; |
| 25 |
} |
| 26 |
|
| 27 |
public function setClockTolerance(int $clockTolerance): self |
| 28 |
{ |
| 29 |
$this->clockTolerance = $clockTolerance; |
| 30 |
|
| 31 |
return $this; |
| 32 |
} |
| 33 |
|
| 34 |
#[Override] |
| 35 |
public function build(ClientInterface $client): IdTokenVerifierInterface |
| 36 |
{ |
| 37 |
|
| 38 |
return \Facile\JoseVerifier\Builder\IdTokenVerifierBuilder::create( |
| 39 |
$client->getIssuer()->getMetadata()->toArray(), |
| 40 |
$client->getMetadata()->toArray(), |
| 41 |
) |
| 42 |
->withJwksProvider($client->getIssuer()->getJwksProvider()) |
| 43 |
->withClientJwksProvider($client->getJwksProvider()) |
| 44 |
->withClockTolerance($this->clockTolerance) |
| 45 |
->withAadIssValidation($this->aadIssValidation) |
| 46 |
->build(); |
| 47 |
} |
| 48 |
} |