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
195
vendor/web-auth/webauthn-lib/src/AuthenticatorAttestationResponseValidator.php
vendored
Normal file
195
vendor/web-auth/webauthn-lib/src/AuthenticatorAttestationResponseValidator.php
vendored
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Webauthn;
|
||||
|
||||
use Psr\EventDispatcher\EventDispatcherInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Throwable;
|
||||
use Webauthn\CeremonyStep\CeremonyStepManager;
|
||||
use Webauthn\Event\AuthenticatorAttestationResponseValidationFailedEvent;
|
||||
use Webauthn\Event\AuthenticatorAttestationResponseValidationSucceededEvent;
|
||||
use Webauthn\Event\BackupEligibilityChangedEvent;
|
||||
use Webauthn\Event\BackupStatusChangedEvent;
|
||||
use Webauthn\Event\CanDispatchEvents;
|
||||
use Webauthn\Event\NullEventDispatcher;
|
||||
use Webauthn\Exception\AuthenticatorResponseVerificationException;
|
||||
use Webauthn\MetadataService\CanLogData;
|
||||
|
||||
class AuthenticatorAttestationResponseValidator implements CanLogData, CanDispatchEvents
|
||||
{
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private EventDispatcherInterface $eventDispatcher;
|
||||
|
||||
public function __construct(
|
||||
private readonly CeremonyStepManager $ceremonyStepManager
|
||||
) {
|
||||
$this->eventDispatcher = new NullEventDispatcher();
|
||||
$this->logger = new NullLogger();
|
||||
}
|
||||
|
||||
public static function create(CeremonyStepManager $ceremonyStepManager): self
|
||||
{
|
||||
return new self($ceremonyStepManager);
|
||||
}
|
||||
|
||||
public function setLogger(LoggerInterface $logger): void
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function setEventDispatcher(EventDispatcherInterface $eventDispatcher): void
|
||||
{
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://www.w3.org/TR/webauthn/#registering-a-new-credential
|
||||
*/
|
||||
public function check(
|
||||
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
|
||||
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
|
||||
string $host,
|
||||
): CredentialRecord {
|
||||
try {
|
||||
$this->logger->info('Checking the authenticator attestation response', [
|
||||
'authenticatorAttestationResponse' => $authenticatorAttestationResponse,
|
||||
'publicKeyCredentialCreationOptions' => $publicKeyCredentialCreationOptions,
|
||||
'host' => $host,
|
||||
]);
|
||||
|
||||
$credentialRecord = $this->createCredentialRecord(
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions
|
||||
);
|
||||
|
||||
$this->ceremonyStepManager->process(
|
||||
$credentialRecord,
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions,
|
||||
$publicKeyCredentialCreationOptions->user->id,
|
||||
$host
|
||||
);
|
||||
|
||||
// Store previous backup state values to detect changes (will be null for new credentials)
|
||||
$previousBackupEligible = $credentialRecord->backupEligible;
|
||||
$previousBackupStatus = $credentialRecord->backupStatus;
|
||||
|
||||
$credentialRecord->counter = $authenticatorAttestationResponse->attestationObject->authData->signCount;
|
||||
$credentialRecord->backupEligible = $authenticatorAttestationResponse->attestationObject->authData->isBackupEligible();
|
||||
$credentialRecord->backupStatus = $authenticatorAttestationResponse->attestationObject->authData->isBackedUp();
|
||||
$credentialRecord->uvInitialized = $authenticatorAttestationResponse->attestationObject->authData->isUserVerified();
|
||||
|
||||
// Dispatch events if backup state changed
|
||||
if ($previousBackupEligible !== $credentialRecord->backupEligible) {
|
||||
$this->eventDispatcher->dispatch(
|
||||
new BackupEligibilityChangedEvent(
|
||||
$credentialRecord,
|
||||
$previousBackupEligible,
|
||||
$credentialRecord->backupEligible
|
||||
)
|
||||
);
|
||||
}
|
||||
if ($previousBackupStatus !== $credentialRecord->backupStatus) {
|
||||
$this->eventDispatcher->dispatch(
|
||||
new BackupStatusChangedEvent(
|
||||
$credentialRecord,
|
||||
$previousBackupStatus,
|
||||
$credentialRecord->backupStatus
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->logger->info('The attestation is valid');
|
||||
$this->logger->debug('Credential Record', [
|
||||
'credentialRecord' => $credentialRecord,
|
||||
]);
|
||||
$this->eventDispatcher->dispatch(
|
||||
$this->createAuthenticatorAttestationResponseValidationSucceededEvent(
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions,
|
||||
$host,
|
||||
$credentialRecord
|
||||
)
|
||||
);
|
||||
return $credentialRecord;
|
||||
} catch (Throwable $throwable) {
|
||||
$this->logger->error('An error occurred', [
|
||||
'exception' => $throwable,
|
||||
]);
|
||||
$this->eventDispatcher->dispatch(
|
||||
$this->createAuthenticatorAttestationResponseValidationFailedEvent(
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions,
|
||||
$host,
|
||||
$throwable
|
||||
)
|
||||
);
|
||||
throw $throwable;
|
||||
}
|
||||
}
|
||||
|
||||
protected function createAuthenticatorAttestationResponseValidationSucceededEvent(
|
||||
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
|
||||
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
|
||||
string $host,
|
||||
CredentialRecord $credentialRecord
|
||||
): AuthenticatorAttestationResponseValidationSucceededEvent {
|
||||
return new AuthenticatorAttestationResponseValidationSucceededEvent(
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions,
|
||||
$host,
|
||||
$credentialRecord
|
||||
);
|
||||
}
|
||||
|
||||
protected function createAuthenticatorAttestationResponseValidationFailedEvent(
|
||||
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
|
||||
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
|
||||
string $host,
|
||||
Throwable $throwable
|
||||
): AuthenticatorAttestationResponseValidationFailedEvent {
|
||||
return new AuthenticatorAttestationResponseValidationFailedEvent(
|
||||
$authenticatorAttestationResponse,
|
||||
$publicKeyCredentialCreationOptions,
|
||||
$host,
|
||||
$throwable
|
||||
);
|
||||
}
|
||||
|
||||
private function createCredentialRecord(
|
||||
AuthenticatorAttestationResponse $authenticatorAttestationResponse,
|
||||
PublicKeyCredentialCreationOptions $publicKeyCredentialCreationOptions,
|
||||
): CredentialRecord {
|
||||
$attestationObject = $authenticatorAttestationResponse->attestationObject;
|
||||
$attestedCredentialData = $attestationObject->authData->attestedCredentialData;
|
||||
$attestedCredentialData !== null || throw AuthenticatorResponseVerificationException::create(
|
||||
'Not attested credential data'
|
||||
);
|
||||
$credentialId = $attestedCredentialData->credentialId;
|
||||
$credentialPublicKey = $attestedCredentialData->credentialPublicKey;
|
||||
$credentialPublicKey !== null || throw AuthenticatorResponseVerificationException::create(
|
||||
'Not credential public key available in the attested credential data'
|
||||
);
|
||||
$userHandle = $publicKeyCredentialCreationOptions->user->id;
|
||||
$transports = $authenticatorAttestationResponse->transports;
|
||||
|
||||
return CredentialRecord::create(
|
||||
$credentialId,
|
||||
PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY,
|
||||
$transports,
|
||||
$attestationObject->attStmt
|
||||
->type,
|
||||
$attestationObject->attStmt
|
||||
->trustPath,
|
||||
$attestedCredentialData->aaguid,
|
||||
$credentialPublicKey,
|
||||
$userHandle,
|
||||
$attestationObject->authData
|
||||
->signCount,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue