diff --git a/partials/landingpages/modules/access.php b/partials/landingpages/modules/access.php new file mode 100644 index 0000000..99bafb2 --- /dev/null +++ b/partials/landingpages/modules/access.php @@ -0,0 +1,61 @@ +get($moduleName); +$notice = null; + +require_admin(); + +if (!$module) { + http_response_code(404); + echo '
Modul nicht gefunden.
'; + return; +} + +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + modules()->saveAuth($moduleName, [ + 'required' => isset($_POST['auth_required']), + 'users' => (string)($_POST['auth_users'] ?? ''), + 'groups' => (string)($_POST['auth_groups'] ?? ''), + ]); + $notice = 'Zugriff gespeichert.'; + $module = modules()->get($moduleName) ?: $module; +} + +$authConfig = is_array($module['auth'] ?? null) ? $module['auth'] : ['required' => false, 'users' => [], 'groups' => []]; +?> +
+
Zugriff
+

- Zugriffsrechte

+

Diese Seite ist nur fuer eingeloggte Mitglieder der Gruppe config()->oidcAdminGroup) ?> verfuegbar.

+ + +
+ +
+ + +
+ + + + + + + Wenn Login aktiv ist und Benutzer/Gruppen leer bleiben, darf jeder eingeloggte Benutzer das Modul oeffnen. + +
+ + Setup + Zurück +
+
+
diff --git a/partials/landingpages/modules/index.php b/partials/landingpages/modules/index.php index 6d7d371..22d22a9 100644 --- a/partials/landingpages/modules/index.php +++ b/partials/landingpages/modules/index.php @@ -51,6 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
Öffnen Setup + Zugriff
diff --git a/partials/landingpages/modules/setup.php b/partials/landingpages/modules/setup.php index 4380afe..51cd452 100644 --- a/partials/landingpages/modules/setup.php +++ b/partials/landingpages/modules/setup.php @@ -93,16 +93,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { } modules()->saveSettings($moduleName, $payload); - modules()->saveAuth($moduleName, [ - 'required' => isset($_POST['auth_required']), - 'users' => (string)($_POST['auth_users'] ?? ''), - 'groups' => (string)($_POST['auth_groups'] ?? ''), - ]); $notice = 'Setup gespeichert.'; $current = array_replace_recursive($current, $payload); $module = modules()->get($moduleName) ?: $module; } -$authConfig = is_array($module['auth'] ?? null) ? $module['auth'] : ['required' => false, 'users' => [], 'groups' => []]; ?>
Setup
@@ -127,6 +121,7 @@ $authConfig = is_array($module['auth'] ?? null) ? $module['auth'] : ['required' $type = (string)($field['type'] ?? 'text'); $required = !empty($field['required']); $help = (string)($field['help'] ?? $field['description'] ?? ''); + $postKey = str_replace('.', '_', $name); $value = ''; if ($name === 'kea_auto_init') { @@ -140,11 +135,11 @@ $authConfig = is_array($module['auth'] ?? null) ? $module['auth'] : ['required' -
- Modulzugriff - - - - Wenn Login aktiv ist und Benutzer/Gruppen leer bleiben, darf jeder eingeloggte Benutzer das Modul oeffnen. -
-
+ Zugriff verwalten Zurück
diff --git a/public/index.php b/public/index.php index 482c403..9d32f19 100755 --- a/public/index.php +++ b/public/index.php @@ -25,7 +25,8 @@ $publicPaths = [ 'module/pi_control/terminal_info', ]; $requiresGlobalAuth = in_array($uriPath, ['settings', 'users', 'modules', 'modules/install', 'modules/sql-import', 'debug', 'exports/database.sql'], true) - || str_starts_with($uriPath, 'modules/setup/'); + || str_starts_with($uriPath, 'modules/setup/') + || str_starts_with($uriPath, 'modules/access/'); if (defined('APP_AUTH_ENABLED') && APP_AUTH_ENABLED && $requiresGlobalAuth && !in_array($uriPath, $publicPaths, true)) { $user = auth_user(); if (!$user) { @@ -94,7 +95,7 @@ if (preg_match('~^api/module-auth/([a-zA-Z0-9_-]+)$~', $uriPath, $moduleAuthMatc echo json_encode(['error' => 'auth_required'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); exit; } - if (!$auth->canAccessModule($moduleMeta)) { + if (!auth_is_admin()) { http_response_code(403); header('Content-Type: application/json; charset=utf-8'); echo json_encode(['error' => 'forbidden'], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); @@ -200,6 +201,9 @@ if (str_starts_with($uriPath, 'modules/install')) { } elseif (str_starts_with($uriPath, 'modules/setup/')) { $_GET['module'] = trim(substr($uriPath, strlen('modules/setup/')), '/'); $target = $pagesBase . '/modules/setup.php'; +} elseif (str_starts_with($uriPath, 'modules/access/')) { + $_GET['module'] = trim(substr($uriPath, strlen('modules/access/')), '/'); + $target = $pagesBase . '/modules/access.php'; } elseif ($uriPath === 'modules/sql-import') { $target = $pagesBase . '/modules/sql_import.php'; } elseif ($uriPath === 'auth/login') {