Compare commits

...

2 Commits

Author SHA1 Message Date
Yasen Pramatarov db6dabedec Remove old type whitelist 2024-12-16 16:39:06 +02:00
Yasen Pramatarov bfa467996f Insert OR ignore in sql 2024-12-16 16:35:36 +02:00
4 changed files with 19 additions and 37 deletions

View File

@ -6,13 +6,10 @@ class RateLimiter {
private $decayMinutes = 15; // Time window in minutes
private $ratelimitTable = 'login_attempts';
private $whitelistTable = 'ip_whitelist';
private $whitelistedIps = []; // Whitelisted IPs
private $whitelistedNetworks = []; // Whitelisted CIDR ranges
public function __construct($database) {
$this->db = $database->getConnection();
$this->createTablesIfNotExists();
$this->loadWhitelist();
}
// Database preparation
@ -40,21 +37,6 @@ class RateLimiter {
$this->db->exec($sql);
}
// List of IPs to bypass rate limiting
private function loadWhitelist() {
// FIXME Load from database or config
$this->whitelistedIps = [
'127.0.0.1', // localhost
'::1' // localhost IPv6
];
$this->whitelistedNetworks = [
'10.0.0.0/8', // Private network
'172.16.0.0/12', // Private network
'192.168.0.0/16' // Private network
];
}
// Check if IP is whitelisted
private function isIpWhitelisted($ip) {
// Check exact IP match and CIDR ranges

View File

@ -1,5 +1,5 @@
INSERT INTO jilo_agent_types VALUES(1,'jvb','/jvb');
INSERT INTO jilo_agent_types VALUES(2,'jicofo','/jicofo');
INSERT INTO jilo_agent_types VALUES(3,'prosody','/prosody');
INSERT INTO jilo_agent_types VALUES(4,'nginx','/nginx');
INSERT INTO jilo_agent_types VALUES(5,'jibri','/jibri');
INSERT OR IGNORE INTO jilo_agent_types VALUES(1,'jvb','/jvb');
INSERT OR IGNORE INTO jilo_agent_types VALUES(2,'jicofo','/jicofo');
INSERT OR IGNORE INTO jilo_agent_types VALUES(3,'prosody','/prosody');
INSERT OR IGNORE INTO jilo_agent_types VALUES(4,'nginx','/nginx');
INSERT OR IGNORE INTO jilo_agent_types VALUES(5,'jibri','/jibri');

View File

@ -1,13 +1,13 @@
INSERT INTO rights VALUES(1,'superuser');
INSERT INTO rights VALUES(2,'edit users');
INSERT INTO rights VALUES(3,'view config file');
INSERT INTO rights VALUES(4,'edit config file');
INSERT INTO rights VALUES(5,'view own profile');
INSERT INTO rights VALUES(6,'edit own profile');
INSERT INTO rights VALUES(7,'view all profiles');
INSERT INTO rights VALUES(8,'edit all profiles');
INSERT INTO rights VALUES(9,'view app logs');
INSERT INTO rights VALUES(10,'view all platforms');
INSERT INTO rights VALUES(11,'edit all platforms');
INSERT INTO rights VALUES(12,'view all agents');
INSERT INTO rights VALUES(13,'edit all agents');
INSERT OR IGNORE INTO rights VALUES(1,'superuser');
INSERT OR IGNORE INTO rights VALUES(2,'edit users');
INSERT OR IGNORE INTO rights VALUES(3,'view config file');
INSERT OR IGNORE INTO rights VALUES(4,'edit config file');
INSERT OR IGNORE INTO rights VALUES(5,'view own profile');
INSERT OR IGNORE INTO rights VALUES(6,'edit own profile');
INSERT OR IGNORE INTO rights VALUES(7,'view all profiles');
INSERT OR IGNORE INTO rights VALUES(8,'edit all profiles');
INSERT OR IGNORE INTO rights VALUES(9,'view app logs');
INSERT OR IGNORE INTO rights VALUES(10,'view all platforms');
INSERT OR IGNORE INTO rights VALUES(11,'edit all platforms');
INSERT OR IGNORE INTO rights VALUES(12,'view all agents');
INSERT OR IGNORE INTO rights VALUES(13,'edit all agents');

View File

@ -45,7 +45,7 @@ CREATE TABLE ip_whitelist (
UNIQUE (ip_address)
);
INSERT INTO ip_whitelist (ip_address, is_network, description, created_by) VALUES
INSERT OR IGNORE INTO ip_whitelist (ip_address, is_network, description, created_by) VALUES
('127.0.0.1', 0, 'localhost IPv4', 'system'),
('::1', 0, 'localhost IPv6', 'system'),
('10.0.0.0/8', 1, 'Private network', 'system'),