From d72f9fdac0c0aaa20e146ef089577548d9f03d83 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 16 Dec 2020 17:38:40 +0100 Subject: [PATCH] SAML login in mobile console --- pandora_console/mobile/include/user.class.php | 59 ++++++++++++++++++- pandora_console/mobile/operation/home.php | 7 +++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/pandora_console/mobile/include/user.class.php b/pandora_console/mobile/include/user.class.php index 61267f2023..eb1af4c10d 100644 --- a/pandora_console/mobile/include/user.class.php +++ b/pandora_console/mobile/include/user.class.php @@ -86,6 +86,36 @@ class User { $system = System::getInstance(); + if ((bool) $system->getRequest('saml', false) === true) { + if ($system->getConfig('auth', 'mysql') !== 'saml') { + // Ignore. + return false; + } else { + \enterprise_include_once('include/auth/saml.php'); + $saml_user_id = enterprise_hook('saml_process_user_login'); + if (!$saml_user_id) { + $this->logged = false; + } else { + $this->logged = true; + $this->user = $saml_user_id; + $this->loginTime = time(); + $this->errorLogin = false; + } + + $this->saveLogin(); + return $this->logged; + } + } else if ($system->getConfig('auth', 'mysql') === 'saml') { + // Maybe back from SAML login. + $saml_session = $system->getSession('samlid', null); + if ($saml_session !== null) { + $this->user = $system->getSession('id_usuario', null); + $this->loginTime = time(); + $this->errorLogin = false; + $this->logged = true; + } + } + if (($user == null) && ($password == null)) { $user = $system->getRequest('user', null); $password = $system->getRequest('password', null); @@ -205,6 +235,12 @@ class User public function logout() { + $system = System::getInstance(); + if ($system->getConfig('auth', 'mysql') === 'saml') { + \enterprise_include_once('include/auth/saml.php'); + \enterprise_hook('saml_logout'); + } + $this->user = null; $this->logged = false; $this->loginTime = false; @@ -213,7 +249,6 @@ class User $this->needDoubleAuth = false; $this->errorDoubleAuth = false; - $system = System::getInstance(); $system->setSession('user', null); $system->sessionDestroy(); } @@ -286,7 +321,29 @@ class User 'name' => 'login_btn', ]; $ui->formAddSubmitButton($options); + $ui->endForm(); + + if ($system->getConfig('auth', 'mysql') === 'saml') { + // Add SAML login button. + $ui->beginForm(''); + $ui->formAddHtml( + html_print_input_hidden('action', 'login', true) + ); + $ui->formAddHtml( + html_print_input_hidden('saml', '1', true) + ); + $ui->formAddSubmitButton( + [ + 'value' => __('Login with SAML'), + 'icon' => 'arrow-r', + 'icon_pos' => 'right', + 'name' => 'login_button_saml', + ] + ); + $ui->endForm(''); + } + $ui->contentAddHtml(''); $ui->endContent(); $ui->showPage(); diff --git a/pandora_console/mobile/operation/home.php b/pandora_console/mobile/operation/home.php index b172d16021..d49f42eb0b 100644 --- a/pandora_console/mobile/operation/home.php +++ b/pandora_console/mobile/operation/home.php @@ -59,6 +59,12 @@ class Home 'menu_item' => true, 'icon' => 'groups', ]; + $items['console'] = [ + 'name' => __('Visual consoles'), + 'filename' => 'vconsole.php', + 'menu_item' => true, + 'icon' => 'consoles', + ]; if (!$system->getConfig('metaconsole')) { $items['alerts'] = [ @@ -74,6 +80,7 @@ class Home 'menu_item' => true, 'icon' => 'agents', ]; + $items['modules'] = [ 'name' => __('Modules'), 'filename' => 'modules.php',