From 6a21a668bf6721d24ea5d2027c27b0b45e7afc75 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 29 Sep 2020 09:44:20 +0200 Subject: [PATCH 1/4] Added control for reveal passwords --- .../godmode/setup/setup_general.php | 7 +++++-- pandora_console/include/functions_ui.php | 20 +++++++++++++++++++ .../include/javascript/pandora_ui.js | 13 ++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 0d8ce68e8e..e4aa1181a9 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -124,7 +124,8 @@ $table->data[$i][0] = __('Phantomjs bin directory'); $table->data[$i++][1] = html_print_input_text('phantomjs_bin', io_safe_output($config['phantomjs_bin']), '', 30, 100, true); $table->data[$i][0] = __('Auto login (hash) password'); -$table->data[$i++][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true); +$table->data[$i][1] = html_print_input_password('loginhash_pwd', io_output_password($config['loginhash_pwd']), '', 15, 15, true); +$table->data[$i++][1] .= ui_print_reveal_password('loginhash_pwd', true); $table->data[$i][0] = __('Time source'); $sources['system'] = __('System'); @@ -162,7 +163,8 @@ if (isset($_POST['list_ACL_IPs_for_API'])) { $table->data[$i++][1] = html_print_textarea('list_ACL_IPs_for_API', 2, 25, $list_ACL_IPs_for_API, 'style="height: 50px; width: 300px"', true); $table->data[$i][0] = __('API password'); -$table->data[$i++][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); +$table->data[$i][1] = html_print_input_password('api_password', io_output_password($config['api_password']), '', 25, 255, true); +$table->data[$i++][1] .= ui_print_reveal_password('api_password', true); $table->data[$i][0] = __('Enable GIS features'); $table->data[$i++][1] = html_print_checkbox_switch('activate_gis', 1, $config['activate_gis'], true); @@ -384,6 +386,7 @@ $table_mail_conf->data[5][1] = html_print_input_text('email_username', $config[' $table_mail_conf->data[6][0] = __('Email password'); $table_mail_conf->data[6][1] = html_print_input_password('email_password', io_output_password($config['email_password']), '', 30, 100, true); +$table_mail_conf->data[6][1] .= ui_print_reveal_password('email_password', true); $uniqid = uniqid(); diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ab6079fb36..2233b2fe95 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6124,3 +6124,23 @@ function ui_print_message_dialog($title, $text, $id='', $img='', $text_button='' echo ''; echo ''; } + + +/** + * Generate a button for reveal the content of the password field. + * + * @param string $name Name of the field. + * @param boolean $return If true, return the string with the formed element. + * + * @return string + */ +function ui_print_reveal_password(string $name, bool $return=false) +{ + $output = ' '; + + if ($return === true) { + return $output; + } + + echo $output; +} diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 2445473591..951db0e712 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -552,3 +552,16 @@ function infoMessage(data, idMsg) { }) .show(); } + +function reveal_password(name) { + var passwordElement = $("#password-" + name); + var revealElement = $("#reveal_password_" + name); + + if (passwordElement.attr("type") == "password") { + passwordElement.attr("type", "text"); + revealElement.attr("src", "images/eye_hide.png"); + } else { + passwordElement.attr("type", "password"); + revealElement.attr("src", "images/eye_show.png"); + } +} From 9d0becc0122e7029bed214d1c84bd9cb5aa7d920 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 29 Sep 2020 10:12:49 +0200 Subject: [PATCH 2/4] Added other password fields --- pandora_console/extensions/quick_shell.php | 1 + pandora_console/godmode/setup/setup_auth.php | 4 ++++ pandora_console/godmode/setup/setup_ehorus.php | 1 + pandora_console/godmode/setup/setup_integria.php | 2 ++ 4 files changed, 8 insertions(+) diff --git a/pandora_console/extensions/quick_shell.php b/pandora_console/extensions/quick_shell.php index 27807e6029..5505caa3af 100644 --- a/pandora_console/extensions/quick_shell.php +++ b/pandora_console/extensions/quick_shell.php @@ -468,6 +468,7 @@ function quickShellSettings() 100, true ); + $hidden->data[1][1] .= ui_print_reveal_password('gotty_pass', true); html_print_table($t); diff --git a/pandora_console/godmode/setup/setup_auth.php b/pandora_console/godmode/setup/setup_auth.php index db436224c3..eba3b44e0d 100644 --- a/pandora_console/godmode/setup/setup_auth.php +++ b/pandora_console/godmode/setup/setup_auth.php @@ -189,6 +189,10 @@ if (is_ajax()) { 100, true ); + $row['control'] .= ui_print_reveal_password( + 'ldap_admin_pass', + true + ); $table->data['ldap_admin_pass'] = $row; break; diff --git a/pandora_console/godmode/setup/setup_ehorus.php b/pandora_console/godmode/setup/setup_ehorus.php index 1c3650418b..1c522593ee 100644 --- a/pandora_console/godmode/setup/setup_ehorus.php +++ b/pandora_console/godmode/setup/setup_ehorus.php @@ -82,6 +82,7 @@ $table_remote->data['ehorus_user'] = $row; $row = []; $row['name'] = __('Password'); $row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true); +$row['control'] .= ui_print_reveal_password('ehorus_pass', true); $table_remote->data['ehorus_pass'] = $row; // Directory hostname. diff --git a/pandora_console/godmode/setup/setup_integria.php b/pandora_console/godmode/setup/setup_integria.php index e172dda50b..0113c6f024 100644 --- a/pandora_console/godmode/setup/setup_integria.php +++ b/pandora_console/godmode/setup/setup_integria.php @@ -221,6 +221,7 @@ $table_remote->data['integria_user'] = $row; $row = []; $row['name'] = __('Password'); $row['control'] = html_print_input_password('integria_pass', io_output_password($config['integria_pass']), '', 30, 100, true); +$row['control'] .= ui_print_reveal_password('integria_pass', true); $table_remote->data['integria_pass'] = $row; // Integria hostname. @@ -233,6 +234,7 @@ $table_remote->data['integria_hostname'] = $row; $row = []; $row['name'] = __('API Password'); $row['control'] = html_print_input_password('integria_api_pass', io_output_password($config['integria_api_pass']), '', 30, 100, true); +$row['control'] .= ui_print_reveal_password('integria_api_pass', true); $table_remote->data['integria_api_pass'] = $row; // Request timeout. From 00b289a557f73cda6656c14aed17495a7f040800 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 29 Sep 2020 12:21:52 +0200 Subject: [PATCH 3/4] Adapt functions for work in Metaconsole --- pandora_console/include/functions_ui.php | 8 +++++++- pandora_console/include/javascript/pandora_ui.js | 11 +++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 2233b2fe95..a6fe8579c0 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -6136,7 +6136,13 @@ function ui_print_message_dialog($title, $text, $id='', $img='', $text_button='' */ function ui_print_reveal_password(string $name, bool $return=false) { - $output = ' '; + if (is_metaconsole()) { + $imagePath = '../../images/'; + } else { + $imagePath = 'images/'; + } + + $output = ' '; if ($return === true) { return $output; diff --git a/pandora_console/include/javascript/pandora_ui.js b/pandora_console/include/javascript/pandora_ui.js index 951db0e712..c2b6a86e01 100644 --- a/pandora_console/include/javascript/pandora_ui.js +++ b/pandora_console/include/javascript/pandora_ui.js @@ -556,12 +556,19 @@ function infoMessage(data, idMsg) { function reveal_password(name) { var passwordElement = $("#password-" + name); var revealElement = $("#reveal_password_" + name); + var imagesPath = ""; + + if ($("#hidden-metaconsole_activated").val() == 1) { + imagesPath = "../../images/"; + } else { + imagesPath = "images/"; + } if (passwordElement.attr("type") == "password") { passwordElement.attr("type", "text"); - revealElement.attr("src", "images/eye_hide.png"); + revealElement.attr("src", imagesPath + "eye_hide.png"); } else { passwordElement.attr("type", "password"); - revealElement.attr("src", "images/eye_show.png"); + revealElement.attr("src", imagesPath + "eye_show.png"); } } From 336f6924dfb2cdbba9a6174883e45074cc255cd5 Mon Sep 17 00:00:00 2001 From: Jose Gonzalez Date: Tue, 29 Sep 2020 12:22:29 +0200 Subject: [PATCH 4/4] Added images --- pandora_console/images/eye_hide.png | Bin 0 -> 647 bytes pandora_console/images/eye_show.png | Bin 0 -> 1365 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 pandora_console/images/eye_hide.png create mode 100644 pandora_console/images/eye_show.png diff --git a/pandora_console/images/eye_hide.png b/pandora_console/images/eye_hide.png new file mode 100644 index 0000000000000000000000000000000000000000..8bed55e59977e35c254f877c03df36aedf39412b GIT binary patch literal 647 zcmV;20(kw2P)%GWaHovko20yJC5`{2QT3`qk?YwE%)BN zKR>?jdk^^Ml}e>9x%c!hVb>|8&pVyY#o0fyXi!m2qCwB04j>IMk%cUkbmXOvMflFG-|iogFqng9>69c#0FfE6-Bv4DShFA z?Q+i7RaGUN^K}54X_|;cB4{?7OS-O~&*gFtX0W+K2e#ue@{n_0cN|9n3`V07iN#`9 z%H{Go#u$3N9snG2&Mz~@_5gq=iXuDC+&WZMbt#j{yaBK#gurAn!RqSjxKgQ@jYcD= z>w3^VKZ8w64Tr-Nfaro$ zyQ->g%z?oCVrl>))9DnJWrI>IXga3|%s z00U{hPY4Tqa`c^Vg*E^*{bD4lMuXjKLQb3cBF3CcXD}Opw)R|xPYehuj0=6D zO-ZKMFz4U#g(WA^uc{fABu7R@%pIUaOgcK|Uc$MNP3m+xc>W zA`S~lzappMR)tw{j|dRuK+k6Guv31Hwpn}*#)d33L+o&q|EFps4u&j_$1~$nQsEga z9(RWy3%lzhNO)%yyc`P)m%qpR`F?m6kAcvzv)lS(rn>Lx#@{oY6O-`x z3-H<^t7!n*YH9jTy=S%yg#Ws?=2{tTxmu}yqiHV8ts@^i?XJIgdddCkkxpad`RlIz zHHDvzu3O_xH(rAIsS~$vx|(8~athpT4?WPpVeR_MH_PsRr=51r&*?(Hyq(`zYwLQ? zefPCOa|3u-)?xxRr>;wv;L@w^Gj)YQ-Mn8vAJ;d}AIE?u&-w=_xR~!)o6*pdu`3g_ zDL*>7aj&vE#$D(<9E%q$uA{Ssv-d0F6~rT3`9p0Ctj_6brlOXrGx~X*;m%{7@1(PO zA6$3>f~kEgde6DfzHq)$ literal 0 HcmV?d00001