Audit logs stage 3: failed sign-ins say why and are logged against the account they were for - wrong password, no account with that email, disabled, archived or invited account, client archived, portal turned off, a wrong MFA or two-step code after the right password - with failed Microsoft 365 portal sign-ins logged too and marked Their account in the audit log; the IP lockout counts portal failures as well; the first sign-in from an IP address is badged New IP in the audit lists and quick look; new Admin > Sign-ins under Access with People and IP addresses views, search, date filter, sortable columns and paging; admins get a notification and an email on a run of failed sign-ins or turned-away API calls from one address or against one account, set in Settings > Security (10 to start, 5, 20, 50 or never), each in the audit log Security view and in Mail > Previews; API calls counted per key, day and endpoint, with a 30-day calls column and last IP on API Keys and a usage window, expired-key calls logged against the key, and usage deleted with the key and after the log retention; database 3.3.2 drops the unused auth_logs table and adds settings.config_login_alert_failures and api_key_usage; new functions/sign_in.php, admin/sign_ins.php and admin/modals/api/api_key_usage.php; the license template page no longer warns when view is missing

This commit is contained in:
johnnyq
2026-10-19 00:56:52 -04:00
parent f43d4a9127
commit a5a43e37ac
25 changed files with 1022 additions and 72 deletions

38
db.sql
View File

@@ -104,6 +104,24 @@ CREATE TABLE `ai_providers` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `api_key_usage`
--
DROP TABLE IF EXISTS `api_key_usage`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `api_key_usage` (
`api_key_usage_key_id` int(11) NOT NULL,
`api_key_usage_date` date NOT NULL,
`api_key_usage_endpoint` varchar(100) NOT NULL DEFAULT '',
`api_key_usage_calls` int(11) NOT NULL DEFAULT 0,
`api_key_usage_last_at` datetime NOT NULL DEFAULT current_timestamp(),
`api_key_usage_last_ip` varchar(200) DEFAULT NULL,
PRIMARY KEY (`api_key_usage_key_id`,`api_key_usage_date`,`api_key_usage_endpoint`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `api_keys`
--
@@ -368,25 +386,6 @@ CREATE TABLE `assets` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `auth_logs`
--
DROP TABLE IF EXISTS `auth_logs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `auth_logs` (
`auth_log_id` int(11) NOT NULL AUTO_INCREMENT,
`auth_log_status` tinyint(1) NOT NULL,
`auth_log_details` varchar(200) DEFAULT NULL,
`auth_log_ip` varchar(200) DEFAULT NULL,
`auth_log_user_agent` varchar(250) DEFAULT NULL,
`auth_log_user_id` int(11) NOT NULL DEFAULT 0,
`auth_log_created_at` datetime NOT NULL DEFAULT current_timestamp(),
PRIMARY KEY (`auth_log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Table structure for table `backups`
--
@@ -2945,6 +2944,7 @@ CREATE TABLE `settings` (
`config_update_checked_at` datetime DEFAULT NULL,
`config_share_max_hours` int(11) NOT NULL DEFAULT 720,
`config_share_require_protection` tinyint(1) NOT NULL DEFAULT 0,
`config_login_alert_failures` int(11) NOT NULL DEFAULT 10,
PRIMARY KEY (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;