Files
cacti/include/config.php.dist
T
Thomas Vincent 0805aa1def fix(auth): [develop] bind Basic sessions to verified identities (#8537)
* fix(auth): bind Basic sessions to verified upstream identities

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(auth): use behavioral proxy identity coverage

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): keep Basic guest sessions bound to their upstream identity

An upstream-verified user with no realm 2 row is logged in as the guest
account by auth_login.php. The identity check then found no user row on
the next request, destroyed the session and re-ran auth_login.php, so
every request ended in another login redirect.

Record the Basic username in the session when auth_login.php
establishes it, and treat a guest session as valid while that recorded
name matches the current upstream identity and the guest account is
still enabled. A different identity, or a realm 2 row created later,
still replaces the session.

Extend the Basic e2e test with a guest-account case on a guest page.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(auth): match session-user assignments, not comparisons, in the sweep

The sweep that requires cacti_auth_transition() near every write of
$_SESSION[SESS_USER_ID] matched '=' at the start of '===', so the guest
session check in include/auth.php was reported as an uncovered write.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): look up Basic sessions by the sanitized login name

auth_login.php creates and resolves the realm 2 account from
sanitize_search_string() of the upstream name, but the per-request check
looked the row up with the raw name. A name that sanitization changes,
such as o'brien, never matched its own row, so every request destroyed
the session and ran auth_login.php again.

Look the row up by the sanitized name and bind every Basic session, not
only guest sessions, to the raw upstream name recorded at login, so a
different upstream identity that maps to the same account still starts
a new session.

Also map $auth_basic_allow_php_auth_user into $config like
$trusted_proxies, name the setting in the changelog fragment, and drop a
doubled blank line in config.php.dist.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* test(phpstan): match the $config shape that includes the Basic opt-in

Mapping $auth_basic_allow_php_auth_user into $config changed the array
shape PHPStan prints for include/global.php, so two existing baseline
entries stopped matching and repo-wide analysis reported them as new.
Update the two messages to the new shape; no entry is added.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

* fix(auth): log the PHP_AUTH_USER opt-in when Basic login finds no identity

An upgraded site whose web server only sets PHP_AUTH_USER now gets the
"no username was passed" page, because that value is no longer trusted
by default. Log a hint naming $auth_basic_allow_php_auth_user so the
administrator can find the setting. The page text is unchanged and the
client-supplied value is never logged. The Basic e2e test asserts the
hint for a decoded client credential.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>

---------

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
2026-11-17 13:46:51 -05:00

303 lines
9.4 KiB
Plaintext

