From 2dbaa89ed56783802f39888e2df2830382d33d6c Mon Sep 17 00:00:00 2001 From: TheWitness Date: Thu, 18 Apr 2024 11:15:28 -0400 Subject: [PATCH] Fixing Issue #5732 - Basic Auth login logging Web Basic Authentication does not log user logins --- CHANGELOG | 1 + include/auth.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 88de26dc1..36190ce3b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,7 @@ Cacti CHANGELOG -issue#5726: Poller cache is not updating when changing hostname -issue#5727: Incorrect values status_fail_date and status_rec_date with cmd poller -issue#5731: After Marking a Tree for Editing - Saving the Tree Unpublishes the Tree +-issue#5732: Web Basic Authentication does not log user logins -feature#5692: Add a "device enabled/disabled" indicator next to the graphs -feature#5710: Notify the admin periodically when a remote data collector goes into heartbeat status -feature#5716: Add Aruba Clearpass template diff --git a/include/auth.php b/include/auth.php index 81e248c09..c95b1ff43 100644 --- a/include/auth.php +++ b/include/auth.php @@ -98,6 +98,15 @@ if (cacti_sizeof($current_user)) { $_SESSION['sess_user_id'] = $current_user['id'];; + cacti_log("LOGIN: User '" . $user['username'] . "' authenticated via Basic Authentication.", false, 'AUTH'); + + $client_addr = get_client_addr(); + + db_execute_prepared('INSERT IGNORE INTO user_log + (username, user_id, result, ip, time) + VALUES (?, ?, 1, ?, NOW())', + array($username, $current_user['id'], $client_addr)); + return true; } else { require_once($config['base_path'] . '/auth_login.php');