Phase 0: Fundament für Inhaus
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7197eaebf2
commit
9c0f8de791
15771 changed files with 1564103 additions and 5 deletions
72
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestationObjectDenormalizer.php
vendored
Normal file
72
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestationObjectDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use CBOR\Decoder;
|
||||
use CBOR\Normalizable;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationObject;
|
||||
use Webauthn\AttestationStatement\AttestationStatement;
|
||||
use Webauthn\AuthenticatorData;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\StringStream;
|
||||
|
||||
final class AttestationObjectDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var string $data */
|
||||
$stream = new StringStream($data);
|
||||
$parsed = Decoder::create()->decode($stream);
|
||||
|
||||
$parsed instanceof Normalizable || throw InvalidDataException::create(
|
||||
$parsed,
|
||||
'Invalid attestation object. Unexpected object.'
|
||||
);
|
||||
/** @var array<string, mixed> $attestationObject */
|
||||
$attestationObject = $parsed->normalize();
|
||||
$stream->isEOF() || throw InvalidDataException::create(
|
||||
null,
|
||||
'Invalid attestation object. Presence of extra bytes.'
|
||||
);
|
||||
$stream->close();
|
||||
$authData = $attestationObject['authData'] ?? throw InvalidDataException::create(
|
||||
$attestationObject,
|
||||
'Invalid attestation object. Missing "authData" field.'
|
||||
);
|
||||
|
||||
return AttestationObject::create(
|
||||
$data,
|
||||
$this->denormalizer->denormalize($attestationObject, AttestationStatement::class, $format, $context),
|
||||
$this->denormalizer->denormalize($authData, AuthenticatorData::class, $format, $context),
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AttestationObject::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AttestationObject::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
48
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestationStatementDenormalizer.php
vendored
Normal file
48
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestationStatementDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatement;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
|
||||
final readonly class AttestationStatementDenormalizer implements DenormalizerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private AttestationStatementSupportManager $attestationStatementSupportManager
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{fmt: string, attStmt: array<string, mixed>, authData: string} $data */
|
||||
$attestationStatementSupport = $this->attestationStatementSupportManager->get($data['fmt']);
|
||||
|
||||
return $attestationStatementSupport->load($data);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AttestationStatement::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AttestationStatement::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
45
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestedCredentialDataNormalizer.php
vendored
Normal file
45
vendor/web-auth/webauthn-lib/src/Denormalizer/AttestedCredentialDataNormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\AttestedCredentialData;
|
||||
|
||||
final class AttestedCredentialDataNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof AttestedCredentialData);
|
||||
$result = [
|
||||
'aaguid' => $this->normalizer->normalize($data->aaguid, $format, $context),
|
||||
'credentialId' => base64_encode($data->credentialId),
|
||||
];
|
||||
if ($data->credentialPublicKey !== null) {
|
||||
$result['credentialPublicKey'] = base64_encode($data->credentialPublicKey);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof AttestedCredentialData;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AttestedCredentialData::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
40
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticationExtensionNormalizer.php
vendored
Normal file
40
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticationExtensionNormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtension;
|
||||
|
||||
final class AuthenticationExtensionNormalizer implements NormalizerInterface
|
||||
{
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticationExtension::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public function normalize(mixed $object, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($object instanceof AuthenticationExtension);
|
||||
|
||||
/** @var array<mixed> $value */
|
||||
$value = $object->value;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof AuthenticationExtension;
|
||||
}
|
||||
}
|
||||
71
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticationExtensionsDenormalizer.php
vendored
Normal file
71
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticationExtensionsDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtension;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtensions;
|
||||
|
||||
final class AuthenticationExtensionsDenormalizer implements DenormalizerInterface, NormalizerInterface
|
||||
{
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
if ($data instanceof AuthenticationExtensions) {
|
||||
return AuthenticationExtensions::create($data->extensions);
|
||||
}
|
||||
assert(is_array($data), 'The data should be an array.');
|
||||
foreach ($data as $key => $value) {
|
||||
if (! is_string($key)) {
|
||||
continue;
|
||||
}
|
||||
$data[$key] = AuthenticationExtension::create($key, $value);
|
||||
}
|
||||
|
||||
/** @var array<string, AuthenticationExtension> $data */
|
||||
return AuthenticationExtensions::create($data);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AuthenticationExtensions::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticationExtensions::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof AuthenticationExtensions);
|
||||
$extensions = [];
|
||||
foreach ($data->extensions as $extension) {
|
||||
$extensions[$extension->name] = $extension->value;
|
||||
}
|
||||
|
||||
return $extensions;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof AuthenticationExtensions;
|
||||
}
|
||||
}
|
||||
83
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php
vendored
Normal file
83
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorAssertionResponseDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationObject;
|
||||
use Webauthn\AuthenticatorAssertionResponse;
|
||||
use Webauthn\AuthenticatorData;
|
||||
use Webauthn\CollectedClientData;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
final class AuthenticatorAssertionResponseDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{authenticatorData: string, signature: string, clientDataJSON: string, userHandle?: ?string, attestationObject?: string} $data */
|
||||
$data['authenticatorData'] = Base64::decode($data['authenticatorData']);
|
||||
$data['signature'] = Base64::decode($data['signature']);
|
||||
$data['clientDataJSON'] = Base64UrlSafe::decodeNoPadding($data['clientDataJSON']);
|
||||
$userHandle = $data['userHandle'] ?? null;
|
||||
if ($userHandle !== '' && $userHandle !== null) {
|
||||
$userHandle = Base64::decode($userHandle);
|
||||
}
|
||||
|
||||
/** @var CollectedClientData $clientDataJSON */
|
||||
$clientDataJSON = $this->denormalizer->denormalize(
|
||||
$data['clientDataJSON'],
|
||||
CollectedClientData::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var AuthenticatorData $authenticatorData */
|
||||
$authenticatorData = $this->denormalizer->denormalize(
|
||||
$data['authenticatorData'],
|
||||
AuthenticatorData::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
return AuthenticatorAssertionResponse::create(
|
||||
$clientDataJSON,
|
||||
$authenticatorData,
|
||||
$data['signature'],
|
||||
$userHandle ?? null,
|
||||
! isset($data['attestationObject']) ? null : $this->denormalizer->denormalize(
|
||||
$data['attestationObject'],
|
||||
AttestationObject::class,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AuthenticatorAssertionResponse::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticatorAssertionResponse::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
70
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php
vendored
Normal file
70
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorAttestationResponseDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationObject;
|
||||
use Webauthn\AuthenticatorAttestationResponse;
|
||||
use Webauthn\CollectedClientData;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
final class AuthenticatorAttestationResponseDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{clientDataJSON: string, attestationObject: string, transports?: string[]} $data */
|
||||
$data['clientDataJSON'] = Base64UrlSafe::decodeNoPadding($data['clientDataJSON']);
|
||||
$data['attestationObject'] = Base64::decode($data['attestationObject']);
|
||||
|
||||
/** @var CollectedClientData $clientDataJSON */
|
||||
$clientDataJSON = $this->denormalizer->denormalize(
|
||||
$data['clientDataJSON'],
|
||||
CollectedClientData::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var AttestationObject $attestationObject */
|
||||
$attestationObject = $this->denormalizer->denormalize(
|
||||
$data['attestationObject'],
|
||||
AttestationObject::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
return AuthenticatorAttestationResponse::create(
|
||||
$clientDataJSON,
|
||||
$attestationObject,
|
||||
$data['transports'] ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AuthenticatorAttestationResponse::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticatorAttestationResponse::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
156
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorDataDenormalizer.php
vendored
Normal file
156
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorDataDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use CBOR\ByteStringObject;
|
||||
use CBOR\Decoder;
|
||||
use CBOR\ListObject;
|
||||
use CBOR\MapObject;
|
||||
use CBOR\NegativeIntegerObject;
|
||||
use CBOR\TextStringObject;
|
||||
use CBOR\UnsignedIntegerObject;
|
||||
use function chr;
|
||||
use function is_string;
|
||||
use function ord;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Webauthn\AttestedCredentialData;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtensionLoader;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtensions;
|
||||
use Webauthn\AuthenticatorData;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\StringStream;
|
||||
|
||||
final class AuthenticatorDataDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
private readonly Decoder $decoder;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->decoder = Decoder::create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
assert(is_string($data));
|
||||
$authData = $this->fixIncorrectEdDSAKey($data);
|
||||
$authDataStream = new StringStream($authData);
|
||||
$rp_id_hash = $authDataStream->read(32);
|
||||
$flags = $authDataStream->read(1);
|
||||
$signCount = $authDataStream->read(4);
|
||||
/** @var array{1: int} $signCount */
|
||||
$signCount = unpack('N', $signCount);
|
||||
|
||||
$attestedCredentialData = null;
|
||||
if (0 !== (ord($flags) & AuthenticatorData::FLAG_AT)) {
|
||||
$aaguid = Uuid::fromBinary($authDataStream->read(16));
|
||||
$credentialLength = $authDataStream->read(2);
|
||||
/** @var array{1: int} $credentialLength */
|
||||
$credentialLength = unpack('n', $credentialLength);
|
||||
$credentialId = $authDataStream->read($credentialLength[1]);
|
||||
$credentialPublicKey = $this->decoder->decode($authDataStream);
|
||||
$credentialPublicKey instanceof MapObject || throw InvalidDataException::create(
|
||||
$authData,
|
||||
'The data does not contain a valid credential public key.'
|
||||
);
|
||||
$attestedCredentialData = AttestedCredentialData::create(
|
||||
$aaguid,
|
||||
$credentialId,
|
||||
(string) $credentialPublicKey,
|
||||
);
|
||||
}
|
||||
$extension = null;
|
||||
if (0 !== (ord($flags) & AuthenticatorData::FLAG_ED)) {
|
||||
$extension = $this->decoder->decode($authDataStream);
|
||||
$extension = AuthenticationExtensionLoader::load($extension);
|
||||
}
|
||||
$authDataStream->isEOF() || throw InvalidDataException::create(
|
||||
$authData,
|
||||
'Invalid authentication data. Presence of extra bytes.'
|
||||
);
|
||||
$authDataStream->close();
|
||||
|
||||
return AuthenticatorData::create(
|
||||
$authData,
|
||||
$rp_id_hash,
|
||||
$flags,
|
||||
$signCount[1],
|
||||
$attestedCredentialData,
|
||||
$extension === null ? null : $this->denormalizer->denormalize(
|
||||
$extension,
|
||||
AuthenticationExtensions::class,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AuthenticatorData::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticatorData::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
private function fixIncorrectEdDSAKey(string $data): string
|
||||
{
|
||||
/** @var string $needle */
|
||||
$needle = hex2bin('a301634f4b500327206745643235353139');
|
||||
/** @var string $correct */
|
||||
$correct = hex2bin('a401634f4b500327206745643235353139');
|
||||
$position = strpos($data, $needle);
|
||||
if ($position === false) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
$begin = substr($data, 0, $position);
|
||||
$end = substr($data, $position);
|
||||
$end = str_replace($needle, $correct, $end);
|
||||
$cbor = new StringStream($end);
|
||||
$badKey = $this->decoder->decode($cbor);
|
||||
|
||||
($badKey instanceof MapObject && $cbor->isEOF()) || throw InvalidDataException::create(
|
||||
$end,
|
||||
'Invalid authentication data. Presence of extra bytes.'
|
||||
);
|
||||
$badX = $badKey->get(-2);
|
||||
$badX instanceof ListObject || throw InvalidDataException::create($end, 'Invalid authentication data.');
|
||||
/** @var list<string> $normalizedBadX */
|
||||
$normalizedBadX = $badX->normalize();
|
||||
$keyBytes = array_reduce(
|
||||
$normalizedBadX,
|
||||
static fn (string $carry, string $item): string => $carry . chr((int) $item),
|
||||
''
|
||||
);
|
||||
$correctX = ByteStringObject::create($keyBytes);
|
||||
$correctKey = MapObject::create()
|
||||
->add(UnsignedIntegerObject::create(1), TextStringObject::create('OKP'))
|
||||
->add(UnsignedIntegerObject::create(3), NegativeIntegerObject::create(-8))
|
||||
->add(NegativeIntegerObject::create(-1), TextStringObject::create('Ed25519'))
|
||||
->add(NegativeIntegerObject::create(-2), $correctX);
|
||||
|
||||
return $begin . $correctKey;
|
||||
}
|
||||
}
|
||||
53
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorResponseDenormalizer.php
vendored
Normal file
53
vendor/web-auth/webauthn-lib/src/Denormalizer/AuthenticatorResponseDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AuthenticatorAssertionResponse;
|
||||
use Webauthn\AuthenticatorAttestationResponse;
|
||||
use Webauthn\AuthenticatorResponse;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
|
||||
final class AuthenticatorResponseDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array<string, mixed> $data */
|
||||
$realType = match (true) {
|
||||
array_key_exists('attestationObject', $data) => AuthenticatorAttestationResponse::class,
|
||||
array_key_exists('signature', $data) => AuthenticatorAssertionResponse::class,
|
||||
default => throw InvalidDataException::create($data, 'Unable to create the response object'),
|
||||
};
|
||||
|
||||
return $this->denormalizer->denormalize($data, $realType, $format, $context);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === AuthenticatorResponse::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AuthenticatorResponse::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
48
vendor/web-auth/webauthn-lib/src/Denormalizer/CollectedClientDataDenormalizer.php
vendored
Normal file
48
vendor/web-auth/webauthn-lib/src/Denormalizer/CollectedClientDataDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use const JSON_THROW_ON_ERROR;
|
||||
use JsonException;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\CollectedClientData;
|
||||
|
||||
final class CollectedClientDataDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws JsonException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var string $data */
|
||||
/** @var array<string, mixed> $decoded */
|
||||
$decoded = json_decode($data, true, flags: JSON_THROW_ON_ERROR);
|
||||
|
||||
return CollectedClientData::create($data, $decoded);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === CollectedClientData::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
CollectedClientData::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
107
vendor/web-auth/webauthn-lib/src/Denormalizer/CredentialRecordDenormalizer.php
vendored
Normal file
107
vendor/web-auth/webauthn-lib/src/Denormalizer/CredentialRecordDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Webauthn\CredentialRecord;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\TrustPath\TrustPath;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
/**
|
||||
* @final
|
||||
*/
|
||||
class CredentialRecordDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface, NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{publicKeyCredentialId: string, credentialPublicKey: string, userHandle: string, type: string, transports: string[], attestationType: string, trustPath: array<string, mixed>, aaguid: string, counter: int, otherUI?: ?array<string, mixed>, backupEligible?: ?bool, backupStatus?: ?bool, uvInitialized?: ?bool} $data */
|
||||
$keys = ['publicKeyCredentialId', 'credentialPublicKey', 'userHandle'];
|
||||
foreach ($keys as $key) {
|
||||
array_key_exists($key, $data) || throw InvalidDataException::create($data, 'Missing ' . $key);
|
||||
$data[$key] = Base64::decode($data[$key]);
|
||||
}
|
||||
|
||||
return CredentialRecord::create(
|
||||
$data['publicKeyCredentialId'],
|
||||
$data['type'],
|
||||
$data['transports'],
|
||||
$data['attestationType'],
|
||||
$this->denormalizer->denormalize($data['trustPath'], TrustPath::class, $format, $context),
|
||||
Uuid::fromString($data['aaguid']),
|
||||
$data['credentialPublicKey'],
|
||||
$data['userHandle'],
|
||||
$data['counter'],
|
||||
$data['otherUI'] ?? null,
|
||||
$data['backupEligible'] ?? null,
|
||||
$data['backupStatus'] ?? null,
|
||||
$data['uvInitialized'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === CredentialRecord::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
CredentialRecord::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof CredentialRecord);
|
||||
$result = [
|
||||
'publicKeyCredentialId' => Base64UrlSafe::encodeUnpadded($data->publicKeyCredentialId),
|
||||
'type' => $data->type,
|
||||
'transports' => $data->transports,
|
||||
'attestationType' => $data->attestationType,
|
||||
'trustPath' => $this->normalizer->normalize($data->trustPath, $format, $context),
|
||||
'aaguid' => $this->normalizer->normalize($data->aaguid, $format, $context),
|
||||
'credentialPublicKey' => Base64UrlSafe::encodeUnpadded($data->credentialPublicKey),
|
||||
'userHandle' => Base64UrlSafe::encodeUnpadded($data->userHandle),
|
||||
'counter' => $data->counter,
|
||||
'otherUI' => $data->otherUI,
|
||||
'backupEligible' => $data->backupEligible,
|
||||
'backupStatus' => $data->backupStatus,
|
||||
'uvInitialized' => $data->uvInitialized,
|
||||
];
|
||||
|
||||
return array_filter($result, static fn ($value): bool => $value !== null);
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof CredentialRecord;
|
||||
}
|
||||
}
|
||||
42
vendor/web-auth/webauthn-lib/src/Denormalizer/ExtensionDescriptorDenormalizer.php
vendored
Normal file
42
vendor/web-auth/webauthn-lib/src/Denormalizer/ExtensionDescriptorDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\MetadataService\Statement\ExtensionDescriptor;
|
||||
|
||||
final class ExtensionDescriptorDenormalizer implements DenormalizerInterface
|
||||
{
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{id: string, tag?: ?int, data?: ?string, failIfUnknown?: bool, fail_if_unknown?: bool} $data */
|
||||
if (array_key_exists('fail_if_unknown', $data)) {
|
||||
$data['failIfUnknown'] = $data['fail_if_unknown'];
|
||||
unset($data['fail_if_unknown']);
|
||||
}
|
||||
|
||||
return ExtensionDescriptor::create(...$data);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === ExtensionDescriptor::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
ExtensionDescriptor::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
64
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialDenormalizer.php
vendored
Normal file
64
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\AuthenticatorResponse;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\PublicKeyCredential;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
final class PublicKeyCredentialDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{id?: string, rawId: string, type: string, response: array<string, mixed>} $data */
|
||||
if (! array_key_exists('id', $data)) {
|
||||
return $data;
|
||||
}
|
||||
$id = Base64UrlSafe::decodeNoPadding($data['id']);
|
||||
$rawId = Base64::decode($data['rawId']);
|
||||
hash_equals($id, $rawId) || throw InvalidDataException::create($data, 'Invalid ID');
|
||||
$data['rawId'] = $rawId;
|
||||
|
||||
/** @var AuthenticatorResponse $response */
|
||||
$response = $this->denormalizer->denormalize(
|
||||
$data['response'],
|
||||
AuthenticatorResponse::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
return PublicKeyCredential::create($data['type'], $data['rawId'], $response);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === PublicKeyCredential::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredential::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
47
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialDescriptorNormalizer.php
vendored
Normal file
47
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialDescriptorNormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use function count;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\PublicKeyCredentialDescriptor;
|
||||
|
||||
final class PublicKeyCredentialDescriptorNormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof PublicKeyCredentialDescriptor);
|
||||
$result = [
|
||||
'type' => $data->type,
|
||||
'id' => Base64UrlSafe::encodeUnpadded($data->id),
|
||||
];
|
||||
if (count($data->transports) !== 0) {
|
||||
$result['transports'] = $data->transports;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof PublicKeyCredentialDescriptor;
|
||||
}
|
||||
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialDescriptor::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
216
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
vendored
Normal file
216
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialOptionsDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use function count;
|
||||
use function in_array;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Exception\BadMethodCallException;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\AuthenticationExtensions\AuthenticationExtensions;
|
||||
use Webauthn\AuthenticatorSelectionCriteria;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
use Webauthn\PublicKeyCredentialDescriptor;
|
||||
use Webauthn\PublicKeyCredentialParameters;
|
||||
use Webauthn\PublicKeyCredentialRequestOptions;
|
||||
use Webauthn\PublicKeyCredentialRpEntity;
|
||||
use Webauthn\PublicKeyCredentialUserEntity;
|
||||
|
||||
final class PublicKeyCredentialOptionsDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface, NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use DenormalizerAwareTrait;
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{challenge?: string, rp?: array<string, mixed>, user?: array<string, mixed>, pubKeyCredParams?: list<array<string, mixed>>, authenticatorSelection?: array<string, mixed>, attestation?: string, excludeCredentials?: list<array{id: string, type?: string, transports?: list<string>}>, allowCredentials?: list<array{id: string, type?: string, transports?: list<string>}>, timeout?: int<1, max>, extensions?: array<string, mixed>, hints?: list<string>, rpId?: string, userVerification?: string} $data */
|
||||
if (array_key_exists('challenge', $data)) {
|
||||
$data['challenge'] = Base64UrlSafe::decodeNoPadding($data['challenge']);
|
||||
}
|
||||
|
||||
foreach (['allowCredentials', 'excludeCredentials'] as $key) {
|
||||
if (array_key_exists($key, $data)) {
|
||||
/** @var list<array{id: string, type?: string, transports?: list<string>}> $credentials */
|
||||
$credentials = $data[$key] ?? [];
|
||||
foreach ($credentials as $item => $allowCredential) {
|
||||
$data[$key][$item]['id'] = Base64UrlSafe::decodeNoPadding($allowCredential['id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($type === PublicKeyCredentialCreationOptions::class) {
|
||||
/** @var PublicKeyCredentialRpEntity $rp */
|
||||
$rp = ! isset($data['rp']) ? PublicKeyCredentialRpEntity::create() : $this->denormalizer->denormalize(
|
||||
$data['rp'],
|
||||
PublicKeyCredentialRpEntity::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var PublicKeyCredentialUserEntity $user */
|
||||
$user = $this->denormalizer->denormalize(
|
||||
$data['user'] ?? [],
|
||||
PublicKeyCredentialUserEntity::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var list<PublicKeyCredentialParameters> $pubKeyCredParams */
|
||||
$pubKeyCredParams = ! isset($data['pubKeyCredParams']) ? [] : $this->denormalizer->denormalize(
|
||||
$data['pubKeyCredParams'],
|
||||
PublicKeyCredentialParameters::class . '[]',
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var ?AuthenticatorSelectionCriteria $authenticatorSelection */
|
||||
$authenticatorSelection = ! isset($data['authenticatorSelection']) ? null : $this->denormalizer->denormalize(
|
||||
$data['authenticatorSelection'],
|
||||
AuthenticatorSelectionCriteria::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var list<PublicKeyCredentialDescriptor> $excludeCredentials */
|
||||
$excludeCredentials = ! isset($data['excludeCredentials']) ? [] : $this->denormalizer->denormalize(
|
||||
$data['excludeCredentials'],
|
||||
PublicKeyCredentialDescriptor::class . '[]',
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var ?AuthenticationExtensions $extensions */
|
||||
$extensions = ! isset($data['extensions']) ? null : $this->denormalizer->denormalize(
|
||||
$data['extensions'],
|
||||
AuthenticationExtensions::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
return PublicKeyCredentialCreationOptions::create(
|
||||
$rp,
|
||||
$user,
|
||||
$data['challenge'] ?? '',
|
||||
$pubKeyCredParams,
|
||||
$authenticatorSelection,
|
||||
$data['attestation'] ?? null,
|
||||
$excludeCredentials,
|
||||
$data['timeout'] ?? null,
|
||||
$extensions,
|
||||
$data['hints'] ?? [],
|
||||
);
|
||||
}
|
||||
if ($type === PublicKeyCredentialRequestOptions::class) {
|
||||
/** @var list<PublicKeyCredentialDescriptor> $allowCredentials */
|
||||
$allowCredentials = ! isset($data['allowCredentials']) ? [] : $this->denormalizer->denormalize(
|
||||
$data['allowCredentials'],
|
||||
PublicKeyCredentialDescriptor::class . '[]',
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
/** @var ?AuthenticationExtensions $extensions */
|
||||
$extensions = ! isset($data['extensions']) ? null : $this->denormalizer->denormalize(
|
||||
$data['extensions'],
|
||||
AuthenticationExtensions::class,
|
||||
$format,
|
||||
$context
|
||||
);
|
||||
|
||||
return PublicKeyCredentialRequestOptions::create(
|
||||
$data['challenge'] ?? '',
|
||||
$data['rpId'] ?? null,
|
||||
$allowCredentials,
|
||||
$data['userVerification'] ?? null,
|
||||
$data['timeout'] ?? null,
|
||||
$extensions,
|
||||
$data['hints'] ?? [],
|
||||
);
|
||||
}
|
||||
throw new BadMethodCallException('Unsupported type');
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return in_array(
|
||||
$type,
|
||||
[PublicKeyCredentialCreationOptions::class, PublicKeyCredentialRequestOptions::class],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof PublicKeyCredentialCreationOptions || $data instanceof PublicKeyCredentialRequestOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialCreationOptions::class => true,
|
||||
PublicKeyCredentialRequestOptions::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $object, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert(
|
||||
$object instanceof PublicKeyCredentialCreationOptions || $object instanceof PublicKeyCredentialRequestOptions
|
||||
);
|
||||
$json = [
|
||||
'challenge' => Base64UrlSafe::encodeUnpadded($object->challenge),
|
||||
'timeout' => $object->timeout,
|
||||
'extensions' => $object->extensions->count() === 0 ? null : $this->normalizer->normalize(
|
||||
$object->extensions,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
'hints' => count($object->hints) === 0 ? null : $object->hints,
|
||||
];
|
||||
|
||||
if ($object instanceof PublicKeyCredentialCreationOptions) {
|
||||
$json = [
|
||||
...$json,
|
||||
'rp' => $this->normalizer->normalize($object->rp, $format, $context),
|
||||
'user' => $this->normalizer->normalize($object->user, $format, $context),
|
||||
'pubKeyCredParams' => $this->normalizer->normalize(
|
||||
$object->pubKeyCredParams,
|
||||
PublicKeyCredentialParameters::class . '[]',
|
||||
$context
|
||||
),
|
||||
'authenticatorSelection' => $object->authenticatorSelection === null ? null : $this->normalizer->normalize(
|
||||
$object->authenticatorSelection,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
'attestation' => $object->attestation,
|
||||
'excludeCredentials' => $this->normalizer->normalize($object->excludeCredentials, $format, $context),
|
||||
];
|
||||
}
|
||||
if ($object instanceof PublicKeyCredentialRequestOptions) {
|
||||
$json = [
|
||||
...$json,
|
||||
'rpId' => $object->rpId,
|
||||
'allowCredentials' => $this->normalizer->normalize($object->allowCredentials, $format, $context),
|
||||
'userVerification' => $object->userVerification,
|
||||
];
|
||||
}
|
||||
|
||||
return array_filter($json, static fn ($value): bool => $value !== null);
|
||||
}
|
||||
}
|
||||
45
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialParametersDenormalizer.php
vendored
Normal file
45
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialParametersDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\PublicKeyCredentialParameters;
|
||||
|
||||
final class PublicKeyCredentialParametersDenormalizer implements DenormalizerInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{type?: string, alg?: int} $data */
|
||||
if (! array_key_exists('type', $data) || ! array_key_exists('alg', $data)) {
|
||||
throw new InvalidDataException($data, 'Missing type or alg');
|
||||
}
|
||||
|
||||
return PublicKeyCredentialParameters::create($data['type'], $data['alg']);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === PublicKeyCredentialParameters::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialParameters::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
51
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialRpEntityDenormalizer.php
vendored
Normal file
51
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialRpEntityDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\PublicKeyCredentialRpEntity;
|
||||
|
||||
final class PublicKeyCredentialRpEntityDenormalizer implements NormalizerInterface
|
||||
{
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialRpEntity::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Per W3C IDL, `PublicKeyCredentialEntity.name` is required. `PublicKeyCredentialRpEntity::$name` is deprecated
|
||||
* and removed in 6.0.0, so the name is defaulted to the Relying Party ID when it is left empty: the payload stays
|
||||
* well-formed for the clients that refuse to start a ceremony without it, and callers no longer have to set the
|
||||
* deprecated field themselves.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $object, ?string $format = null, array $context = []): ?array
|
||||
{
|
||||
assert($object instanceof PublicKeyCredentialRpEntity);
|
||||
$name = $object->name;
|
||||
$data = array_filter(
|
||||
[
|
||||
'id' => $object->id,
|
||||
'name' => $name === '' ? $object->id : $name,
|
||||
'icon' => $object->icon,
|
||||
],
|
||||
static fn (?string $value): bool => ($value !== null && $value !== ''),
|
||||
);
|
||||
|
||||
return $data === [] ? null : $data;
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof PublicKeyCredentialRpEntity;
|
||||
}
|
||||
}
|
||||
104
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php
vendored
Normal file
104
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialSourceDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Symfony\Component\Uid\Uuid;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\PublicKeyCredentialSource;
|
||||
use Webauthn\TrustPath\TrustPath;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
final class PublicKeyCredentialSourceDenormalizer implements DenormalizerInterface, DenormalizerAwareInterface, NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
use DenormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{publicKeyCredentialId: string, credentialPublicKey: string, userHandle: string, type: string, transports: string[], attestationType: string, trustPath: array<string, mixed>, aaguid: string, counter: int, otherUI?: ?array<string, mixed>, backupEligible?: ?bool, backupStatus?: ?bool, uvInitialized?: ?bool} $data */
|
||||
$keys = ['publicKeyCredentialId', 'credentialPublicKey', 'userHandle'];
|
||||
foreach ($keys as $key) {
|
||||
array_key_exists($key, $data) || throw InvalidDataException::create($data, 'Missing ' . $key);
|
||||
$data[$key] = Base64::decode($data[$key]);
|
||||
}
|
||||
|
||||
return PublicKeyCredentialSource::create(
|
||||
$data['publicKeyCredentialId'],
|
||||
$data['type'],
|
||||
$data['transports'],
|
||||
$data['attestationType'],
|
||||
$this->denormalizer->denormalize($data['trustPath'], TrustPath::class, $format, $context),
|
||||
Uuid::fromString($data['aaguid']),
|
||||
$data['credentialPublicKey'],
|
||||
$data['userHandle'],
|
||||
$data['counter'],
|
||||
$data['otherUI'] ?? null,
|
||||
$data['backupEligible'] ?? null,
|
||||
$data['backupStatus'] ?? null,
|
||||
$data['uvInitialized'] ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === PublicKeyCredentialSource::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialSource::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof PublicKeyCredentialSource);
|
||||
$result = [
|
||||
'publicKeyCredentialId' => Base64UrlSafe::encodeUnpadded($data->publicKeyCredentialId),
|
||||
'type' => $data->type,
|
||||
'transports' => $data->transports,
|
||||
'attestationType' => $data->attestationType,
|
||||
'trustPath' => $this->normalizer->normalize($data->trustPath, $format, $context),
|
||||
'aaguid' => $this->normalizer->normalize($data->aaguid, $format, $context),
|
||||
'credentialPublicKey' => Base64UrlSafe::encodeUnpadded($data->credentialPublicKey),
|
||||
'userHandle' => Base64UrlSafe::encodeUnpadded($data->userHandle),
|
||||
'counter' => $data->counter,
|
||||
'otherUI' => $data->otherUI,
|
||||
'backupEligible' => $data->backupEligible,
|
||||
'backupStatus' => $data->backupStatus,
|
||||
'uvInitialized' => $data->uvInitialized,
|
||||
];
|
||||
|
||||
return array_filter($result, static fn ($value): bool => $value !== null);
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof PublicKeyCredentialSource;
|
||||
}
|
||||
}
|
||||
68
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php
vendored
Normal file
68
vendor/web-auth/webauthn-lib/src/Denormalizer/PublicKeyCredentialUserEntityDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\Exception\InvalidDataException;
|
||||
use Webauthn\PublicKeyCredentialUserEntity;
|
||||
use Webauthn\Util\Base64;
|
||||
|
||||
final class PublicKeyCredentialUserEntityDenormalizer implements DenormalizerInterface, NormalizerInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidDataException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{id?: string, name: string, displayName: string} $data */
|
||||
if (! array_key_exists('id', $data)) {
|
||||
return $data;
|
||||
}
|
||||
$data['id'] = Base64::decode($data['id']);
|
||||
|
||||
return PublicKeyCredentialUserEntity::create($data['name'], $data['id'], $data['displayName']);
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === PublicKeyCredentialUserEntity::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
PublicKeyCredentialUserEntity::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $object, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($object instanceof PublicKeyCredentialUserEntity);
|
||||
return [
|
||||
'id' => Base64UrlSafe::encodeUnpadded($object->id),
|
||||
'name' => $object->name,
|
||||
'displayName' => $object->displayName,
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof PublicKeyCredentialUserEntity;
|
||||
}
|
||||
}
|
||||
65
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalAllAcceptedCredentialsDenormalizer.php
vendored
Normal file
65
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalAllAcceptedCredentialsDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\PublicKeyCredentialDescriptor;
|
||||
use Webauthn\Signal\AllAcceptedCredentials;
|
||||
|
||||
class SignalAllAcceptedCredentialsDenormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
AllAcceptedCredentials::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof AllAcceptedCredentials);
|
||||
|
||||
/** @var array<string, mixed> $normalized_rp */
|
||||
$normalized_rp = $this->normalizer->normalize($data->rp, $format, $context);
|
||||
|
||||
/** @var array<string, mixed> $normalized_user */
|
||||
$normalized_user = $this->normalizer->normalize($data->user, $format, $context);
|
||||
|
||||
/** @var array<int, array{id: string, type: string}> $normalized_credentials */
|
||||
$normalized_credentials = array_map(
|
||||
fn (PublicKeyCredentialDescriptor $credential) => $this->normalizer->normalize(
|
||||
$credential,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
$data->allAcceptedCredentials
|
||||
);
|
||||
|
||||
return [
|
||||
'rpId' => $normalized_rp['id'],
|
||||
'userId' => $normalized_user['id'],
|
||||
'allAcceptedCredentialIds' => array_map(
|
||||
static fn (array $credential): string => $credential['id'],
|
||||
$normalized_credentials
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof AllAcceptedCredentials;
|
||||
}
|
||||
}
|
||||
52
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalCurrentUserDetailsDenormalizer.php
vendored
Normal file
52
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalCurrentUserDetailsDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\Signal\CurrentUserDetails;
|
||||
|
||||
class SignalCurrentUserDetailsDenormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
CurrentUserDetails::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof CurrentUserDetails);
|
||||
|
||||
/** @var array<string, mixed> $normalized_rp */
|
||||
$normalized_rp = $this->normalizer->normalize($data->rp, $format, $context);
|
||||
|
||||
/** @var array<string, mixed> $normalized_user */
|
||||
$normalized_user = $this->normalizer->normalize($data->user, $format, $context);
|
||||
|
||||
return [
|
||||
'rpId' => $normalized_rp['id'],
|
||||
'userId' => $normalized_user['id'],
|
||||
'name' => $normalized_user['name'],
|
||||
'displayName' => $normalized_user['displayName'],
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof CurrentUserDetails;
|
||||
}
|
||||
}
|
||||
50
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalUnknownCredentialDenormalizer.php
vendored
Normal file
50
vendor/web-auth/webauthn-lib/src/Denormalizer/SignalUnknownCredentialDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\Signal\UnknownCredential;
|
||||
|
||||
class SignalUnknownCredentialDenormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
UnknownCredential::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof UnknownCredential);
|
||||
|
||||
/** @var array<string, mixed> $normalized_rp */
|
||||
$normalized_rp = $this->normalizer->normalize($data->rp, $format, $context);
|
||||
|
||||
/** @var array<string, mixed> $normalized_credential */
|
||||
$normalized_credential = $this->normalizer->normalize($data->credential, $format, $context);
|
||||
|
||||
return [
|
||||
'rpId' => $normalized_rp['id'],
|
||||
'credentialId' => $normalized_credential['id'],
|
||||
];
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof UnknownCredential;
|
||||
}
|
||||
}
|
||||
70
vendor/web-auth/webauthn-lib/src/Denormalizer/TrustPathDenormalizer.php
vendored
Normal file
70
vendor/web-auth/webauthn-lib/src/Denormalizer/TrustPathDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function array_key_exists;
|
||||
use function assert;
|
||||
use function is_array;
|
||||
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\Exception\InvalidTrustPathException;
|
||||
use Webauthn\TrustPath\CertificateTrustPath;
|
||||
use Webauthn\TrustPath\EmptyTrustPath;
|
||||
use Webauthn\TrustPath\TrustPath;
|
||||
|
||||
final class TrustPathDenormalizer implements DenormalizerInterface, NormalizerInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidTrustPathException
|
||||
*/
|
||||
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
|
||||
{
|
||||
/** @var array{x5c?: list<string>, type?: string} $data */
|
||||
return match (true) {
|
||||
array_key_exists('x5c', $data) && is_array($data['x5c']) => CertificateTrustPath::create($data['x5c']),
|
||||
$data === [], isset($data['type']) && $data['type'] === EmptyTrustPath::class => EmptyTrustPath::create(),
|
||||
default => throw new InvalidTrustPathException('Unsupported trust path type'),
|
||||
};
|
||||
}
|
||||
|
||||
public function supportsDenormalization(
|
||||
mixed $data,
|
||||
string $type,
|
||||
?string $format = null,
|
||||
array $context = []
|
||||
): bool {
|
||||
return $type === TrustPath::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
TrustPath::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof TrustPath);
|
||||
return match (true) {
|
||||
$data instanceof CertificateTrustPath => [
|
||||
'x5c' => $data->certificates,
|
||||
],
|
||||
$data instanceof EmptyTrustPath => [],
|
||||
default => throw new InvalidTrustPathException('Unsupported trust path type'),
|
||||
};
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof TrustPath;
|
||||
}
|
||||
}
|
||||
63
vendor/web-auth/webauthn-lib/src/Denormalizer/UrlNormalizer.php
vendored
Normal file
63
vendor/web-auth/webauthn-lib/src/Denormalizer/UrlNormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use const FILTER_VALIDATE_URL;
|
||||
use function filter_var;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Throwable;
|
||||
use Webauthn\Url;
|
||||
|
||||
/**
|
||||
* Normalizes Url objects to absolute HTTPS URLs.
|
||||
* Either returns the URL directly if already absolute, or generates it from a Symfony route.
|
||||
*/
|
||||
final readonly class UrlNormalizer implements NormalizerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ?UrlGeneratorInterface $urlGenerator = null,
|
||||
) {
|
||||
}
|
||||
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): string
|
||||
{
|
||||
assert($data instanceof Url);
|
||||
|
||||
// If no URL generator available, return the path as-is
|
||||
if ($this->urlGenerator === null) {
|
||||
return $data->path;
|
||||
}
|
||||
|
||||
// If the path is already a valid absolute URL (https://...), return it directly
|
||||
if (filter_var($data->path, FILTER_VALIDATE_URL) !== false) {
|
||||
return $data->path;
|
||||
}
|
||||
|
||||
// Otherwise, try to generate an absolute URL from a Symfony route name
|
||||
try {
|
||||
return $this->urlGenerator->generate($data->path, $data->params, UrlGeneratorInterface::ABSOLUTE_URL);
|
||||
} catch (Throwable) {
|
||||
// If the URL cannot be generated, return the path as is
|
||||
return $data->path;
|
||||
}
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof Url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
Url::class => true,
|
||||
];
|
||||
}
|
||||
}
|
||||
50
vendor/web-auth/webauthn-lib/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php
vendored
Normal file
50
vendor/web-auth/webauthn-lib/src/Denormalizer/VerificationMethodANDCombinationsDenormalizer.php
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use function assert;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Webauthn\MetadataService\Statement\VerificationMethodANDCombinations;
|
||||
use Webauthn\MetadataService\Statement\VerificationMethodDescriptor;
|
||||
|
||||
final class VerificationMethodANDCombinationsDenormalizer implements NormalizerInterface, NormalizerAwareInterface
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
/**
|
||||
* @return array<class-string, bool>
|
||||
*/
|
||||
public function getSupportedTypes(?string $format): array
|
||||
{
|
||||
return [
|
||||
VerificationMethodANDCombinations::class => true,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array<string, mixed>>
|
||||
*/
|
||||
public function normalize(mixed $data, ?string $format = null, array $context = []): array
|
||||
{
|
||||
assert($data instanceof VerificationMethodANDCombinations);
|
||||
|
||||
/** @var array<array<string, mixed>> */
|
||||
return array_map(
|
||||
fn (VerificationMethodDescriptor $verificationMethod) => $this->normalizer->normalize(
|
||||
$verificationMethod,
|
||||
$format,
|
||||
$context
|
||||
),
|
||||
$data->verificationMethods
|
||||
);
|
||||
}
|
||||
|
||||
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
|
||||
{
|
||||
return $data instanceof VerificationMethodANDCombinations;
|
||||
}
|
||||
}
|
||||
100
vendor/web-auth/webauthn-lib/src/Denormalizer/WebauthnSerializerFactory.php
vendored
Normal file
100
vendor/web-auth/webauthn-lib/src/Denormalizer/WebauthnSerializerFactory.php
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\Denormalizer;
|
||||
|
||||
use RuntimeException;
|
||||
use function sprintf;
|
||||
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
|
||||
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
|
||||
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
|
||||
use Symfony\Component\Serializer\Normalizer\UidNormalizer;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
|
||||
final readonly class WebauthnSerializerFactory
|
||||
{
|
||||
private const PACKAGE_SYMFONY_PROPERTY_INFO = 'symfony/property-info';
|
||||
|
||||
private const PACKAGE_SYMFONY_SERIALIZER = 'symfony/serializer';
|
||||
|
||||
private const PACKAGE_PHPDOCUMENTOR_REFLECTION_DOCBLOCK = 'phpdocumentor/reflection-docblock';
|
||||
|
||||
public function __construct(
|
||||
private AttestationStatementSupportManager $attestationStatementSupportManager
|
||||
) {
|
||||
}
|
||||
|
||||
public function create(): SerializerInterface
|
||||
{
|
||||
foreach (self::getRequiredSerializerClasses() as $class => $package) {
|
||||
if (! class_exists($class)) {
|
||||
throw new RuntimeException(sprintf(
|
||||
'The class "%s" is required. Please install the package "%s" to use this feature.',
|
||||
$class,
|
||||
$package
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$denormalizers = [
|
||||
new ExtensionDescriptorDenormalizer(),
|
||||
new VerificationMethodANDCombinationsDenormalizer(),
|
||||
new AuthenticationExtensionNormalizer(),
|
||||
new PublicKeyCredentialDescriptorNormalizer(),
|
||||
new AttestedCredentialDataNormalizer(),
|
||||
new UrlNormalizer(),
|
||||
new AttestationObjectDenormalizer(),
|
||||
new AttestationStatementDenormalizer($this->attestationStatementSupportManager),
|
||||
new AuthenticationExtensionsDenormalizer(),
|
||||
new AuthenticatorAssertionResponseDenormalizer(),
|
||||
new AuthenticatorAttestationResponseDenormalizer(),
|
||||
new AuthenticatorDataDenormalizer(),
|
||||
new AuthenticatorResponseDenormalizer(),
|
||||
new CollectedClientDataDenormalizer(),
|
||||
new PublicKeyCredentialDenormalizer(),
|
||||
new PublicKeyCredentialOptionsDenormalizer(),
|
||||
new CredentialRecordDenormalizer(),
|
||||
new PublicKeyCredentialSourceDenormalizer(),
|
||||
new PublicKeyCredentialRpEntityDenormalizer(),
|
||||
new PublicKeyCredentialUserEntityDenormalizer(),
|
||||
new SignalAllAcceptedCredentialsDenormalizer(),
|
||||
new SignalCurrentUserDetailsDenormalizer(),
|
||||
new SignalUnknownCredentialDenormalizer(),
|
||||
new TrustPathDenormalizer(),
|
||||
new UidNormalizer(),
|
||||
new ArrayDenormalizer(),
|
||||
new ObjectNormalizer(
|
||||
propertyTypeExtractor: new PropertyInfoExtractor(typeExtractors: [
|
||||
new PhpDocExtractor(),
|
||||
new ReflectionExtractor(),
|
||||
])
|
||||
),
|
||||
];
|
||||
|
||||
return new Serializer($denormalizers, [new JsonEncoder()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<class-string, string>
|
||||
*/
|
||||
private static function getRequiredSerializerClasses(): array
|
||||
{
|
||||
return [
|
||||
UidNormalizer::class => self::PACKAGE_SYMFONY_SERIALIZER,
|
||||
ArrayDenormalizer::class => self::PACKAGE_SYMFONY_SERIALIZER,
|
||||
AbstractNormalizer::class => self::PACKAGE_SYMFONY_SERIALIZER,
|
||||
PropertyInfoExtractor::class => self::PACKAGE_SYMFONY_PROPERTY_INFO,
|
||||
PhpDocExtractor::class => self::PACKAGE_PHPDOCUMENTOR_REFLECTION_DOCBLOCK,
|
||||
ReflectionExtractor::class => self::PACKAGE_SYMFONY_PROPERTY_INFO,
|
||||
JsonEncoder::class => self::PACKAGE_SYMFONY_SERIALIZER,
|
||||
Serializer::class => self::PACKAGE_SYMFONY_SERIALIZER,
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue