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
66
vendor/web-auth/webauthn-lib/src/MetadataService/Service/ChainedMetadataServices.php
vendored
Normal file
66
vendor/web-auth/webauthn-lib/src/MetadataService/Service/ChainedMetadataServices.php
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class ChainedMetadataServices implements MetadataService
|
||||
{
|
||||
/**
|
||||
* @var MetadataService[]
|
||||
*/
|
||||
private array $services = [];
|
||||
|
||||
public function __construct(MetadataService ...$services)
|
||||
{
|
||||
foreach ($services as $service) {
|
||||
$this->addServices($service);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create(MetadataService ...$services): self
|
||||
{
|
||||
return new self(...$services);
|
||||
}
|
||||
|
||||
public function addServices(MetadataService ...$services): self
|
||||
{
|
||||
foreach ($services as $service) {
|
||||
$this->services[] = $service;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
foreach ($this->services as $service) {
|
||||
yield from $service->list();
|
||||
}
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
foreach ($this->services as $service) {
|
||||
if ($service->has($aaguid)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
foreach ($this->services as $service) {
|
||||
if ($service->has($aaguid)) {
|
||||
return $service->get($aaguid);
|
||||
}
|
||||
}
|
||||
|
||||
throw MissingMetadataStatementException::create($aaguid);
|
||||
}
|
||||
}
|
||||
128
vendor/web-auth/webauthn-lib/src/MetadataService/Service/DistantResourceMetadataService.php
vendored
Normal file
128
vendor/web-auth/webauthn-lib/src/MetadataService/Service/DistantResourceMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use function sprintf;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\MetadataStatementFound;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\MetadataStatementLoadingException;
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class DistantResourceMetadataService implements MetadataService, CanDispatchEvents
|
||||
{
|
||||
private ?MetadataStatement $statement = null;
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
private readonly SerializerInterface $serializer;
|
||||
|
||||
/**
|
||||
* @param array<string, string> $additionalHeaderParameters
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly HttpClientInterface $httpClient,
|
||||
private readonly string $uri,
|
||||
private readonly bool $isBase64Encoded = false,
|
||||
private readonly array $additionalHeaderParameters = [],
|
||||
?SerializerInterface $serializer = null,
|
||||
) {
|
||||
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
|
||||
AttestationStatementSupportManager::create()
|
||||
))->create();
|
||||
$this->dispatcher = new NullEventDispatcher();
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $additionalHeaderParameters
|
||||
*/
|
||||
public static function create(
|
||||
HttpClientInterface $httpClient,
|
||||
string $uri,
|
||||
bool $isBase64Encoded = false,
|
||||
array $additionalHeaderParameters = [],
|
||||
?SerializerInterface $serializer = null
|
||||
): self {
|
||||
return new self($httpClient, $uri, $isBase64Encoded, $additionalHeaderParameters, $serializer);
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
$aaguid = $this->statement->aaguid;
|
||||
if ($aaguid === null) {
|
||||
yield from [];
|
||||
} else {
|
||||
yield from [$aaguid];
|
||||
}
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
|
||||
return $aaguid === $this->statement->aaguid;
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
|
||||
if ($aaguid === $this->statement->aaguid) {
|
||||
$this->dispatcher->dispatch(MetadataStatementFound::create($this->statement));
|
||||
|
||||
return $this->statement;
|
||||
}
|
||||
|
||||
throw MissingMetadataStatementException::create($aaguid);
|
||||
}
|
||||
|
||||
private function loadData(): void
|
||||
{
|
||||
if ($this->statement !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->fetch();
|
||||
if ($this->isBase64Encoded) {
|
||||
$content = Base64::decode($content, true);
|
||||
}
|
||||
$this->statement = $this->serializer->deserialize($content, MetadataStatement::class, JsonEncoder::FORMAT);
|
||||
}
|
||||
|
||||
private function fetch(): string
|
||||
{
|
||||
$response = $this->httpClient->request('GET', $this->uri, [
|
||||
'headers' => $this->additionalHeaderParameters,
|
||||
]);
|
||||
$response->getStatusCode() === 200 || throw MetadataStatementLoadingException::create(sprintf(
|
||||
'Unable to contact the server. Response code is %d',
|
||||
$response->getStatusCode()
|
||||
));
|
||||
|
||||
$content = $response->getContent();
|
||||
$content !== '' || throw MetadataStatementLoadingException::create(
|
||||
'Unable to contact the server. The response has no content'
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
236
vendor/web-auth/webauthn-lib/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php
vendored
Normal file
236
vendor/web-auth/webauthn-lib/src/MetadataService/Service/FidoAllianceCompliantMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function array_key_exists;
|
||||
use function is_array;
|
||||
use Jose\Component\Core\AlgorithmManager;
|
||||
use Jose\Component\KeyManagement\JWKFactory;
|
||||
use Jose\Component\Signature\Algorithm\ES256;
|
||||
use Jose\Component\Signature\Algorithm\RS256;
|
||||
use Jose\Component\Signature\JWSVerifier;
|
||||
use Jose\Component\Signature\Serializer\CompactSerializer;
|
||||
use LogicException;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use function sprintf;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
use Throwable;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\MetadataStatementFound;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\MetadataStatementLoadingException;
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\CertificateChain\CertificateChainValidator;
|
||||
use Webauthn\MetadataService\CertificateChain\CertificateToolbox;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
use Webauthn\MetadataService\Statement\StatusReport;
|
||||
|
||||
final class FidoAllianceCompliantMetadataService implements MetadataService, CanDispatchEvents
|
||||
{
|
||||
private bool $loaded = false;
|
||||
|
||||
/**
|
||||
* @var MetadataStatement[]
|
||||
*/
|
||||
private array $statements = [];
|
||||
|
||||
/**
|
||||
* @var array<string, StatusReport[]>
|
||||
*/
|
||||
private array $statusReports = [];
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
private readonly SerializerInterface $serializer;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $additionalHeaderParameters
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly HttpClientInterface $httpClient,
|
||||
private readonly string $uri,
|
||||
private readonly array $additionalHeaderParameters = [],
|
||||
private readonly ?CertificateChainValidator $certificateChainValidator = null,
|
||||
private readonly ?string $rootCertificateUri = null,
|
||||
?SerializerInterface $serializer = null,
|
||||
) {
|
||||
if (! class_exists(CompactSerializer::class)) {
|
||||
throw new LogicException(
|
||||
'The "web-token/jwt-library" package is required to use this service. Please run "composer require web-token/jwt-library".'
|
||||
);
|
||||
}
|
||||
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
|
||||
AttestationStatementSupportManager::create()
|
||||
))->create();
|
||||
$this->dispatcher = new NullEventDispatcher();
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $additionalHeaderParameters
|
||||
*/
|
||||
public static function create(
|
||||
HttpClientInterface $httpClient,
|
||||
string $uri,
|
||||
array $additionalHeaderParameters = [],
|
||||
?CertificateChainValidator $certificateChainValidator = null,
|
||||
?string $rootCertificateUri = null,
|
||||
?SerializerInterface $serializer = null,
|
||||
): self {
|
||||
return new self(
|
||||
$httpClient,
|
||||
$uri,
|
||||
$additionalHeaderParameters,
|
||||
$certificateChainValidator,
|
||||
$rootCertificateUri,
|
||||
$serializer,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function list(): iterable
|
||||
{
|
||||
$this->loadData();
|
||||
|
||||
yield from array_keys($this->statements);
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
$this->loadData();
|
||||
|
||||
return array_key_exists($aaguid, $this->statements);
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
$this->loadData();
|
||||
array_key_exists($aaguid, $this->statements) || throw MissingMetadataStatementException::create($aaguid);
|
||||
$mds = $this->statements[$aaguid];
|
||||
$this->dispatcher->dispatch(MetadataStatementFound::create($mds));
|
||||
|
||||
return $mds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return StatusReport[]
|
||||
*/
|
||||
public function getStatusReports(string $aaguid): iterable
|
||||
{
|
||||
$this->loadData();
|
||||
|
||||
return $this->statusReports[$aaguid] ?? [];
|
||||
}
|
||||
|
||||
private function loadData(): void
|
||||
{
|
||||
if ($this->loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = $this->fetch($this->uri, $this->additionalHeaderParameters);
|
||||
$jwtCertificates = [];
|
||||
try {
|
||||
$payload = $this->getJwsPayload($content, $jwtCertificates);
|
||||
$this->validateCertificates(...$jwtCertificates);
|
||||
/** @var MetadataBLOBPayload $blob */
|
||||
$blob = $this->serializer->deserialize($payload, MetadataBLOBPayload::class, JsonEncoder::FORMAT);
|
||||
foreach ($blob->entries as $entry) {
|
||||
$mds = $entry->metadataStatement;
|
||||
if ($mds !== null && $entry->aaguid !== null) {
|
||||
$this->statements[$entry->aaguid] = $mds;
|
||||
$this->statusReports[$entry->aaguid] = $entry->statusReports;
|
||||
}
|
||||
}
|
||||
} catch (Throwable) {
|
||||
// Nothing to do
|
||||
} finally {
|
||||
$this->loaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $headerParameters
|
||||
*/
|
||||
private function fetch(string $uri, array $headerParameters): string
|
||||
{
|
||||
$response = $this->httpClient->request('GET', $uri, [
|
||||
'headers' => $headerParameters,
|
||||
]);
|
||||
$response->getStatusCode() === 200 || throw MetadataStatementLoadingException::create(sprintf(
|
||||
'Unable to contact the server. Response code is %d',
|
||||
$response->getStatusCode()
|
||||
));
|
||||
|
||||
$content = $response->getContent();
|
||||
$content !== '' || throw MetadataStatementLoadingException::create(
|
||||
'Unable to contact the server. The response has no content'
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $rootCertificates
|
||||
*/
|
||||
private function getJwsPayload(string $token, array &$rootCertificates): string
|
||||
{
|
||||
$jws = (new CompactSerializer())->unserialize($token);
|
||||
$jws->countSignatures() === 1 || throw MetadataStatementLoadingException::create(
|
||||
'Invalid response from the metadata service. Only one signature shall be present.'
|
||||
);
|
||||
$signature = $jws->getSignature(0);
|
||||
$payload = $jws->getPayload();
|
||||
$payload !== '' || throw MetadataStatementLoadingException::create(
|
||||
'Invalid response from the metadata service. The token payload is empty.'
|
||||
);
|
||||
$header = $signature->getProtectedHeader();
|
||||
array_key_exists('alg', $header) || throw MetadataStatementLoadingException::create(
|
||||
'The "alg" parameter is missing.'
|
||||
);
|
||||
array_key_exists('x5c', $header) || throw MetadataStatementLoadingException::create(
|
||||
'The "x5c" parameter is missing.'
|
||||
);
|
||||
is_array($header['x5c']) || throw MetadataStatementLoadingException::create(
|
||||
'The "x5c" parameter should be an array.'
|
||||
);
|
||||
/** @var string[] $x5c */
|
||||
$x5c = $header['x5c'];
|
||||
$key = JWKFactory::createFromX5C($x5c);
|
||||
$rootCertificates = $x5c;
|
||||
|
||||
$verifier = new JWSVerifier(new AlgorithmManager([new ES256(), new RS256()]));
|
||||
$isValid = $verifier->verifyWithKey($jws, $key, 0);
|
||||
$isValid || throw MetadataStatementLoadingException::create(
|
||||
'Invalid response from the metadata service. The token signature is invalid.'
|
||||
);
|
||||
$payload = $jws->getPayload();
|
||||
$payload !== null || throw MetadataStatementLoadingException::create(
|
||||
'Invalid response from the metadata service. The payload is missing.'
|
||||
);
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
private function validateCertificates(string ...$untrustedCertificates): void
|
||||
{
|
||||
if ($this->certificateChainValidator === null || $this->rootCertificateUri === null) {
|
||||
return;
|
||||
}
|
||||
$untrustedCertificates = CertificateToolbox::fixPEMStructures($untrustedCertificates);
|
||||
$rootCertificate = CertificateToolbox::convertDERToPEM($this->fetch($this->rootCertificateUri, []));
|
||||
$this->certificateChainValidator->check($untrustedCertificates, [$rootCertificate]);
|
||||
}
|
||||
}
|
||||
78
vendor/web-auth/webauthn-lib/src/MetadataService/Service/FolderResourceMetadataService.php
vendored
Normal file
78
vendor/web-auth/webauthn-lib/src/MetadataService/Service/FolderResourceMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function assert;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use function file_get_contents;
|
||||
use InvalidArgumentException;
|
||||
use function is_array;
|
||||
use function sprintf;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Exception\MetadataStatementLoadingException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class FolderResourceMetadataService implements MetadataService
|
||||
{
|
||||
private readonly SerializerInterface $serializer;
|
||||
|
||||
public function __construct(
|
||||
private string $rootPath,
|
||||
?SerializerInterface $serializer = null,
|
||||
) {
|
||||
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
|
||||
AttestationStatementSupportManager::create()
|
||||
))->create();
|
||||
$this->rootPath = rtrim($rootPath, DIRECTORY_SEPARATOR);
|
||||
is_dir($this->rootPath) || throw new InvalidArgumentException('The given parameter is not a valid folder.');
|
||||
is_readable($this->rootPath) || throw new InvalidArgumentException(
|
||||
'The given parameter is not a valid folder.'
|
||||
);
|
||||
}
|
||||
|
||||
public static function create(string $rootPath, ?SerializerInterface $serializer = null): self
|
||||
{
|
||||
return new self($rootPath, $serializer);
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
$files = glob($this->rootPath . DIRECTORY_SEPARATOR . '*');
|
||||
is_array($files) || throw MetadataStatementLoadingException::create('Unable to read files.');
|
||||
foreach ($files as $file) {
|
||||
if (is_dir($file) || ! is_readable($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
yield basename($file);
|
||||
}
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
$filename = $this->rootPath . DIRECTORY_SEPARATOR . $aaguid;
|
||||
|
||||
return is_file($filename) && is_readable($filename);
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
$this->has($aaguid) || throw new InvalidArgumentException(sprintf(
|
||||
'The MDS with the AAGUID "%s" does not exist.',
|
||||
$aaguid
|
||||
));
|
||||
$filename = $this->rootPath . DIRECTORY_SEPARATOR . $aaguid;
|
||||
$content = file_get_contents($filename);
|
||||
assert($content !== false, 'The file exists and is readable.');
|
||||
$data = trim($content);
|
||||
$mds = $this->serializer->deserialize($data, MetadataStatement::class, JsonEncoder::FORMAT);
|
||||
$mds->aaguid !== null || throw MetadataStatementLoadingException::create('Invalid Metadata Statement.');
|
||||
|
||||
return $mds;
|
||||
}
|
||||
}
|
||||
73
vendor/web-auth/webauthn-lib/src/MetadataService/Service/InMemoryMetadataService.php
vendored
Normal file
73
vendor/web-auth/webauthn-lib/src/MetadataService/Service/InMemoryMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function array_key_exists;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\MetadataStatementFound;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class InMemoryMetadataService implements MetadataService, CanDispatchEvents
|
||||
{
|
||||
/**
|
||||
* @var MetadataStatement[]
|
||||
*/
|
||||
private array $statements = [];
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
public function __construct(MetadataStatement ...$statements)
|
||||
{
|
||||
foreach ($statements as $statement) {
|
||||
$this->addStatements($statement);
|
||||
}
|
||||
$this->dispatcher = new NullEventDispatcher();
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public static function create(MetadataStatement ...$statements): self
|
||||
{
|
||||
return new self(...$statements);
|
||||
}
|
||||
|
||||
public function addStatements(MetadataStatement ...$statements): self
|
||||
{
|
||||
foreach ($statements as $statement) {
|
||||
$aaguid = $statement->aaguid;
|
||||
if ($aaguid === null) {
|
||||
continue;
|
||||
}
|
||||
$this->statements[$aaguid] = $statement;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
yield from array_keys($this->statements);
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
return array_key_exists($aaguid, $this->statements);
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
array_key_exists($aaguid, $this->statements) || throw MissingMetadataStatementException::create($aaguid);
|
||||
$mds = $this->statements[$aaguid];
|
||||
$this->dispatcher->dispatch(MetadataStatementFound::create($mds));
|
||||
|
||||
return $mds;
|
||||
}
|
||||
}
|
||||
76
vendor/web-auth/webauthn-lib/src/MetadataService/Service/JsonMetadataService.php
vendored
Normal file
76
vendor/web-auth/webauthn-lib/src/MetadataService/Service/JsonMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function array_key_exists;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\MetadataStatementFound;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class JsonMetadataService implements MetadataService, CanDispatchEvents
|
||||
{
|
||||
/**
|
||||
* @var MetadataStatement[]
|
||||
*/
|
||||
private array $statements = [];
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
private readonly SerializerInterface $serializer;
|
||||
|
||||
/**
|
||||
* @param string[] $statements
|
||||
*/
|
||||
public function __construct(array $statements, ?SerializerInterface $serializer = null)
|
||||
{
|
||||
$this->dispatcher = new NullEventDispatcher();
|
||||
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
|
||||
AttestationStatementSupportManager::create()
|
||||
))->create();
|
||||
foreach ($statements as $statement) {
|
||||
$this->addStatement($statement);
|
||||
}
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
yield from array_keys($this->statements);
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
return array_key_exists($aaguid, $this->statements);
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
array_key_exists($aaguid, $this->statements) || throw MissingMetadataStatementException::create($aaguid);
|
||||
$mds = $this->statements[$aaguid];
|
||||
$this->dispatcher->dispatch(MetadataStatementFound::create($mds));
|
||||
|
||||
return $mds;
|
||||
}
|
||||
|
||||
private function addStatement(string $statement): void
|
||||
{
|
||||
$mds = $this->serializer->deserialize($statement, MetadataStatement::class, JsonEncoder::FORMAT);
|
||||
if ($mds->aaguid === null) {
|
||||
return;
|
||||
}
|
||||
$this->statements[$mds->aaguid] = $mds;
|
||||
}
|
||||
}
|
||||
101
vendor/web-auth/webauthn-lib/src/MetadataService/Service/LocalResourceMetadataService.php
vendored
Normal file
101
vendor/web-auth/webauthn-lib/src/MetadataService/Service/LocalResourceMetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function assert;
|
||||
use function file_get_contents;
|
||||
use ParagonIE\ConstantTime\Base64;
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Serializer\Encoder\JsonEncoder;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Webauthn\AttestationStatement\AttestationStatementSupportManager;
|
||||
use Webauthn\Denormalizer\WebauthnSerializerFactory;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\MetadataStatementFound;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\MetadataStatementLoadingException;
|
||||
use Webauthn\Exception\MissingMetadataStatementException;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
final class LocalResourceMetadataService implements MetadataService, CanDispatchEvents
|
||||
{
|
||||
private ?MetadataStatement $statement = null;
|
||||
|
||||
private EventDispatcherInterface $dispatcher;
|
||||
|
||||
private readonly SerializerInterface $serializer;
|
||||
|
||||
public function __construct(
|
||||
private readonly string $filename,
|
||||
private readonly bool $isBase64Encoded = false,
|
||||
?SerializerInterface $serializer = null,
|
||||
) {
|
||||
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
|
||||
AttestationStatementSupportManager::create()
|
||||
))->create();
|
||||
$this->dispatcher = new NullEventDispatcher();
|
||||
}
|
||||
|
||||
public static function create(
|
||||
string $filename,
|
||||
bool $isBase64Encoded = false,
|
||||
?SerializerInterface $serializer = null
|
||||
): self {
|
||||
return new self($filename, $isBase64Encoded, $serializer);
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->dispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
public function list(): iterable
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
$aaguid = $this->statement->aaguid;
|
||||
if ($aaguid === null) {
|
||||
yield from [];
|
||||
} else {
|
||||
yield from [$aaguid];
|
||||
}
|
||||
}
|
||||
|
||||
public function has(string $aaguid): bool
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
|
||||
return $aaguid === $this->statement->aaguid;
|
||||
}
|
||||
|
||||
public function get(string $aaguid): MetadataStatement
|
||||
{
|
||||
$this->loadData();
|
||||
$this->statement !== null || throw MetadataStatementLoadingException::create();
|
||||
|
||||
if ($aaguid === $this->statement->aaguid) {
|
||||
$this->dispatcher->dispatch(MetadataStatementFound::create($this->statement));
|
||||
|
||||
return $this->statement;
|
||||
}
|
||||
|
||||
throw MissingMetadataStatementException::create($aaguid);
|
||||
}
|
||||
|
||||
private function loadData(): void
|
||||
{
|
||||
if ($this->statement !== null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = file_get_contents($this->filename);
|
||||
assert($content !== false, 'The file could not be read');
|
||||
if ($this->isBase64Encoded) {
|
||||
$content = Base64::decode($content, true);
|
||||
}
|
||||
$this->statement = $this->serializer->deserialize($content, MetadataStatement::class, JsonEncoder::FORMAT);
|
||||
}
|
||||
}
|
||||
19
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataBLOBPayload.php
vendored
Normal file
19
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataBLOBPayload.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
class MetadataBLOBPayload
|
||||
{
|
||||
/**
|
||||
* @param MetadataBLOBPayloadEntry[] $entries
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $no,
|
||||
public readonly string $nextUpdate,
|
||||
public readonly ?string $legalHeader = null,
|
||||
public array $entries = [],
|
||||
) {
|
||||
}
|
||||
}
|
||||
52
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataBLOBPayloadEntry.php
vendored
Normal file
52
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataBLOBPayloadEntry.php
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use function count;
|
||||
use function is_string;
|
||||
use Webauthn\Exception\MetadataStatementLoadingException;
|
||||
use Webauthn\MetadataService\Statement\BiometricStatusReport;
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
use Webauthn\MetadataService\Statement\StatusReport;
|
||||
|
||||
class MetadataBLOBPayloadEntry
|
||||
{
|
||||
/**
|
||||
* @param StatusReport[] $statusReports
|
||||
* @param BiometricStatusReport[] $biometricStatusReports
|
||||
* @param string[] $attestationCertificateKeyIdentifiers
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $timeOfLastStatusChange,
|
||||
public array $statusReports,
|
||||
public readonly ?string $aaid = null,
|
||||
public readonly ?string $aaguid = null,
|
||||
public array $attestationCertificateKeyIdentifiers = [],
|
||||
public readonly ?MetadataStatement $metadataStatement = null,
|
||||
public readonly ?string $rogueListURL = null,
|
||||
public readonly ?string $rogueListHash = null,
|
||||
public array $biometricStatusReports = []
|
||||
) {
|
||||
if ($aaid !== null && $aaguid !== null) {
|
||||
throw MetadataStatementLoadingException::create('Authenticators cannot support both AAID and AAGUID');
|
||||
}
|
||||
if ($aaid === null && $aaguid === null && count($attestationCertificateKeyIdentifiers) === 0) {
|
||||
throw MetadataStatementLoadingException::create(
|
||||
'If neither AAID nor AAGUID are set, the attestation certificate identifier list shall not be empty'
|
||||
);
|
||||
}
|
||||
foreach ($attestationCertificateKeyIdentifiers as $attestationCertificateKeyIdentifier) {
|
||||
is_string($attestationCertificateKeyIdentifier) || throw MetadataStatementLoadingException::create(
|
||||
'Invalid attestation certificate identifier. Shall be a list of strings'
|
||||
);
|
||||
preg_match(
|
||||
'/^[0-9a-f]+$/',
|
||||
$attestationCertificateKeyIdentifier
|
||||
) === 1 || throw MetadataStatementLoadingException::create(
|
||||
'Invalid attestation certificate identifier. Shall be a list of strings'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataService.php
vendored
Normal file
19
vendor/web-auth/webauthn-lib/src/MetadataService/Service/MetadataService.php
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn\MetadataService\Service;
|
||||
|
||||
use Webauthn\MetadataService\Statement\MetadataStatement;
|
||||
|
||||
interface MetadataService
|
||||
{
|
||||
/**
|
||||
* @return string[] The list of AAGUID supported by the service
|
||||
*/
|
||||
public function list(): iterable;
|
||||
|
||||
public function has(string $aaguid): bool;
|
||||
|
||||
public function get(string $aaguid): MetadataStatement;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue