Audit: dev/sicherheit/SICHERHEITSAUDIT-2026-10-07.md, Plan und Entscheidungen: dev/sicherheit/ENTWICKLUNGSPLAN-SICHERHEIT-2026-10-07.md. - S-01 Legacy-Rechnungen fremder Kunden nur mit billing:manage (auch Kundenroute). - S-02 Kontaktzuordnung auf der Firmenanzeige verlangt companies:write, $id gesperrt. - S-03 CompanyMembershipObserver: automatische Firmenrechte werden bei jeder Adress-/Zuordnungsänderung sofort neu bewertet; memberships:resync-auto. - S-04 Passwortwechsel beendet alle anderen Sessions (PasswordChanger), Reset alle Sessions und offene Login-Links; Fortify PUT /user/password abgeschaltet. API-Tokens bleiben bestehen. - S-05 Google: email_verified Pflicht, feste Bindung über die Provider-ID; Erstverknüpfung bestehender Konten außerhalb gmail/hd nur per Bestätigungslink in derselben Browser-Session. - S-06 Frischer Identitätsnachweis (Passwort, App-Code, E-Mail-Code oder Passkey) vor E-Mail-Wechsel, erster 2FA-Einrichtung und Token-Erzeugung; Hinweis-Mails an die (bisherige) Kontoadresse. - Entscheidung 5: Passkeys (Fortify, @laravel/passkeys) für alle; Super-Admins und Admins bestätigen die Session für den Admin-Bereich per Passkey oder App-Code (EnsureStrongAdminAuthentication, Notfallschalter AUTH_REQUIRE_STRONG_ADMIN); Reset des zweiten Faktors durch Super-Admins. Neue Migration: create_passkeys_table. Suite 2.403 grün (1 übersprungen), Larastan ohne Meldung. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
147 lines
5.5 KiB
PHP
147 lines
5.5 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Concerns\ConfirmsIdentity;
|
|
use App\Models\User;
|
|
use App\Services\Auth\SecurityConfirmation;
|
|
use App\Services\Auth\StrongAuthentication;
|
|
use Livewire\Attributes\Layout;
|
|
use Livewire\Attributes\Title;
|
|
use Livewire\Component;
|
|
|
|
/**
|
|
* Einmalige Bestätigung der Session für den Admin-Bereich (Entscheidung 5,
|
|
* 07.10.2026): per Passkey (Browser-Zeremonie gegen /passkeys/confirm, die
|
|
* Marke setzt TrackSecondFactorEvents) oder per Authenticator-Code. Ohne
|
|
* beides führt die Seite zur Einrichtung auf der Sicherheitsseite.
|
|
*/
|
|
new #[Layout('components.layouts.app'), Title('Anmeldung bestätigen')] class extends Component
|
|
{
|
|
use ConfirmsIdentity;
|
|
|
|
public function mount(): void
|
|
{
|
|
if (app(StrongAuthentication::class)->isSatisfiedBy($this->user())) {
|
|
$this->continueToIntended();
|
|
}
|
|
}
|
|
|
|
public function confirmWithCode(): void
|
|
{
|
|
$user = $this->user();
|
|
|
|
abort_unless($user->hasEnabledTwoFactorAuthentication(), 403);
|
|
|
|
$this->assertSecondFactor($user);
|
|
|
|
app(StrongAuthentication::class)->mark($user, 'totp');
|
|
app(SecurityConfirmation::class)->markConfirmed($user);
|
|
|
|
$this->continueToIntended();
|
|
}
|
|
|
|
/**
|
|
* Aufruf nach erfolgreicher Passkey-Zeremonie im Browser.
|
|
*/
|
|
public function passkeyConfirmed(): void
|
|
{
|
|
if (! app(StrongAuthentication::class)->isSatisfiedBy($this->user())) {
|
|
$this->addError('passkey', __('Der Passkey konnte nicht bestätigt werden. Bitte versuchen Sie es erneut.'));
|
|
|
|
return;
|
|
}
|
|
|
|
$this->continueToIntended();
|
|
}
|
|
|
|
public function with(): array
|
|
{
|
|
$user = $this->user();
|
|
|
|
return [
|
|
'hasPasskeys' => app(StrongAuthentication::class)->hasPasskeys($user),
|
|
'hasTotp' => $user->hasEnabledTwoFactorAuthentication(),
|
|
];
|
|
}
|
|
|
|
private function continueToIntended(): void
|
|
{
|
|
$intended = session()->pull(StrongAuthentication::INTENDED_KEY);
|
|
$host = request()->getHost();
|
|
|
|
// Nur Ziele auf dieser Domain (kein offener Redirect).
|
|
$target = is_string($intended) && parse_url($intended, PHP_URL_HOST) === $host
|
|
? $intended
|
|
: route('dashboard');
|
|
|
|
$this->redirect($target);
|
|
}
|
|
|
|
private function user(): User
|
|
{
|
|
/** @var User */
|
|
return auth()->user();
|
|
}
|
|
}; ?>
|
|
|
|
<div class="max-w-[560px] space-y-6">
|
|
<header class="page-header">
|
|
<div class="min-w-0">
|
|
<div class="flex items-center gap-3 mb-3">
|
|
<span class="eyebrow muted">{{ __('Admin-Bereich') }}</span>
|
|
</div>
|
|
<h1 class="text-[26px] font-bold tracking-[-0.5px] leading-[1.15] m-0 text-[color:var(--color-ink)]">
|
|
{{ __('Anmeldung bestätigen') }}
|
|
</h1>
|
|
<p class="text-[13px] leading-[1.55] mt-2 m-0 text-[color:var(--color-ink-2)]">
|
|
{{ __('Für den Admin-Bereich bestätigen Sie Ihre Anmeldung einmalig mit einem zweiten Faktor. Die Bestätigung gilt, bis Sie sich abmelden.') }}
|
|
</p>
|
|
</div>
|
|
</header>
|
|
|
|
@if ($hasPasskeys)
|
|
<article class="panel p-5 space-y-3"
|
|
x-data="{ busy: false, error: null }">
|
|
<div class="section-eyebrow">{{ __('Mit Passkey') }}</div>
|
|
<p class="text-[13px] text-[color:var(--color-ink-2)] m-0">
|
|
{{ __('Fingerabdruck, Gesicht oder Geräte-PIN — ohne Code aus der App.') }}
|
|
</p>
|
|
<flux:button variant="primary" icon="finger-print" x-bind:disabled="busy"
|
|
x-on:click="busy = true; error = null;
|
|
const outcome = await window.PkPasskeys.confirm();
|
|
if (outcome.ok) { await $wire.passkeyConfirmed(); }
|
|
else { error = outcome.error; }
|
|
busy = false;">
|
|
{{ __('Mit Passkey bestätigen') }}
|
|
</flux:button>
|
|
<p class="text-[12px] text-[color:var(--color-warn,#b91c1c)] m-0" x-show="error" x-text="error"></p>
|
|
@error('passkey')
|
|
<p class="text-[12px] text-[color:var(--color-warn,#b91c1c)] m-0">{{ $message }}</p>
|
|
@enderror
|
|
</article>
|
|
@endif
|
|
|
|
@if ($hasTotp)
|
|
<article class="panel p-5">
|
|
<form wire:submit="confirmWithCode" class="space-y-3 max-w-[320px]">
|
|
<div class="section-eyebrow">{{ __('Mit Authenticator-App') }}</div>
|
|
<flux:input wire:model="securityCode" :label="__('Code aus der App oder Wiederherstellungs-Code')"
|
|
inputmode="numeric" autocomplete="one-time-code" placeholder="123456" required />
|
|
<flux:button type="submit" :variant="$hasPasskeys ? 'filled' : 'primary'">
|
|
{{ __('Bestätigen') }}
|
|
</flux:button>
|
|
</form>
|
|
</article>
|
|
@endif
|
|
|
|
@if (! $hasPasskeys && ! $hasTotp)
|
|
<article class="panel p-5 space-y-3">
|
|
<div class="section-eyebrow">{{ __('Zweiten Faktor einrichten') }}</div>
|
|
<p class="text-[13px] text-[color:var(--color-ink-2)] m-0">
|
|
{{ __('Für Administratoren ist ein zweiter Faktor Pflicht. Richten Sie am einfachsten einen Passkey ein — alternativ die Authenticator-App. Danach geht es hier direkt weiter.') }}
|
|
</p>
|
|
<flux:button variant="primary" icon="shield-check" :href="route('me.security')" wire:navigate>
|
|
{{ __('Jetzt einrichten') }}
|
|
</flux:button>
|
|
</article>
|
|
@endif
|
|
</div>
|