diff --git a/lib/Maintenance.php b/lib/Maintenance.php index cfa8e68..882a20d 100644 --- a/lib/Maintenance.php +++ b/lib/Maintenance.php @@ -135,8 +135,11 @@ public static function isSecretAllowed(): bool $maintenance_secret = rex_request('maintenance_secret', 'string', ''); $authentification_mode = (string) self::getConfig('authentification_mode', ''); - // Check if the correct secret is passed via URL or password - if (('URL' === $authentification_mode || 'password' === $authentification_mode) && '' !== $config_secret && $maintenance_secret === $config_secret) { + // Authentifizierung prüfen - für URL-Parameter und auch bei leerem Modus + $authentification_mode = (string) self::getConfig('authentification_mode', ''); + if (('' === $authentification_mode || 'URL' === $authentification_mode || 'password' === $authentification_mode) + && '' !== $config_secret + && $maintenance_secret === $config_secret) { rex_set_session('maintenance_secret', $maintenance_secret); return true; } diff --git a/update.php b/update.php index d6a432f..9ef44e8 100644 --- a/update.php +++ b/update.php @@ -50,3 +50,16 @@ $addon->removeConfig('type'); $addon->removeConfig('secret'); } + +// Leerer String ('') und 'URL' werden beide als gültige URL-Authentifizierung betrachtet +$authentification_mode = $addon->getConfig('authentification_mode', ''); +if (!in_array($authentification_mode, ['URL', 'password'], true)) { + // Wenn kein gültiger Modus gesetzt ist, standardmäßig auf URL setzen + $addon->setConfig('authentification_mode', 'URL'); +} + +// Überprüfen, ob ein maintenance_secret existiert +if (!$addon->hasConfig('maintenance_secret') || '' === $addon->getConfig('maintenance_secret')) { + // Falls kein Secret vorhanden, ein neues generieren + $addon->setConfig('maintenance_secret', bin2hex(random_bytes(16))); +}