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
22
vendor/laravel/passkeys/src/Actions/DeletePasskey.php
vendored
Normal file
22
vendor/laravel/passkeys/src/Actions/DeletePasskey.php
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laravel\Passkeys\Actions;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Laravel\Passkeys\Events\PasskeyDeleted;
|
||||
use Laravel\Passkeys\Passkey;
|
||||
|
||||
class DeletePasskey
|
||||
{
|
||||
/**
|
||||
* Delete the given passkey.
|
||||
*/
|
||||
public function __invoke(Authenticatable $user, Passkey $passkey): void
|
||||
{
|
||||
$passkey->delete();
|
||||
|
||||
PasskeyDeleted::dispatch($user, $passkey);
|
||||
}
|
||||
}
|
||||
129
vendor/laravel/passkeys/src/Actions/GenerateRegistrationOptions.php
vendored
Normal file
129
vendor/laravel/passkeys/src/Actions/GenerateRegistrationOptions.php
vendored
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laravel\Passkeys\Actions;
|
||||
|
||||
use Cose\Algorithms;
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Laravel\Passkeys\Contracts\PasskeyUser;
|
||||
use Laravel\Passkeys\Passkeys;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use RuntimeException;
|
||||
use Webauthn\AuthenticatorSelectionCriteria;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
use Webauthn\PublicKeyCredentialDescriptor;
|
||||
use Webauthn\PublicKeyCredentialParameters;
|
||||
use Webauthn\PublicKeyCredentialRpEntity;
|
||||
use Webauthn\PublicKeyCredentialUserEntity;
|
||||
|
||||
class GenerateRegistrationOptions
|
||||
{
|
||||
/**
|
||||
* Generate registration options for a user to create a new passkey.
|
||||
*/
|
||||
public function __invoke(Authenticatable $user): PublicKeyCredentialCreationOptions
|
||||
{
|
||||
if (! $user instanceof PasskeyUser) {
|
||||
throw new RuntimeException('User model must implement the PasskeyUser contract.');
|
||||
}
|
||||
|
||||
// Don't verify the authenticator's attestation certificate chain.
|
||||
$attestation = PublicKeyCredentialCreationOptions::ATTESTATION_CONVEYANCE_PREFERENCE_NONE;
|
||||
|
||||
return PublicKeyCredentialCreationOptions::create(
|
||||
rp: $this->relyingParty(),
|
||||
user: $this->userEntity($user),
|
||||
challenge: random_bytes(32),
|
||||
pubKeyCredParams: $this->supportedAlgorithms(),
|
||||
authenticatorSelection: $this->authenticatorSelection(),
|
||||
attestation: $attestation,
|
||||
excludeCredentials: $this->excludedCredentials($user),
|
||||
timeout: Passkeys::timeout(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the relying party entity.
|
||||
*/
|
||||
protected function relyingParty(): PublicKeyCredentialRpEntity
|
||||
{
|
||||
return PublicKeyCredentialRpEntity::create(
|
||||
name: Passkeys::relyingPartyName(),
|
||||
id: Passkeys::relyingPartyId(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the user entity for registration.
|
||||
*/
|
||||
protected function userEntity(PasskeyUser $user): PublicKeyCredentialUserEntity
|
||||
{
|
||||
return PublicKeyCredentialUserEntity::create(
|
||||
name: $user->getPasskeyUsername(),
|
||||
id: $user->getPasskeyUserHandle(),
|
||||
displayName: $user->getPasskeyDisplayName(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticator selection criteria.
|
||||
*
|
||||
* @see https://www.w3.org/TR/webauthn-3/#dictdef-authenticatorselectioncriteria
|
||||
*/
|
||||
public function authenticatorSelection(): AuthenticatorSelectionCriteria
|
||||
{
|
||||
// Allow any authenticator: built-in (Touch ID, Windows Hello) or external (YubiKey).
|
||||
$crossPlatform = AuthenticatorSelectionCriteria::AUTHENTICATOR_ATTACHMENT_NO_PREFERENCE;
|
||||
|
||||
// Require a discoverable credential so the user can sign in without typing a username.
|
||||
$residentKey = AuthenticatorSelectionCriteria::RESIDENT_KEY_REQUIREMENT_REQUIRED;
|
||||
|
||||
// Require user verification (biometric, PIN) rather than just presence (tap).
|
||||
$userVerification = AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED;
|
||||
|
||||
return AuthenticatorSelectionCriteria::create(
|
||||
authenticatorAttachment: $crossPlatform,
|
||||
userVerification: $userVerification,
|
||||
residentKey: $residentKey,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials to exclude from registration. Prevents the same
|
||||
* authenticator from being registered twice.
|
||||
*
|
||||
* @return array<PublicKeyCredentialDescriptor>
|
||||
*/
|
||||
public function excludedCredentials(PasskeyUser $user): array
|
||||
{
|
||||
$type = PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY;
|
||||
|
||||
return $user->passkeys()->get()->map(
|
||||
fn ($passkey): PublicKeyCredentialDescriptor => PublicKeyCredentialDescriptor::create(
|
||||
$type,
|
||||
Base64UrlSafe::decodeNoPadding($passkey->credential_id)
|
||||
)
|
||||
)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the supported public key credential algorithms.
|
||||
*
|
||||
* @return array<PublicKeyCredentialParameters>
|
||||
*/
|
||||
public function supportedAlgorithms(): array
|
||||
{
|
||||
$type = PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY;
|
||||
|
||||
// ES256 (ECDSA) is preferred and supported by most authenticators.
|
||||
// RS256 (RSA) is a fallback for older Windows Hello implementations.
|
||||
$es256 = Algorithms::COSE_ALGORITHM_ES256;
|
||||
$rs256 = Algorithms::COSE_ALGORITHM_RS256;
|
||||
|
||||
return [
|
||||
PublicKeyCredentialParameters::create($type, $es256),
|
||||
PublicKeyCredentialParameters::create($type, $rs256),
|
||||
];
|
||||
}
|
||||
}
|
||||
54
vendor/laravel/passkeys/src/Actions/GenerateVerificationOptions.php
vendored
Normal file
54
vendor/laravel/passkeys/src/Actions/GenerateVerificationOptions.php
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laravel\Passkeys\Actions;
|
||||
|
||||
use Laravel\Passkeys\Contracts\PasskeyUser;
|
||||
use Laravel\Passkeys\Passkeys;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Webauthn\AuthenticatorSelectionCriteria;
|
||||
use Webauthn\PublicKeyCredentialDescriptor;
|
||||
use Webauthn\PublicKeyCredentialRequestOptions;
|
||||
|
||||
class GenerateVerificationOptions
|
||||
{
|
||||
/**
|
||||
* Generate verification options for passwordless login or user confirmation.
|
||||
*
|
||||
* @see https://www.w3.org/TR/webauthn-3/#dictdef-publickeycredentialrequestoptions
|
||||
*/
|
||||
public function __invoke(?PasskeyUser $user = null): PublicKeyCredentialRequestOptions
|
||||
{
|
||||
return PublicKeyCredentialRequestOptions::create(
|
||||
challenge: random_bytes(32),
|
||||
rpId: Passkeys::relyingPartyId(),
|
||||
allowCredentials: $this->allowCredentials($user),
|
||||
userVerification: AuthenticatorSelectionCriteria::USER_VERIFICATION_REQUIREMENT_REQUIRED,
|
||||
timeout: Passkeys::timeout(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get credentials allowed for verification.
|
||||
*
|
||||
* When no user is provided, uses discoverable credentials for passwordless login.
|
||||
*
|
||||
* @return array<PublicKeyCredentialDescriptor>
|
||||
*/
|
||||
public function allowCredentials(?PasskeyUser $user): array
|
||||
{
|
||||
if (! $user instanceof PasskeyUser) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$type = PublicKeyCredentialDescriptor::CREDENTIAL_TYPE_PUBLIC_KEY;
|
||||
|
||||
return $user->passkeys()->get()->map(
|
||||
fn ($passkey): PublicKeyCredentialDescriptor => PublicKeyCredentialDescriptor::create(
|
||||
$type,
|
||||
Base64UrlSafe::decodeNoPadding($passkey->credential_id)
|
||||
)
|
||||
)->all();
|
||||
}
|
||||
}
|
||||
111
vendor/laravel/passkeys/src/Actions/StorePasskey.php
vendored
Normal file
111
vendor/laravel/passkeys/src/Actions/StorePasskey.php
vendored
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laravel\Passkeys\Actions;
|
||||
|
||||
use Illuminate\Contracts\Auth\Authenticatable;
|
||||
use Laravel\Passkeys\Contracts\PasskeyUser;
|
||||
use Laravel\Passkeys\Events\PasskeyRegistered;
|
||||
use Laravel\Passkeys\Exceptions\InvalidPasskeyException;
|
||||
use Laravel\Passkeys\Passkey;
|
||||
use Laravel\Passkeys\Passkeys;
|
||||
use Laravel\Passkeys\Support\WebAuthn;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use RuntimeException;
|
||||
use Webauthn\AuthenticatorAttestationResponse;
|
||||
use Webauthn\CredentialRecord;
|
||||
use Webauthn\PublicKeyCredential;
|
||||
use Webauthn\PublicKeyCredentialCreationOptions;
|
||||
|
||||
class StorePasskey
|
||||
{
|
||||
/**
|
||||
* Validate and store a passkey for the user.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
public function __invoke(
|
||||
Authenticatable $user,
|
||||
string $name,
|
||||
PublicKeyCredential $credential,
|
||||
PublicKeyCredentialCreationOptions $options
|
||||
): Passkey {
|
||||
if (! $user instanceof PasskeyUser) {
|
||||
throw new RuntimeException('User model must implement the PasskeyUser contract.');
|
||||
}
|
||||
|
||||
$response = $this->getResponse($credential);
|
||||
|
||||
$source = $this->validate($response, $options);
|
||||
|
||||
$this->ensureCredentialIsUnique($source);
|
||||
|
||||
$passkey = $this->createPasskey($user, $name, $source);
|
||||
|
||||
PasskeyRegistered::dispatch($user, $passkey);
|
||||
|
||||
return $passkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticator attestation response from the credential.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
protected function getResponse(PublicKeyCredential $credential): AuthenticatorAttestationResponse
|
||||
{
|
||||
if (! $credential->response instanceof AuthenticatorAttestationResponse) {
|
||||
throw InvalidPasskeyException::make('Unable to register passkey. Please try again.');
|
||||
}
|
||||
|
||||
return $credential->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the credential and return the source.
|
||||
*/
|
||||
protected function validate(
|
||||
AuthenticatorAttestationResponse $response,
|
||||
PublicKeyCredentialCreationOptions $options
|
||||
): CredentialRecord {
|
||||
return WebAuthn::attestationValidator()->check(
|
||||
authenticatorAttestationResponse: $response,
|
||||
publicKeyCredentialCreationOptions: $options,
|
||||
host: Passkeys::relyingPartyId(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the credential is not already registered.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
protected function ensureCredentialIsUnique(CredentialRecord $source): void
|
||||
{
|
||||
$credentialId = Base64UrlSafe::encodeUnpadded($source->publicKeyCredentialId);
|
||||
|
||||
$exists = Passkeys::passkeyModel()::where('credential_id', $credentialId)->exists();
|
||||
|
||||
if ($exists) {
|
||||
throw InvalidPasskeyException::make('Unable to register this passkey.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the passkey record for the user.
|
||||
*/
|
||||
public function createPasskey(
|
||||
PasskeyUser $user,
|
||||
string $name,
|
||||
CredentialRecord $source
|
||||
): Passkey {
|
||||
$credentialId = Base64UrlSafe::encodeUnpadded($source->publicKeyCredentialId);
|
||||
|
||||
return $user->passkeys()->create([
|
||||
'name' => $name,
|
||||
'credential_id' => $credentialId,
|
||||
'credential' => json_decode(WebAuthn::toJson($source), true, flags: JSON_THROW_ON_ERROR),
|
||||
]);
|
||||
}
|
||||
}
|
||||
138
vendor/laravel/passkeys/src/Actions/VerifyPasskey.php
vendored
Normal file
138
vendor/laravel/passkeys/src/Actions/VerifyPasskey.php
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Laravel\Passkeys\Actions;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Laravel\Passkeys\Contracts\PasskeyUser;
|
||||
use Laravel\Passkeys\Events\PasskeyVerified;
|
||||
use Laravel\Passkeys\Exceptions\InvalidPasskeyException;
|
||||
use Laravel\Passkeys\Passkey;
|
||||
use Laravel\Passkeys\Passkeys;
|
||||
use Laravel\Passkeys\Support\WebAuthn;
|
||||
use ParagonIE\ConstantTime\Base64UrlSafe;
|
||||
use Webauthn\AuthenticatorAssertionResponse;
|
||||
use Webauthn\CredentialRecord;
|
||||
use Webauthn\PublicKeyCredential;
|
||||
use Webauthn\PublicKeyCredentialRequestOptions;
|
||||
|
||||
class VerifyPasskey
|
||||
{
|
||||
/**
|
||||
* Validate the passkey credential and return the passkey.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
public function __invoke(
|
||||
PublicKeyCredential $credential,
|
||||
PublicKeyCredentialRequestOptions $options,
|
||||
?PasskeyUser $user = null
|
||||
): Passkey {
|
||||
$response = $this->getResponse($credential);
|
||||
|
||||
/** @var Passkey $passkey */
|
||||
$passkey = DB::transaction(function () use ($credential, $options, $user, $response) {
|
||||
$passkey = $this->getPasskey($credential, lock: true);
|
||||
|
||||
$this->ensurePasskeyBelongsToUser($passkey, $user);
|
||||
|
||||
$source = $this->validate($response, $passkey, $options);
|
||||
|
||||
$this->updatePasskey($passkey, $source);
|
||||
|
||||
PasskeyVerified::dispatch($passkey->user, $passkey);
|
||||
|
||||
return $passkey;
|
||||
});
|
||||
|
||||
return $passkey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticator assertion response from the credential.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
protected function getResponse(PublicKeyCredential $credential): AuthenticatorAssertionResponse
|
||||
{
|
||||
if (! $credential->response instanceof AuthenticatorAssertionResponse) {
|
||||
throw InvalidPasskeyException::make('Unable to verify passkey. Please try again.');
|
||||
}
|
||||
|
||||
return $credential->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the passkey by credential ID.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
public function getPasskey(PublicKeyCredential $credential, bool $lock = false): Passkey
|
||||
{
|
||||
$credentialId = Base64UrlSafe::encodeUnpadded($credential->rawId);
|
||||
|
||||
$query = Passkeys::passkeyModel()::where('credential_id', $credentialId);
|
||||
|
||||
if ($lock) {
|
||||
$query->lockForUpdate();
|
||||
}
|
||||
|
||||
return $query->first()
|
||||
?? throw InvalidPasskeyException::make('Passkey not recognized. It may have been removed from your account.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure the passkey belongs to the expected user.
|
||||
*
|
||||
* @throws InvalidPasskeyException
|
||||
*/
|
||||
public function ensurePasskeyBelongsToUser(Passkey $passkey, ?PasskeyUser $user): void
|
||||
{
|
||||
if (! $user instanceof PasskeyUser) {
|
||||
return;
|
||||
}
|
||||
|
||||
$identifier = $user->getKey();
|
||||
|
||||
if (! is_scalar($identifier) || (string) $passkey->user_id !== (string) $identifier) {
|
||||
throw InvalidPasskeyException::make('Passkey not recognized. It may have been removed from your account.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the credential against the stored passkey.
|
||||
*/
|
||||
protected function validate(
|
||||
AuthenticatorAssertionResponse $response,
|
||||
Passkey $passkey,
|
||||
PublicKeyCredentialRequestOptions $options
|
||||
): CredentialRecord {
|
||||
$source = WebAuthn::fromJson(
|
||||
json_encode($passkey->credential, JSON_THROW_ON_ERROR),
|
||||
CredentialRecord::class
|
||||
);
|
||||
|
||||
return WebAuthn::assertionValidator()->check(
|
||||
credentialRecord: $source,
|
||||
authenticatorAssertionResponse: $response,
|
||||
publicKeyCredentialRequestOptions: $options,
|
||||
host: Passkeys::relyingPartyId(),
|
||||
userHandle: $source->userHandle,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the passkey with the latest credential data.
|
||||
*
|
||||
* The credential must be persisted after each use to store the updated
|
||||
* signature counter, which is used to detect cloned authenticators.
|
||||
*/
|
||||
public function updatePasskey(Passkey $passkey, CredentialRecord $source): void
|
||||
{
|
||||
$passkey->forceFill([
|
||||
'credential' => json_decode(WebAuthn::toJson($source), true, flags: JSON_THROW_ON_ERROR),
|
||||
'last_used_at' => now(),
|
||||
])->save();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue