diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 8fdf4f3671..de0ae5ad35 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,21 @@ +2012-05-30 Vanessa Gil + + * pandoradb.sql + pandoradb.postgreSQL.sql + pandoradb.oracle.sql + pandoradb_data.sql + pandoradb.data.oracle.sql + pandoradb.data.postgreSQL.sql + extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql + extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql + extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql + index.php + godmode/users/configure_user.php + include/functions_config.php + include/auth/mysql.php + include/javascript/jquery.pandora.js: Added admin users to password policy + and added password history. + 2012-05-30 Sergio Martin * include/functions_api.php: Added to API a test function diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql index 7c2753144f..f6c3ffb696 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.mysql.sql @@ -244,4 +244,19 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('pass_expire', 0), ('first_login', 0), ('mins_fail_pass', 5), -('number_attempts', 5); +('number_attempts', 5), +('enable_pass_policy_admin', 0), +('enable_pass_history', 0), +('compare_pass', 3); + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tpassword_history` ( + `id_pass` int(10) unsigned NOT NULL auto_increment, + `id_user` varchar(60) NOT NULL, + `password` varchar(45) default NULL, + `date_begin` DATETIME NOT NULL DEFAULT 0, + `date_end` DATETIME NOT NULL DEFAULT 0, +PRIMARY KEY (`id_pass`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql index d216026d3c..7888cb5781 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.oracle.sql @@ -247,4 +247,20 @@ INSERT INTO tconfig (token, value) VALUES ('pass_expire', 0), ('first_login', 0), ('mins_fail_pass', 5), -('number_attempts', 5); +('number_attempts', 5), +('enable_pass_policy_admin', 0), +('enable_pass_history', 0), +('compare_pass', 3); + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS tpassword_history ( + id_pass NUMBER(10) NOT NULL PRIMARY KEY, + id_user varchar2(60) NOT NULL, + password varchar2(45) default '', + date_begin TIMESTAMP DEFAULT 0, + date_end TIMESTAMP DEFAULT 0 +); +CREATE SEQUENCE tpassword_history_s INCREMENT BY 1 START WITH 1; + diff --git a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql index 220caaf0f6..4878c65d6b 100644 --- a/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql +++ b/pandora_console/extras/pandoradb_migrate_4.0.x_to_4.1.postgreSQL.sql @@ -236,4 +236,18 @@ INSERT INTO "tconfig" ("token", "value") VALUES ('pass_expire', 0), ('first_login', 0), ('mins_fail_pass', 5), -('number_attempts', 5); +('number_attempts', 5), +('enable_pass_policy_admin', 0), +('enable_pass_history', 0), +('compare_pass', 3); + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS "tpassword_history" ( + "id_pass" INTEGER NOT NULL PRIMARY KEY, + "id_user" varchar(60) NOT NULL, + "password" varchar(45) default NULL, + "date_begin" BIGINT NOT NULL default 0, + "date_end" BIGINT NOT NULL default 0, +); diff --git a/pandora_console/godmode/users/configure_user.php b/pandora_console/godmode/users/configure_user.php index 1978f91c43..be14b9bd61 100644 --- a/pandora_console/godmode/users/configure_user.php +++ b/pandora_console/godmode/users/configure_user.php @@ -173,9 +173,16 @@ if ($create_user) { case "mysql": case "postgresql": $result = create_user($id, $password_new, $values); + if ($result) { + $res = save_pass_history($id, $password_new); + } break; case "oracle": $result = db_process_sql('/INSERT INTO tusuario (fullname, firstname, lastname, email, phone, comments, is_admin, language, id_skin, block_size, flash_chart, id_user, password, last_connect, registered) VALUES (\'' . $values['fullname'] . '\',\'\',\'\',\'\',\'\',\'\',' . $values['is_admin'] . ',\'' . $values['language'] .'\',' . $values['id_skin'] . ',' . $values['block_size'] . ',' . $values['flash_chart'] . ',\'' . $id . '\',\'' . $password_new . '\',0,\'' . get_system_time () . '\')'); + + if ($result) { + $res = db_process_sql('/INSERT INTO tpassword_history (id_user, password, date_begin) VALUES (\'' . $id . '\',\'' . md5($password_new) . '\',\'' . date ("Y/m/d H:i:s", get_system_time()) . '\')'); + } break; } @@ -226,6 +233,9 @@ if ($update_user) { if ($password_new != '') { if ($password_confirm == $password_new) { $res2 = update_user_password ($id, $password_new); + if ($res2) { + $res3 = save_pass_history($id, $password_new); + } ui_print_result_message ($res1 || $res2, __('User info successfully updated'), __('Error updating user info (no change?)')); diff --git a/pandora_console/include/auth/mysql.php b/pandora_console/include/auth/mysql.php index 420a2c9fdd..3731c185d1 100644 --- a/pandora_console/include/auth/mysql.php +++ b/pandora_console/include/auth/mysql.php @@ -341,6 +341,19 @@ function create_user ($id_user, $password, $user_info) { return (@db_process_sql_insert ("tusuario", $values)) !== false; } +/** + * Save password history + * + * @return bool false + */ +function save_pass_history ($id_user, $password) { + $values["id_user"] = $id_user; + $values["password"] = md5 ($password); + $values["date_begin"] = date ("Y/m/d H:i:s", get_system_time()); + + return (@db_process_sql_insert ("tpassword_history", $values)) !== false; +} + /** * Deletes the user * diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 2cd1d758de..4e535401d0 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -225,6 +225,9 @@ function config_update_config () { $config['number_attempts'] = get_parameter('number_attempts', $config['number_attempts']); $config['pass_needs_numbers'] = get_parameter('pass_needs_numbers', $config['pass_needs_numbers']); $config['pass_needs_symbols'] = get_parameter('pass_needs_symbols', $config['pass_needs_symbols']); + $config['enable_pass_policy_admin'] = get_parameter('enable_pass_policy_admin', $config['enable_pass_policy_admin']); + $config['enable_pass_history'] = get_parameter('enable_pass_history', $config['enable_pass_history']); + $config['compare_pass'] = get_parameter('compare_pass', $config['compare_pass']); } # Update of Pandora FMS license diff --git a/pandora_console/include/javascript/jquery.pandora.js b/pandora_console/include/javascript/jquery.pandora.js index c02eab43ac..14aed14b82 100644 --- a/pandora_console/include/javascript/jquery.pandora.js +++ b/pandora_console/include/javascript/jquery.pandora.js @@ -137,8 +137,8 @@ $(document).ready (function () { resizable: true, draggable: true, modal: true, - height: 280, - width: 600, + height: 260, + width: 590, overlay: { opacity: 0.5, background: "black" diff --git a/pandora_console/index.php b/pandora_console/index.php index 12f36f805c..4ec26cbed7 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -186,7 +186,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { $expired_pass = false; - if (($nick_in_db != false)&&(!is_user_admin($nick)) && (defined('PANDORA_ENTERPRISE')) && ($config['enable_pass_policy'])) { + if (($nick_in_db != false)&& ((!is_user_admin($nick) || $config['enable_pass_policy_admin'])) && (defined('PANDORA_ENTERPRISE')) && ($config['enable_pass_policy'])) { include_once(ENTERPRISE_DIR."/include/auth/mysql.php"); $blocked = login_check_blocked($nick); @@ -284,7 +284,7 @@ elseif (! isset ($config['id_user']) && isset ($_GET["login"])) { else { //login wrong $blocked = false; - if (!is_user_admin($nick)) { + if (!is_user_admin($nick) || $config['enable_pass_policy_admin']) { $blocked = login_check_blocked($nick); } diff --git a/pandora_console/pandoradb.data.oracle.sql b/pandora_console/pandoradb.data.oracle.sql index 29457d74f1..8d49964292 100644 --- a/pandora_console/pandoradb.data.oracle.sql +++ b/pandora_console/pandoradb.data.oracle.sql @@ -100,6 +100,9 @@ INSERT INTO tconfig (token, value) VALUES ('pass_expire', 0); INSERT INTO tconfig (token, value) VALUES ('first_login', 0); INSERT INTO tconfig (token, value) VALUES ('mins_fail_pass', 5); INSERT INTO tconfig (token, value) VALUES ('number_attempts', 5); +INSERT INTO tconfig (token, value) VALUES ('enable_pass_policy_admin', 0); +INSERT INTO tconfig (token, value) VALUES ('enable_pass_history', 0); +INSERT INTO tconfig (token, value) VALUES ('compare_pass', 3); COMMIT; END;; diff --git a/pandora_console/pandoradb.data.postgreSQL.sql b/pandora_console/pandoradb.data.postgreSQL.sql index d4ffbfaf05..a09aba7f41 100644 --- a/pandora_console/pandoradb.data.postgreSQL.sql +++ b/pandora_console/pandoradb.data.postgreSQL.sql @@ -87,15 +87,18 @@ INSERT INTO "tconfig" ("token", "value") VALUES ('netflow_interval', '300'), ('netflow_daemon', '/usr/bin/nfcapd'), ('event_fields', 'evento,id_agente,estado,timestamp'), -('list_ACL_IPs_for_API_0', '127.0.0.1'); -('enable_pass_policy', 0); -('pass_size', 4); -('pass_needs_numbers', 0); -('pass_needs_simbols', 0); -('pass_expire', 0); -('first_login', 0); -('mins_fail_pass', 5); -('number_attempts', 5); +('list_ACL_IPs_for_API_0', '127.0.0.1'), +('enable_pass_policy', 0), +('pass_size', 4), +('pass_needs_numbers', 0), +('pass_needs_simbols', 0), +('pass_expire', 0), +('first_login', 0), +('mins_fail_pass', 5), +('number_attempts', 5), +('enable_pass_policy_admin', 0), +('enable_pass_history', 0), +('compare_pass', 3); COMMIT WORK; diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql index 56ec62c2c2..382ef18d96 100644 --- a/pandora_console/pandoradb.oracle.sql +++ b/pandora_console/pandoradb.oracle.sql @@ -1602,3 +1602,15 @@ CREATE TABLE IF NOT EXISTS ttimezone ( CREATE SEQUENCE ttimezone_s INCREMENT BY 1 START WITH 1; CREATE OR REPLACE TRIGGER ttimezone_inc BEFORE INSERT ON ttimezone REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT ttimezone_s.nextval INTO :NEW.ID_TZ FROM dual; END ttimezone_inc;; + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS tpassword_history ( + id_pass NUMBER(10) NOT NULL PRIMARY KEY, + id_user varchar2(60) NOT NULL, + password varchar2(45) default '', + date_begin TIMESTAMP DEFAULT 0, + date_end TIMESTAMP DEFAULT 0 +); +CREATE SEQUENCE tpassword_history_s INCREMENT BY 1 START WITH 1; diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql index d2f4ee911b..4f01733c39 100644 --- a/pandora_console/pandoradb.postgreSQL.sql +++ b/pandora_console/pandoradb.postgreSQL.sql @@ -1297,3 +1297,14 @@ CREATE TABLE "ttimezone" ( "zone" varchar(60) NOT NULL, "timezone" varchar(60) NOT NULL ); + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS "tpassword_history" ( + "id_pass" INTEGER NOT NULL PRIMARY KEY, + "id_user" varchar(60) NOT NULL, + "password" varchar(45) default NULL, + "date_begin" BIGINT NOT NULL default 0, + "date_end" BIGINT NOT NULL default 0, +); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 4e22828555..ba5939d658 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1403,3 +1403,15 @@ CREATE TABLE IF NOT EXISTS `ttimezone` ( `timezone` varchar(60) NOT NULL, PRIMARY KEY (`id_tz`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ----------------------------------------------------- +-- Table `tpassword_history` +-- ----------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tpassword_history` ( + `id_pass` int(10) unsigned NOT NULL auto_increment, + `id_user` varchar(60) NOT NULL, + `password` varchar(45) default NULL, + `date_begin` DATETIME NOT NULL DEFAULT 0, + `date_end` DATETIME NOT NULL DEFAULT 0, +PRIMARY KEY (`id_pass`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/pandora_console/pandoradb_data.sql b/pandora_console/pandoradb_data.sql index 7be3682f86..858fe156e9 100644 --- a/pandora_console/pandoradb_data.sql +++ b/pandora_console/pandoradb_data.sql @@ -94,7 +94,10 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES ('pass_expire', 0), ('first_login', 0), ('mins_fail_pass', 5), -('number_attempts', 5); +('number_attempts', 5), +('enable_pass_policy_admin', 0), +('enable_pass_history', 0), +('compare_pass', 3); UNLOCK TABLES;