mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
* Change the data type to boolean
* Use boolean values in SQL and Conditional Statements
* Schema Data Types: Drop views so that alter tables statements complete
* Update settings.php
* Add extension for call_screen_enabled
* Gateway handle boolean
Add the boolean toggle
- distinct_to
- caller_id_in_from
- supress_cng
- extension_in_contact
- contact_in_ping
* Update gateways.php
* Update voicemail_edit.php
* Replace the ${caller_id_name} with the extensions caller id name
* Phrase - Edit: Update slide toggle with new select beneath.
* Update the input toggle style
* Set the input_toggle_style_switch as boolean
* Update the input toggle style
* Theme: Adjust CSS to wrap description text on form fields.
* Add domain_uuid and domain_name to the SQL SELECT
* Unset the parameters to fix the next query
* Gateway: Integrate new slide toggle switch.
* Dashboard: Update the input toggle style (#7499)
* Dashboard: Update the input toggle style
* Update dashboard_widget_edit.php
* Update dashboard_edit.php
* Inbound Route - Add: Integrate new slide toggle switch and boolean.
* User Settings: Integrate new slide toggle switch.
* Call Block Edit: Update the input toggle style (#7500)
* Bridge Edit: Update the input toggle style (#7501)
* Update phrases.php
* Update domain_edit.php
* Domain Settings Edit: Update the input toggle style
* User Edit: Update the input toggle style
* Update install.php
* Remove fields marked as deprecated
* Use boolean in the select statement
* Streams: New slide toggle and boolean.
* Streams: Remove unnecessary default.
* Queues (FIFO): New slide toggle.
* Call Detail Records: Update the input toggle style (#7503)
* Call Detail Records: Update the input toggle style
* Update xml_cdr_extension_summary.php
* Update xml_cdr_extension_summary.php
* Update xml_cdr_extension_summary.php
* Call Centers: Update the input toggle style (#7502)
* Call Centers: Update the input toggle style
* Update call_center_agent_edit.php
* Conference Centers: Update the input toggle style (#7506)
* Conference Centers: Update the input toggle style
* Update app_config.php
* Update conference_center_edit.php
* Use boolean data type (#7505)
* Call Flow Edit: Update the input toggle style (#7504)
* Devices: Update the input toggle style
* IVR Menus: New slide toggle.
* IVR Menu: Remove deprected file.
* SIP Profile - Edit: New slide toggle.
* Device Profiles: Update the input toggle style
* Ring Groups - List: Fix syntax.
* Theme: Fire onchange event when switching slide toggle control.
* Device Vendors: Update the input toggle style
* Update enabled boolean
* Update device_edit.php
* Ring Groups: New slide toggle.
* Update domain_edit.php
* Email Templates: Update the input toggle style
* Header: Correct default value on input toggle style.
* Default/Domain/User Settings: Adjust Select option label for better clarity.
* Use true boolean types for switch theme toggle or drop-down box (#7507)
* Groups: Update the input toggle style
* Conference Controls: Update the input toggle style (#7509)
* Conference Controls: Update the input toggle style
* Update conference_control_edit.php
* Update conference_control_details.php
* Update conference_control_detail_edit.php
* Conferences: Update the input toggle style (#7511)
* Use true boolean types for switch theme toggle or drop-down box (#7513)
* Dialplans: Update the input toggle style
Also updated outbound route add
* Ring Group: Only adjust ring group forward destination top margin when slide toggle enabled.
* Default/Domain/User Settings - List: Adjust for new 'Select Box' label on input_toggle_style value.
* Use true boolean types for switch theme toggle or drop-down box (#7514)
* Call Forward / Follow Me: Minor javascript adjustments to mirror previous behavior.
* Ring Groups [Dashboard]: New slide toggle.
* Get the contacts details with a seperate SQL Query
* Remove debug info
* Destinations: Update the input toggle style
* Conference Profiles: Update the input toggle style (#7515)
* Conference Profiles: Update the input toggle style
* Update conference_profiles.php
* Update conference_profile_params.php
* Update conference_profile_param_edit.php
* Update conference_profile_edit.php
* Extensions: Update the input toggle style
* Contacts: Update the input toggle style (#7517)
* Contacts: Update the input toggle style
* Update contact_address_edit.php
* Update contact_attachment_edit.php
* Update contact_edit.php
* Update contact_email_edit.php
* Update contact_phone_edit.php
* Update contact_relation_edit.php
* Update contact_setting_edit.php
* Update contact_url_edit.php
* Update contacts.php
* Voicemails: New slide toggle.
* Voicemail Greeting: New slide toggle.
* Modules: New slide toggle.
* Recordings: New slide toggle
* Variables: New slide toggle.
* Time Conditions: New slide toggle.
* Extensions - List: Remove invalid column name.
* Extension Settings: New slide toggle.
* Number Translations: New slide toggle and boolean.
* Sofia global settings: Update the input toggle style
* Update alter table convert to boolean
* Fix contact relation search (#7518)
* Sip Profile Edit: Fix setting enabled labels (#7519)
* Sip Profile Edit: Fix setting enabled labels
* Update sip_profile_edit.php
* Update dialplan_edit.php (#7520)
* Update SQL queries to use true/false for contact primary settings (#7521)
* Update SQL queries to use true/false for contact primary settings
* Update contacts_vcard.php
* Update email.php
* Update totp.php
* Update contact_url_edit.php
* Update contact_email_edit.php
* Update contact_address_edit.php
* Update contact_attachment_edit.php
* Update contact_phone_edit.php
* Add a database views method
* Add database view groups
* Add database users view
* Add database call_recordings view
* Update users.php
* Add database view call block
* Update schema to use the database views method
* Update conference.conf.lua boolean
* Update directory.lua boolean
* Update callcenter.conf.lua agent_status boolean
* Update sofia.conf.lua boolean
* Update number translations lua boolean
* Update directory.lua boolean
* Update group_call.lua fix the cache
* Update reverse-auth-lookup.lua boolean
* Update directory.lua boolean
* Use concat instead of ||
* Update index.lua
---------
Co-authored-by: fusionate <nate@fusionpbx.com>
Co-authored-by: Alex <alex@fusionpbx.com>
Co-authored-by: frytimo <tim@fusionpbx.com>
212 lines
8.0 KiB
PHP
212 lines
8.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* plugin_ldap
|
|
*
|
|
* @method ldap checks a local or remote ldap database to authenticate the user
|
|
*/
|
|
class plugin_ldap {
|
|
|
|
/**
|
|
* Define variables and their scope
|
|
*/
|
|
public $debug;
|
|
public $domain_name;
|
|
public $username;
|
|
public $password;
|
|
public $user_uuid;
|
|
public $contact_uuid;
|
|
|
|
/**
|
|
* ldap checks a local or remote ldap database to authenticate the user
|
|
* @return array [authorized] => true or false
|
|
*/
|
|
function ldap() {
|
|
|
|
//show the authentication code view
|
|
if ($_REQUEST["username"]) {
|
|
|
|
//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']['background_video'] = isset($_SESSION['theme']['background_video'][0]) ? $_SESSION['theme']['background_video'][0] : null;
|
|
|
|
//get the domain
|
|
$domain_array = explode(":", $_SERVER["HTTP_HOST"]);
|
|
$domain_name = $domain_array[0];
|
|
|
|
//create token
|
|
//$object = new token;
|
|
//$token = $object->create('login');
|
|
|
|
//add multi-lingual support
|
|
$language = new text;
|
|
$text = $language->get(null, '/core/authentication');
|
|
|
|
//initialize a template object
|
|
$view = new template();
|
|
$view->engine = 'smarty';
|
|
$view->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/core/authentication/resources/views/';
|
|
$view->cache_dir = sys_get_temp_dir();
|
|
$view->init();
|
|
|
|
//add translations
|
|
$view->assign("login_title", $text['button-login']);
|
|
$view->assign("label_username", $text['label-username']);
|
|
$view->assign("label_password", $text['label-password']);
|
|
$view->assign("button_login", $text['button-login']);
|
|
|
|
//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_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("background_video", $settings['theme']['background_video']);
|
|
|
|
//add the token name and hash to the view
|
|
//$view->assign("token_name", $token['name']);
|
|
//$view->assign("token_hash", $token['hash']);
|
|
|
|
//show the views
|
|
$content = $view->render('login.htm');
|
|
echo $content;
|
|
exit;
|
|
}
|
|
|
|
//use ldap to validate the user credentials
|
|
if (isset($_SESSION["ldap"]["certpath"])) {
|
|
$s = "LDAPTLS_CERT=" . $_SESSION["ldap"]["certpath"]["text"];
|
|
putenv($s);
|
|
}
|
|
if (isset($_SESSION["ldap"]["certkey"])) {
|
|
$s = "LDAPTLS_KEY=" . $_SESSION["ldap"]["certkey"]["text"];
|
|
putenv($s);
|
|
}
|
|
$host = $_SESSION["ldap"]["server_host"]["text"];
|
|
$port = $_SESSION["ldap"]["server_port"]["numeric"];
|
|
$connect = ldap_connect($host, $port)
|
|
or die("Could not connect to the LDAP server.");
|
|
//ldap_set_option($connect, LDAP_OPT_NETWORK_TIMEOUT, 10);
|
|
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
|
|
//ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
|
|
|
|
//set the default status
|
|
$user_authorized = false;
|
|
|
|
//provide backwards compatability
|
|
if (!empty($_SESSION["ldap"]["user_dn"]["text"])) {
|
|
$_SESSION["ldap"]["user_dn"][] = $_SESSION["ldap"]["user_dn"]["text"];
|
|
}
|
|
|
|
//check all user_dn in the array
|
|
foreach ($_SESSION["ldap"]["user_dn"] as $user_dn) {
|
|
$bind_dn = $_SESSION["ldap"]["user_attribute"]["text"]."=".$this->username.",".$user_dn;
|
|
$bind_pw = $this->password;
|
|
//Note: As of 4/16, the call below will fail randomly. PHP debug reports ldap_bind
|
|
//called below with all arguments '*uninitialized*'. However, the debugger
|
|
//single-stepping just before the failing call correctly displays all the values.
|
|
if (!empty($bind_pw)) {
|
|
$bind = ldap_bind($connect, $bind_dn, $bind_pw);
|
|
if ($bind) {
|
|
//connected and authorized
|
|
$user_authorized = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
//check to see if the user exists
|
|
if ($user_authorized) {
|
|
$sql = "select * from v_users ";
|
|
$sql .= "where username = :username ";
|
|
if ($settings['users']['unique'] != "global") {
|
|
//unique username per domain (not globally unique across system - example: email address)
|
|
$sql .= "and domain_uuid = :domain_uuid ";
|
|
$parameters['domain_uuid'] = $this->domain_uuid;
|
|
}
|
|
$sql .= "and (user_type = 'default' or user_type is null) ";
|
|
$parameters['username'] = $this->username;
|
|
$database = new database;
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
|
if ($settings['users']['unique'] == "global" && $row["domain_uuid"] != $this->domain_uuid) {
|
|
//get the domain uuid
|
|
$this->domain_uuid = $row["domain_uuid"];
|
|
$this->domain_name = $_SESSION['domains'][$this->domain_uuid]['domain_name'];
|
|
|
|
//set the domain session variables
|
|
$_SESSION["domain_uuid"] = $this->domain_uuid;
|
|
$_SESSION["domain_name"] = $this->domain_name;
|
|
|
|
//set the setting arrays
|
|
$domain = new domains();
|
|
$domain->set();
|
|
}
|
|
$this->user_uuid = $row["user_uuid"];
|
|
$this->contact_uuid = $row["contact_uuid"];
|
|
}
|
|
else {
|
|
//salt used with the password to create a one way hash
|
|
$salt = generate_password('32', '4');
|
|
$password = generate_password('32', '4');
|
|
|
|
//prepare the uuids
|
|
$this->user_uuid = uuid();
|
|
$this->contact_uuid = uuid();
|
|
|
|
//build user insert array
|
|
$array['users'][0]['user_uuid'] = $this->user_uuid;
|
|
$array['users'][0]['domain_uuid'] = $this->domain_uuid;
|
|
$array['users'][0]['contact_uuid'] = $this->contact_uuid;
|
|
$array['users'][0]['username'] = strtolower($this->username);
|
|
$array['users'][0]['password'] = md5($salt.$password);
|
|
$array['users'][0]['salt'] = $salt;
|
|
$array['users'][0]['add_date'] = now();
|
|
$array['users'][0]['add_user'] = strtolower($this->username);
|
|
$array['users'][0]['user_enabled'] = true;
|
|
|
|
//build user group insert array
|
|
$array['user_groups'][0]['user_group_uuid'] = uuid();
|
|
$array['user_groups'][0]['domain_uuid'] = $this->domain_uuid;
|
|
$array['user_groups'][0]['group_name'] = 'user';
|
|
$array['user_groups'][0]['user_uuid'] = $this->user_uuid;
|
|
|
|
//grant temporary permissions
|
|
$p = permissions::new();
|
|
$p->add('user_add', 'temp');
|
|
$p->add('user_group_add', 'temp');
|
|
|
|
//execute insert
|
|
$database = new database;
|
|
$database->app_name = 'authentication';
|
|
$database->app_uuid = 'a8a12918-69a4-4ece-a1ae-3932be0e41f1';
|
|
$database->save($array);
|
|
unset($array);
|
|
|
|
//revoke temporary permissions
|
|
$p->delete('user_add', 'temp');
|
|
$p->delete('user_group_add', 'temp');
|
|
}
|
|
unset($sql, $parameters, $row);
|
|
}
|
|
|
|
//result array
|
|
$result["ldap"]["plugin"] = "ldap";
|
|
$result["ldap"]["domain_name"] = $this->domain_name;
|
|
$result["ldap"]["username"] = $this->username;
|
|
if ($this->debug) {
|
|
$result["ldap"]["password"] = $this->password;
|
|
}
|
|
$result["ldap"]["user_uuid"] = $this->user_uuid;
|
|
$result["ldap"]["domain_uuid"] = $this->domain_uuid;
|
|
$result["ldap"]["authorized"] = $user_authorized ? true : false;
|
|
return $result;
|
|
}
|
|
}
|