Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 7m25s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 6m46s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m52s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 8m5s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 10m33s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 10m53s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 9m1s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 8m49s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 54s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m4s
- /uploads nur über das Portal: UploadController prüft Sitzung bzw. App-Token; frei nur die Dateien der Anmeldeseite (Logos, Symbole, Anmeldehintergrund, Stylesheet, Schrift); public/uploads/.htaccess leitet alles an index.php (Migration schreibt sie, da der Ordner vor dem Updater geschützt ist); Systemzustand prüft die Regel; nginx-Hinweis in docs/SECURITY.md - Passwort-Anmeldung abschaltbar (PasswordLogin): Login-Formular, Passwort vergessen, App-Token und /api/v1/config; nur mit verknüpftem Konto abschaltbar, automatische Rückkehr ohne nutzbaren Dienst, Notausgang INHAUS_PASSWORD_LOGIN - Titelbilder: profile_covers (bis 12), zufällig je Seitenaufruf - ImageCompressor: Uploads im Backend (SafeUpload) und WordPress-Import auf ≤ 2400 px komprimiert, Format bleibt Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
||
|
||
namespace App\Support;
|
||
|
||
/**
|
||
* Schutzregel für public/uploads: Der Webserver liefert dort nichts direkt aus, sondern reicht
|
||
* jede Anfrage an das Portal weiter, das die Anmeldung prüft (UploadController).
|
||
*
|
||
* public/uploads ist vor dem Updater geschützt (Kundendaten) – deshalb schreibt eine Migration
|
||
* diese Datei bei bestehenden Installationen, neue bekommen sie mit dem Paket.
|
||
*/
|
||
class UploadsGuard
|
||
{
|
||
public const HTACCESS = <<<'HTACCESS'
|
||
# Hochgeladene Dateien nur über das Portal – es prüft die Anmeldung (UploadController).
|
||
# Direkte Links funktionieren ohne Anmeldung nicht. Diese Datei schreibt das Portal selbst.
|
||
|
||
<IfModule mod_php.c>
|
||
php_flag engine off
|
||
</IfModule>
|
||
|
||
<IfModule mod_rewrite.c>
|
||
RewriteEngine On
|
||
RewriteRule ^ ../index.php [L]
|
||
</IfModule>
|
||
|
||
# Ohne mod_rewrite lieber gar nichts ausliefern
|
||
<IfModule !mod_rewrite.c>
|
||
Require all denied
|
||
</IfModule>
|
||
|
||
HTACCESS;
|
||
|
||
/** Schreibt die Regel; liefert false, wenn das nicht ging */
|
||
public static function install(?string $dir = null): bool
|
||
{
|
||
$dir ??= public_path('uploads');
|
||
|
||
if (! is_dir($dir) && ! @mkdir($dir, 0775, true)) {
|
||
return false;
|
||
}
|
||
|
||
return @file_put_contents($dir.'/.htaccess', self::HTACCESS) !== false;
|
||
}
|
||
|
||
public static function installed(?string $dir = null): bool
|
||
{
|
||
return @file_get_contents(($dir ?? public_path('uploads')).'/.htaccess') === self::HTACCESS;
|
||
}
|
||
}
|