' . html_escape(__('Review the recorded observations below. Acknowledgments are personal to this session, expire when observations change, and never suppress alerts or change health.', 'redfish')) . '
'; + print '' . html_escape(__('Monitoring view', 'redfish')) . '
'; + OperatorPage::render($rows, $session, $user, $now, $actions); + bottom_footer(); +} catch (Throwable $error) { + cacti_log('Operator page failed (' . get_class($error) . ')', false, 'REDFISH'); + http_response_code(503); + top_header(); + print '' . html_escape(__('Observations could not be read. Ask an administrator to check the plugin log.', 'redfish')) . '
'; + bottom_footer(); +} diff --git a/setup.php b/setup.php index ba707d0..9b7693a 100644 --- a/setup.php +++ b/setup.php @@ -128,13 +128,18 @@ function plugin_redfish_check_config(): bool { } /** - * Common start of every page script, after include/auth.php has authorized - * the realm. Refuses on an unsupported runtime or a disabled plugin, because - * Cacti keeps plugin realms registered while a plugin is disabled. + * Common start after include/auth.php establishes the user. Recheck the + * realm here because cookie and Basic login restore the user after the + * alternate-realms hook. Disabled plugins and unsupported runtimes refuse. */ function redfish_page_start(): bool { if (redfish_boot() && api_plugin_is_enabled('redfish')) { - return true; + if (redfish_page_allowed()) { + return true; + } + http_response_code(403); + + return false; } top_header(); @@ -317,7 +322,7 @@ function redfish_setup_hooks(bool $grant = false): void { } foreach (\Somethingwithproof\Redfish\Pages::realms() as $realm) { - api_plugin_register_realm('redfish', implode(',', $realm['files']), $realm['name'], $grant); + api_plugin_register_realm('redfish', implode(',', $realm['files']), $realm['name'], $grant && $realm['files'] !== \Somethingwithproof\Redfish\Pages::OPERATOR); } } @@ -384,6 +389,10 @@ function redfish_config_arrays(): void { function redfish_config_settings(): void { global $tabs, $settings; + if (PHP_SAPI !== 'cli' && !api_plugin_user_realm_auth('redfish_bmcs.php')) { + return; + } + if (!redfish_boot()) { return; } @@ -397,10 +406,17 @@ function redfish_config_settings(): void { * @return array