diff --git a/core/authentication/resources/classes/authentication.php b/core/authentication/resources/classes/authentication.php index e03048a9ef..403e4672ca 100644 --- a/core/authentication/resources/classes/authentication.php +++ b/core/authentication/resources/classes/authentication.php @@ -113,13 +113,9 @@ class authentication { $object->username = $this->username; $object->password = $this->password; } - //database plugin requires the authentication object and settings - if ($name == 'database') { - $array = $object->$name($this, $settings); - } else { - //get the array from the plugin - $array = $object->$name(); - } + //initialize the plugin send the authentication object and settings + $array = $object->$name($this, $settings); + //build a result array if (!empty($array) && is_array($array)) { $result['plugin'] = $array["plugin"]; diff --git a/core/authentication/resources/classes/plugins/email.php b/core/authentication/resources/classes/plugins/email.php index a74f9983b5..286aa75220 100644 --- a/core/authentication/resources/classes/plugins/email.php +++ b/core/authentication/resources/classes/plugins/email.php @@ -55,18 +55,21 @@ class plugin_email { * time based one time password with email * @return array [authorized] => true or false */ - function email() { + function email(authentication $auth, settings $settings) { //pre-process some settings - $settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico'; - $settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : ''; - $settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : ''; - $settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png'; - $settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px'; - $settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px'; - $settings['theme']['message_delay'] = isset($_SESSION['theme']['message_delay']) ? 1000 * (float) $_SESSION['theme']['message_delay'] : 3000; - $settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null; - + $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); + $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); + $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); + $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); + $background_videos = $settings->get('theme', 'background_video', null); + $theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null; + //$login_domain_name_visible = $settings->get('login', 'domain_name_visible'); + //$login_domain_name = $settings->get('login', 'domain_name'); + $login_destination = $settings->get('login', 'destination'); + $users_unique = $settings->get('users', 'unique', ''); + //get the domain $domain_array = explode(":", $_SERVER["HTTP_HOST"]); $domain_name = $domain_array[0]; @@ -93,16 +96,16 @@ class plugin_email { //assign default values to the template $view->assign("project_path", PROJECT_PATH); - $view->assign("login_destination_url", $settings['login']['destination']); - $view->assign("favicon", $settings['theme']['favicon']); + $view->assign("login_destination_url", $login_destination); + $view->assign("favicon", $theme_favicon); $view->assign("login_title", $text['label-username']); $view->assign("login_username", $text['label-username']); - $view->assign("login_logo_width", $settings['theme']['login_logo_width']); - $view->assign("login_logo_height", $settings['theme']['login_logo_height']); - $view->assign("login_logo_source", $settings['theme']['logo']); + $view->assign("login_logo_width", $theme_login_logo_width); + $view->assign("login_logo_height", $theme_login_logo_height); + $view->assign("login_logo_source", $theme_logo); $view->assign("button_login", $text['button-login']); - $view->assign("message_delay", $settings['theme']['message_delay']); - $view->assign("background_video", $settings['theme']['background_video']); + $view->assign("message_delay", $theme_message_delay); + $view->assign("background_video", $theme_background_video); //messages $view->assign('messages', message::html(true, ' ')); @@ -129,7 +132,7 @@ class plugin_email { $sql .= " username = :username\n"; $sql .= " or user_email = :username\n"; $sql .= ")\n"; - if ($settings['users']['unique'] != "global") { + if ($users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION["domain_uuid"]; @@ -330,16 +333,16 @@ class plugin_email { //assign default values to the template $view->assign("project_path", PROJECT_PATH); - $view->assign("login_destination_url", $settings['login']['destination']); - $view->assign("favicon", $settings['theme']['favicon']); + $view->assign("login_destination_url", $login_destination); + $view->assign("favicon", $theme_favicon); $view->assign("login_title", $text['label-verify']); $view->assign("login_email_description", $text['label-email_description']); $view->assign("login_authentication_code", $text['label-authentication_code']); - $view->assign("login_logo_width", $settings['theme']['login_logo_width']); - $view->assign("login_logo_height", $settings['theme']['login_logo_height']); - $view->assign("login_logo_source", $settings['theme']['logo']); + $view->assign("login_logo_width", $theme_login_logo_width); + $view->assign("login_logo_height", $theme_login_logo_height); + $view->assign("login_logo_source", $theme_logo); $view->assign("button_verify", $text['label-verify']); - $view->assign("message_delay", $settings['theme']['message_delay']); + $view->assign("message_delay", $theme_message_delay); if (!empty($_SESSION['username'])) { $view->assign("username", $_SESSION['username']); $view->assign("button_cancel", $text['button-cancel']); @@ -377,7 +380,7 @@ class plugin_email { $sql .= " username = :username\n"; $sql .= " or user_email = :username\n"; $sql .= ")\n"; - if ($settings['users']['unique'] != "global") { + if ($users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION["domain_uuid"]; @@ -431,7 +434,7 @@ class plugin_email { } $sql .= "where "; $sql .= " u.user_uuid = :user_uuid "; - if ($settings['users']['unique'] != "global") { + if ($users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and u.domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION["domain_uuid"]; diff --git a/core/authentication/resources/classes/plugins/ldap.php b/core/authentication/resources/classes/plugins/ldap.php index 2b0bf24d90..fdeff4dbc7 100644 --- a/core/authentication/resources/classes/plugins/ldap.php +++ b/core/authentication/resources/classes/plugins/ldap.php @@ -31,7 +31,7 @@ class plugin_ldap { * ldap checks a local or remote ldap database to authenticate the user * @return array [authorized] => true or false */ - function ldap() { + function ldap(authentication $auth, settings $settings) { //show the authentication code view if ($_REQUEST["username"]) { diff --git a/core/authentication/resources/classes/plugins/totp.php b/core/authentication/resources/classes/plugins/totp.php index 69fd165b6f..cf911c80a8 100644 --- a/core/authentication/resources/classes/plugins/totp.php +++ b/core/authentication/resources/classes/plugins/totp.php @@ -57,18 +57,21 @@ class plugin_totp { * time based one time password aka totp * @return array [authorized] => true or false */ - function totp() { + function totp(authentication $auth, settings $settings) { //pre-process some settings - $settings['theme']['favicon'] = !empty($_SESSION['theme']['favicon']['text']) ? $_SESSION['theme']['favicon']['text'] : PROJECT_PATH.'/themes/default/favicon.ico'; - $settings['login']['destination'] = !empty($_SESSION['login']['destination']['text']) ? $_SESSION['login']['destination']['text'] : ''; - $settings['users']['unique'] = !empty($_SESSION['users']['unique']['text']) ? $_SESSION['users']['unique']['text'] : ''; - $settings['theme']['logo'] = !empty($_SESSION['theme']['logo']['text']) ? $_SESSION['theme']['logo']['text'] : PROJECT_PATH.'/themes/default/images/logo_login.png'; - $settings['theme']['login_logo_width'] = !empty($_SESSION['theme']['login_logo_width']['text']) ? $_SESSION['theme']['login_logo_width']['text'] : 'auto; max-width: 300px'; - $settings['theme']['login_logo_height'] = !empty($_SESSION['theme']['login_logo_height']['text']) ? $_SESSION['theme']['login_logo_height']['text'] : 'auto; max-height: 300px'; - $settings['theme']['message_delay'] = isset($_SESSION['theme']['message_delay']) ? 1000 * (float) $_SESSION['theme']['message_delay'] : 3000; - $settings['theme']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null; - + $theme_favicon = $settings->get('theme', 'favicon', PROJECT_PATH.'/themes/default/favicon.ico'); + $theme_logo = $settings->get('theme', 'logo', PROJECT_PATH.'/themes/default/images/logo_login.png'); + $theme_login_logo_width = $settings->get('theme', 'login_logo_width', 'auto; max-width: 300px'); + $theme_login_logo_height = $settings->get('theme', 'login_logo_height', 'auto; max-height: 300px'); + $theme_message_delay = 1000 * (float)$settings->get('theme', 'message_delay', 3000); + $background_videos = $settings->get('theme', 'background_video', null); + $theme_background_video = (isset($background_videos) && is_array($background_videos)) ? $background_videos[0] : null; + //$login_domain_name_visible = $settings->get('login', 'domain_name_visible'); + //$login_domain_name = $settings->get('login', 'domain_name'); + $login_destination = $settings->get('login', 'destination'); + $users_unique = $settings->get('users', 'unique', ''); + //get the username if (isset($_SESSION["username"])) { $this->username = $_SESSION["username"]; @@ -102,16 +105,16 @@ class plugin_totp { //assign default values to the template $view->assign("project_path", PROJECT_PATH); - $view->assign("login_destination_url", $settings['login']['destination']); - $view->assign("favicon", $settings['theme']['favicon']); + $view->assign("login_destination_url", $login_destination); + $view->assign("favicon", $theme_favicon); $view->assign("login_title", $text['label-username']); $view->assign("login_username", $text['label-username']); - $view->assign("login_logo_width", $settings['theme']['login_logo_width']); - $view->assign("login_logo_height", $settings['theme']['login_logo_height']); - $view->assign("login_logo_source", $settings['theme']['logo']); + $view->assign("login_logo_width", $theme_login_logo_width); + $view->assign("login_logo_height", $theme_login_logo_height); + $view->assign("login_logo_source", $theme_logo); $view->assign("button_login", $text['button-login']); - $view->assign("favicon", $settings['theme']['favicon']); - $view->assign("message_delay", $settings['theme']['message_delay']); + $view->assign("favicon", $theme_favicon); + $view->assign("message_delay", $theme_message_delay); //messages $view->assign('messages', message::html(true, ' ')); @@ -203,16 +206,16 @@ class plugin_totp { //assign values to the template $view->assign("project_path", PROJECT_PATH); - $view->assign("login_destination_url", $settings['login']['destination']); - $view->assign("favicon", $settings['theme']['favicon']); + $view->assign("login_destination_url", $login_destination); + $view->assign("favicon", $theme_favicon); $view->assign("login_title", $text['label-verify']); $view->assign("login_totp_description", $text['label-totp_description']); $view->assign("login_authentication_code", $text['label-authentication_code']); - $view->assign("login_logo_width", $settings['theme']['login_logo_width']); - $view->assign("login_logo_height", $settings['theme']['login_logo_height']); - $view->assign("login_logo_source", $settings['theme']['logo']); - $view->assign("favicon", $settings['theme']['favicon']); - $view->assign("background_video", $settings['theme']['background_video']); + $view->assign("login_logo_width", $theme_login_logo_width); + $view->assign("login_logo_height", $theme_login_logo_height); + $view->assign("login_logo_source", $theme_logo); + $view->assign("favicon", $theme_favicon); + $view->assign("background_video", $theme_background_video); if (!empty($_SESSION['username'])) { $view->assign("username", $_SESSION['username']); $view->assign("button_cancel", $text['button-cancel']); @@ -271,8 +274,8 @@ class plugin_totp { $view->assign("totp_image", base64_encode($image)); $view->assign("totp_description", $text['description-totp']); $view->assign("button_next", $text['button-next']); - $view->assign("favicon", $settings['theme']['favicon']); - $view->assign("message_delay", $settings['theme']['message_delay']); + $view->assign("favicon", $theme_favicon); + $view->assign("message_delay", $theme_message_delay); //messages $view->assign('messages', message::html(true, ' ')); @@ -283,7 +286,7 @@ class plugin_totp { else { //assign values to the template $view->assign("button_verify", $text['label-verify']); - $view->assign("message_delay", $settings['theme']['message_delay']); + $view->assign("message_delay", $theme_message_delay); //messages $view->assign('messages', message::html(true, ' ')); @@ -305,7 +308,7 @@ class plugin_totp { $sql .= " username = :username\n"; $sql .= " or user_email = :username\n"; $sql .= ")\n"; - if ($settings['users']['unique'] != "global") { + if ($users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION["domain_uuid"]; @@ -358,7 +361,7 @@ class plugin_totp { } $sql .= "where "; $sql .= " u.user_uuid = :user_uuid "; - if ($settings['users']['unique'] != "global") { + if ($users_unique != "global") { //unique username per domain (not globally unique across system - example: email address) $sql .= "and u.domain_uuid = :domain_uuid "; $parameters['domain_uuid'] = $_SESSION["domain_uuid"];