Skip to content

Commit 3ceacab

Browse files
authored
Add validation for missing "web-token/jwt-library" dependency (#688)
Ensure the service throws a clear exception if the required "web-token/jwt-library" package is not installed. This prevents potential runtime issues by guiding users to install the necessary dependency upfront.
1 parent 523735f commit 3ceacab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/webauthn/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Jose\Component\Signature\Algorithm\RS256;
1111
use Jose\Component\Signature\JWSVerifier;
1212
use Jose\Component\Signature\Serializer\CompactSerializer;
13+
use LogicException;
1314
use Psr\EventDispatcher\EventDispatcherInterface;
1415
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1516
use Symfony\Component\Serializer\SerializerInterface;
@@ -59,6 +60,11 @@ public function __construct(
5960
private readonly ?string $rootCertificateUri = null,
6061
?SerializerInterface $serializer = null,
6162
) {
63+
if (! class_exists(CompactSerializer::class)) {
64+
throw new LogicException(
65+
'The "web-token/jwt-library" package is required to use this service. Please run "composer require web-token/jwt-library".'
66+
);
67+
}
6268
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
6369
AttestationStatementSupportManager::create()
6470
))->create();

0 commit comments

Comments
 (0)