Skip to content

Commit cdb4569

Browse files
author
Alexander Walther
authored
Merge pull request #143 from FriendsOfREDAXO/skerbis-patch-2
Fix für Maintenance-AddOn URL-Parameter Authentifizierung
2 parents bf62a78 + d760792 commit cdb4569

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/Maintenance.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ public static function isSecretAllowed(): bool
135135
$maintenance_secret = rex_request('maintenance_secret', 'string', '');
136136
$authentification_mode = (string) self::getConfig('authentification_mode', '');
137137

138-
// Check if the correct secret is passed via URL or password
139-
if (('URL' === $authentification_mode || 'password' === $authentification_mode) && '' !== $config_secret && $maintenance_secret === $config_secret) {
138+
// Authentifizierung prüfen - für URL-Parameter und auch bei leerem Modus
139+
$authentification_mode = (string) self::getConfig('authentification_mode', '');
140+
if (('' === $authentification_mode || 'URL' === $authentification_mode || 'password' === $authentification_mode)
141+
&& '' !== $config_secret
142+
&& $maintenance_secret === $config_secret) {
140143
rex_set_session('maintenance_secret', $maintenance_secret);
141144
return true;
142145
}

update.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@
5050
$addon->removeConfig('type');
5151
$addon->removeConfig('secret');
5252
}
53+
54+
// Leerer String ('') und 'URL' werden beide als gültige URL-Authentifizierung betrachtet
55+
$authentification_mode = $addon->getConfig('authentification_mode', '');
56+
if (!in_array($authentification_mode, ['URL', 'password'], true)) {
57+
// Wenn kein gültiger Modus gesetzt ist, standardmäßig auf URL setzen
58+
$addon->setConfig('authentification_mode', 'URL');
59+
}
60+
61+
// Überprüfen, ob ein maintenance_secret existiert
62+
if (!$addon->hasConfig('maintenance_secret') || '' === $addon->getConfig('maintenance_secret')) {
63+
// Falls kein Secret vorhanden, ein neues generieren
64+
$addon->setConfig('maintenance_secret', bin2hex(random_bytes(16)));
65+
}

0 commit comments

Comments
 (0)