<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2026 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/*
* Make sure these values reflect your actual database/host/user/password
*/
$database_type = 'mysql';
$database_default = 'cacti';
$database_hostname = 'localhost';
$database_username = 'cactiuser';
$database_password = 'cactiuser';
$database_port = 3306;
$database_retries = 5;
$database_ssl = false;
$database_ssl_key = '';
$database_ssl_cert = '';
$database_ssl_ca = '';
$database_ssl_capath = '';
$database_ssl_verify_server_cert = true;
$database_persist = false;
/*
* When the cacti server is a remote poller, then these entries point to
* the main cacti server. Otherwise, these variables have no use and
* must remain commented out.
*/
#$rdatabase_type = 'mysql';
#$rdatabase_default = 'cacti';
#$rdatabase_hostname = 'localhost';
#$rdatabase_username = 'cactiuser';
#$rdatabase_password = 'cactiuser';
#$rdatabase_port = 3306;
#$rdatabase_retries = 5;
#$rdatabase_ssl = false;
#$rdatabase_ssl_key = '';
#$rdatabase_ssl_cert = '';
#$rdatabase_ssl_ca = '';
#$rdatabase_ssl_capath = '';
#$rdatabase_ssl_verify_server_cert = true;
/*
* The poller_id of this system. set to `1` for the main cacti web server.
* Otherwise, you this value should be the poller_id for the remote poller.
*/
$poller_id = 1;
/*
* Set the $url_path to point to the default URL of your cacti install.
* For example if your cacti install as at `https://serverip/cacti/` this
* would be set to `/cacti/`.
*/
$url_path = '/cacti/';
/*
* Default session name - session name must contain alpha characters
*/
$cacti_session_name = 'Cacti';
if (isset($_COOKIE['CactiTab'])) {
$cacti_session_name = 'CactiTabId:' . $_COOKIE['CactiTab'];
}
/*
* Default Cookie domain - The cookie domain to be used for Cacti
*/
//$cacti_cookie_domain = 'cacti.net';
/*
* Save sessions to a database for load balancing
*/
$cacti_db_session = false;
/*
* Disable log rotation settings for packagers
*/
$disable_log_rotation = false;
/*
* Optional parameters to define scripts, resource, and rra paths. These
* variables become important when using remote poller installs when the
* scripts and resource files are not in the main Cacti web server path.
*/
//$scripts_path = '/var/www/html/cacti/scripts';
//$resource_path = '/var/www/html/cacti/resource/';
//$rra_path = '/var/www/html/cacti/rra/';
//$package_keys_path = '/etc/cacti/pki';
/*
* Optional parameter to define the directory used by Cacti's shared object
* cache (for example the pre-hardened SNMP credential cache). When unset, Cacti
* uses cache/ below the installation path and creates it when needed. The
* directory must be private and writable by the poller/web server user; if it
* cannot be created or written, the shared cache degrades to per-process storage
* rather than falling back to a world-writable system temporary directory.
*/
//$config['cache_dir'] = '/var/www/html/cacti/cache';
/*
* Optional parameter to define a data input whitelist command string. This
* whitelist file will help protect cacti from unauthorized changes to Cacti
* data input command string.
*/
//$input_whitelist = '/usr/local/etc/cacti/input_whitelist.json';
/*
* Optional parameter to give explicit path to PHP
*/
//$php_path = '/bin/php';
/*
* Optional parameter to disable the PHP SNMP extension. If not set, defaults
* to class_exists('SNMP').
*/
//$php_snmp_support = false;
/*
* Optional parameter to define the path of the csrf_secret.php path. This
* variable is for packagers who wish to specify an alternate location of
* the CRSF secret file.
*/
//$path_csrf_secret = '/usr/share/cacti/resource/csrf-secret.php';
/*
* The following are optional variables for debugging low level system
* functions that are generally only used by Cacti Developers to help
* identify potential issues in commonly used functions
*
* To use them, uncomment and the equivalent field will be set in the
* $config variable allowing for instant on but still allowing the
* ability to fine turn and turn them off.
*/
/*
* Debug the read_config_option program flow
*/
#if (!defined('DEBUG_READ_CONFIG_OPTION')) {
# define('DEBUG_READ_CONFIG_OPTION', true);
#}
/*
* Automatically suppress the DEBUG_READ_CONFIG_OPTION
*/
#if (!defined('DEBUG_READ_CONFIG_OPTION_DB_OPEN')) {
# define('DEBUG_READ_CONFIG_OPTION_DB_OPEN', true);
#}
/*
* Always write the SQL command to the cacti log file
*/
#if (!defined('DEBUG_SQL_CMD')) {
# define('DEBUG_SQL_CMD', true);
#}
/*
* Debug the flow of calls to the db_xxx functions that
* are defined in lib/database.php
*/
#if (!defined('DEBUG_SQL_FLOW')) {
# define('DEBUG_SQL_FLOW', true);
#}
/**
* Debug the connect and disconnect activity
* and the first execute from each connection
* to the PHP error_log.
*/
#if (!defined('DEBUG_SQL_CONNECT')) {
# define('DEBUG_SQL_CONNECT', true);
#}
/**
* Allow the use of Proxy IPs when searching for client
* IP to be used
*
* This can be set to one of the following:
* - false: to use only REMOTE_ADDR
* - true: to use all allowed headers (not advised)
* - array of one or more the following:
* 'X-Forwarded-For',
* 'X-Client-IP',
* 'X-Real-IP',
* 'X-ProxyUser-Ip',
* 'CF-Connecting-IP',
* 'True-Client-IP',
* 'HTTP_X_FORWARDED',
* 'HTTP_X_FORWARDED_FOR',
* 'HTTP_X_CLUSTER_CLIENT_IP',
* 'HTTP_FORWARDED_FOR',
* 'HTTP_FORWARDED',
* 'HTTP_CLIENT_IP',
*
* NOTE: The following will always be checked:
* 'REMOTE_ADDR',
*/
$proxy_headers = null;
/**
* List the REMOTE_ADDR values of the reverse proxies that are
* permitted to assert a pre-authenticated user via forwarded
* headers such as:
* 'X-Forwarded-User',
* 'PHP-Auth-User',
* 'Remote-User',
* 'Redirect-Remote-User',
*
* When a request arrives from one of these addresses, Cacti will
* honor the forwarded identity header. Requests from any other
* address have their forwarded identity headers ignored.
*
* This list also governs the client address reported by
* get_client_addr(). A proxy appends to headers such as
* X-Forwarded-For, so the leftmost entry is whatever the client
* chose to send. Cacti walks the chain from the right, discarding
* hops that are themselves trusted, and reports the first address
* a trusted hop actually observed.
*
* Empty (the default) means no proxy is trusted, so all forwarded
* headers are ignored and REMOTE_ADDR is used. Entries may be a
* plain address or a CIDR range such as '10.0.0.0/8'.
*/
$trusted_proxies = [];
/*
* PHP_AUTH_USER can come directly from an unverified client Authorization header.
* Enable this compatibility option only when the web server verifies the password
* before passing every request to PHP. Prefer the server's REMOTE_USER identity.
* Trusted proxies must replace client identity headers before forwarding them.
*/
$auth_basic_allow_php_auth_user = false;
/*
* Set this to define the default i18n handler if not set
* in the database. For valid values, see CACTI_LANGUAGE_HANDLER
* constants but only use the value not the constant name
* here because we have not included global_constants.php
* yet
*/
$i18n_handler = null;
/*
* Set this to define ignore everything else and force a
* specific language. Should be in the format of a string
* such as 'es-ES'
*/
$i18n_force_language = null;
/**
* Define the location to log general i18n function calls
* to for debugging purposes. Note that if you use /tmp
* some systemd systems will remap that folder to special
* locations under /tmp/systemd<uniqueid>/tmp
*/
$i18n_log = null;
/**
* Define the location to log translation i18n function calls
* to for debugging purposes. Note that if you use /tmp
* some systemd systems will remap that folder to special
* locations under /tmp/systemd<uniqueid>/tmp
*/
$i18n_text_log = null;
/**
* Define the array of IP addresses whitelisted for
* remote agent communication.
*
* Example:
*
* $remote_agent_whitelist = ['1.2.3.4'];
*
*/
$remote_agent_whitelist = array();