Self-Updater und Lizenzprüfung
Umsetzung von docs/specs/self-updater.md für Laravel: - Installierter Stand als SHA in storage/.version, Fortschritt in storage/.update-progress, selbstheilender Wartungsmodus in storage/.maintenance - Update-Client je Kanal (stable/development), nur HTTPS, begrenzte Redirects, ZIP-Download per Stream mit PK- und SHA-256-Prüfung - Entpacken mit zweistufigem ZIP-Slip-Schutz, Übernahme mit geschützten Pfaden (atomar je Datei, nie löschen), Migrationen, Cache- und OPcache-Reset - Lizenzspeicher außerhalb der DB, Geräte-ID als Zufallszahl, rotierendes Gerätetoken wird bei jeder Antwort (auch Fehler und Downloads) sofort gespeichert - Lizenzfehler mit verständlichen Meldungen – sie sperren nie das Portal - Seite „Aktualisierung“ mit Kanal, Suche, Changelog-Vorschau, Fortschritt, Migrationen, Änderungsprotokoll, Lizenz und Datenschutzhinweis - Wartungs-Middleware (503 + Retry-After) und Auto-Migration per Fingerabdruck - Audit-Log für Updates, Kanalwechsel und Lizenzänderungen - Version 0.2.0 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a36752e09a
commit
43244d751a
41 changed files with 3184 additions and 3 deletions
35
app/Http/Middleware/EnsureNotInMaintenance.php
Normal file
35
app/Http/Middleware/EnsureNotInMaintenance.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Support\Update\MaintenanceFlag;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Während eines Updates: 503 mit Wartungsseite. Ausgenommen sind die
|
||||
* Update-Endpunkte, die Seite „Aktualisierung“, die Anmeldung und der
|
||||
* Health-Check – sonst könnte niemand verfolgen, wie weit das Update ist.
|
||||
*/
|
||||
class EnsureNotInMaintenance
|
||||
{
|
||||
private const EXCEPT = ['admin/update/*', 'admin/aktualisierung', 'login', 'logout', 'up'];
|
||||
|
||||
public function __construct(private readonly MaintenanceFlag $maintenance) {}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
if (! $this->maintenance->isActive() || $request->is(...self::EXCEPT)) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
$retryAfter = $this->maintenance->retryAfter();
|
||||
|
||||
if ($request->expectsJson() || $request->header('X-Inertia')) {
|
||||
return response()->json(['message' => 'Das Portal wird gerade aktualisiert.'], 503, ['Retry-After' => $retryAfter]);
|
||||
}
|
||||
|
||||
return response()->view('maintenance', ['retryAfter' => $retryAfter], 503, ['Retry-After' => $retryAfter]);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue