diff --git a/install/apps/metronome_libs/mod_auth_external/authenticate_isp.php b/install/apps/metronome_libs/mod_auth_external/authenticate_isp.php deleted file mode 100644 index 7c59f3759b4ab6383168c98c548c7133ef396abf..0000000000000000000000000000000000000000 --- a/install/apps/metronome_libs/mod_auth_external/authenticate_isp.php +++ /dev/null @@ -1,65 +0,0 @@ - 'f47kmm5Yh5hJzSws2KTS', - 'weirdempire.de' => 'scNDcU37gQ7MCMeBgaJX' -); - -$arg_email = ''; -$arg_password = ''; - -if(count($argv) == 4){ - $arg_email = $argv[1].'@'.$argv[2]; - $arg_password = $argv[3]; -} -$client = new SoapClient(null, array('location' => $soap_location, 'uri' => $soap_uri)); -try { - //* Login to the remote server - if($session_id = $client->login($username,$password)) { - //var_dump($client->mail_alias_get($session_id, array('source' => 'blablubb@divepage.net', 'type' => 'alias', 'active' => 'y'))); - // Is Mail Alias? - $alias = $client->mail_alias_get($session_id, array('source' => $arg_email, 'type' => 'alias', 'active' => 'y')); - if(count($alias)) - $arg_email = $alias[0]['destination']; - $mailbox = $client->mail_user_get($session_id, array('email' => $arg_email)); - if(count($mailbox)){ - $password = $mailbox[0]['password']; - echo checkAuth($argv[1], $argv[2], $arg_password, $password);//intval(crypt($arg_password, $password) == $password); - } - else - echo 0; - //* Logout - $client->logout($session_id); - } - else - echo 0; -} catch (SoapFault $e) { - echo 0; -} - -function checkAuth($user, $domain, $pw, $pw_mailbox){ - global $auth_keys; - if(crypt($pw, $pw_mailbox) == $pw_mailbox) - return intval(1); - - if(array_key_exists($domain, $auth_keys)){ - $datetime = new DateTime(); - $datetime->setTimezone(new DateTimeZone("UTC")); - for($t = $datetime->getTimestamp(); $t >= $datetime->getTimestamp()-30; $t--){ - $pw_api = md5($domain.'@'.$auth_keys[$domain].'@'.$user.'@'.$t); - if($pw_api == $pw) - return intval(1); - } - } - return intval(0); -} -?> \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh b/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh index c4832f44333e69a536284c601b82a041c4b1f2db..c5a0c8e6846b85087bcc6f3f1ba3ae764f1a7a3c 100644 --- a/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh +++ b/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh @@ -12,7 +12,7 @@ while read ACTION USER HOST PASS ; do case $ACTION in "auth") - if [ `/usr/bin/php /usr/lib/metronome/spicy-modules/mod_auth_external/authenticate_isp.php $USER $HOST $PASS` == 1 ] ; then + if [ `/usr/bin/php /usr/lib/metronome/isp-modules/mod_auth_external/db_auth.php $USER $HOST $PASS 2>/dev/null` == 1 ] ; then echo $AUTH_OK [ $USELOG == true ] && { echo "AUTH OK" >> $LOGFILE; } else @@ -21,17 +21,17 @@ while read ACTION USER HOST PASS ; do fi ;; "isuser") - if [ `/usr/bin/php /usr/lib/metronome/spicy-modules/mod_auth_external/isuser_isp.php $USER $HOST` == 1 ] ; then + if [ `/usr/bin/php /usr/lib/metronome/isp-modules/mod_auth_external/db_isuser.php $USER $HOST 2>/dev/null` == 1 ] ; then echo $AUTH_OK - [ $USELOG == true ] && { echo "AUTH OK" >> $LOGFILE; } + [ $USELOG == true ] && { echo "ISUSER OK" >> $LOGFILE; } else echo $AUTH_FAILED - [ $USELOG == true ] && { echo "AUTH FAILED" >> $LOGFILE; } + [ $USELOG == true ] && { echo "ISUSER FAILED" >> $LOGFILE; } fi ;; *) echo $AUTH_FAILED - [ $USELOG == true ] && { echo "NO ACTION GIVEN" >> $LOGFILE; } + [ $USELOG == true ] && { echo "UNKNOWN ACTION GIVEN: $ACTION" >> $LOGFILE; } ;; esac diff --git a/install/apps/metronome_libs/mod_auth_external/db_auth.php b/install/apps/metronome_libs/mod_auth_external/db_auth.php new file mode 100644 index 0000000000000000000000000000000000000000..086dcf6a0143efbb8562f3817d0fc7c58c03d949 --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/db_auth.php @@ -0,0 +1,58 @@ +real_escape_string($arg_email); + $result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE '".$dbmail."' AND active='y' AND server_id='".$isp_server_id."'"); + result_false($result->num_rows != 1); + + $user = $result->fetch_object(); + + // check for domain autologin api key + $domain_key = 'f47kmm5Yh5hJzSws2KTS'; + + checkAuth($argv[1], $argv[2], $arg_password, $user->password, $domain_key); +}catch(Exception $ex){ + echo 0; + exit(); +} + +function result_false($cond = true){ + if(!$cond) return; + echo 0; + exit(); +} +function result_true(){ + echo 1; + exit(); +} +function checkAuth($user, $domain, $pw_arg, $pw_db, $domain_key){ + if(crypt($pw_arg, $pw_db) == $pw_db) + result_true(); + + if($domain_key){ + $datetime = new DateTime(); + $datetime->setTimezone(new DateTimeZone("UTC")); + for($t = $datetime->getTimestamp(); $t >= $datetime->getTimestamp()-30; $t--){ + $pw_api = md5($domain.'@'.$domain_key.'@'.$user.'@'.$t); + if($pw_api == $pw_arg) + result_true(); + } + } + result_false(); +} +?> \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php b/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..1aba63d6ea051ff4826312757b10af2a1c590525 --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php @@ -0,0 +1,6 @@ +real_escape_string($arg_email); + $result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE '".$dbmail."' AND active='y' AND server_id='".$isp_server_id."'"); + result_false($result->num_rows != 1); + result_true(); + +}catch(Exception $ex){ + echo 0; + exit(); +} + +function result_false($cond = true){ + if(!$cond) return; + echo 0; + exit(); +} +function result_true(){ + echo 1; + exit(); +} + +?> \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_auth_external/isuser_isp.php b/install/apps/metronome_libs/mod_auth_external/isuser_isp.php deleted file mode 100644 index d37053270e771d40cd8b960b16fc07936dcd9549..0000000000000000000000000000000000000000 --- a/install/apps/metronome_libs/mod_auth_external/isuser_isp.php +++ /dev/null @@ -1,44 +0,0 @@ - $soap_location, 'uri' => $soap_uri)); -try { - //* Login to the remote server - if($session_id = $client->login($username,$password)) { - //var_dump($client->mail_alias_get($session_id, array('source' => 'blablubb@divepage.net', 'type' => 'alias', 'active' => 'y'))); - // Is Mail Alias? - $alias = $client->mail_alias_get($session_id, array('source' => $arg_email, 'type' => 'alias', 'active' => 'y')); - if(count($alias)) - $arg_email = $alias[0]['destination']; - $mailbox = $client->mail_user_get($session_id, array('email' => $arg_email)); - if(count($mailbox)){ - echo 1; - //$password = $mailbox[0]['password']; - //echo intval(crypt($arg_password, $password) == $password); - } - else - echo 0; - //* Logout - $client->logout($session_id); - } - else - echo 0; -} catch (SoapFault $e) { - echo 0; -} -?> \ No newline at end of file diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 688cfdb6ef29827090240659810fc9ad96fbf5cb..acaaf3bfd6550920df325c123ac6cf20c67bd015 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -1339,6 +1339,16 @@ class installer_base { // Copy isp libs if(!@is_dir('/usr/lib/metronome/isp-modules')) mkdir('/usr/lib/metronome/isp-modules', 0755, true); caselog('cp -rf apps/metronome_libs/* /usr/lib/metronome/isp-modules/', __FILE__, __LINE__); + // Process db config + $full_file_name = '/usr/lib/metronome/isp-modules/mod_auth_external/db_conf.inc.php'; + $content = rf($full_file_name); + $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); + $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); + $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); + $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); + $content = str_replace('{server_id}', $conf['server_id'], $content); + wf($full_file_name, $content); + // Copy init script caselog('cp -f apps/metronome-init /etc/init.d/metronome', __FILE__, __LINE__); diff --git a/install/sql/incremental/upd_0081.sql b/install/sql/incremental/upd_0081.sql index 5acfc732c0987a83e9ec423940bd09be6152725a..ce16a5b1bd4625edfd00f4983caf2840bcee96d1 100644 --- a/install/sql/incremental/upd_0081.sql +++ b/install/sql/incremental/upd_0081.sql @@ -23,7 +23,7 @@ CREATE TABLE `xmpp_domain` ( `server_id` int(11) unsigned NOT NULL default '0', `domain` varchar(255) NOT NULL default '', - `auth_method` ENUM( 'isp', 'plain', 'hashed' ) NOT NULL default 'hashed', + `management_method` ENUM( 'normal', 'maildomain' ) NOT NULL default 'normal', `public_registration` ENUM( 'n', 'y' ) NOT NULL default 'n', `registration_url` varchar(255) NOT NULL DEFAULT '', `registration_message` varchar(255) NOT NULL DEFAULT '', @@ -66,12 +66,8 @@ CREATE TABLE `xmpp_user` ( `sys_perm_group` varchar(5) NOT NULL default '', `sys_perm_other` varchar(5) NOT NULL default '', `server_id` int(11) unsigned NOT NULL default '0', - `xmpp_domain_id` int(11) unsigned NOT NULL default '0', - `login` varchar(255) NOT NULL default '', `jid` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', - `is_domain_admin` enum('n','y') NOT NULL default 'n', - `is_muc_admin` enum('n','y') NOT NULL default 'n', `active` enum('n','y') NOT NULL DEFAULT 'n', PRIMARY KEY (`xmppuser_id`), KEY `server_id` (`server_id`,`jid`), diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 0b5ce406a22e8963577eadb8ea91ac91f515269a..22c58b1b5c485f3abe021aa7973f872e000c293f 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1977,7 +1977,7 @@ CREATE TABLE `xmpp_domain` ( `server_id` int(11) unsigned NOT NULL default '0', `domain` varchar(255) NOT NULL default '', - `auth_method` ENUM( 'isp', 'plain', 'hashed' ) NOT NULL default 'hashed', + `management_method` ENUM( 'normal', 'maildomain' ) NOT NULL default 'normal', `public_registration` ENUM( 'n', 'y' ) NOT NULL default 'n', `registration_url` varchar(255) NOT NULL DEFAULT '', `registration_message` varchar(255) NOT NULL DEFAULT '', @@ -2022,12 +2022,8 @@ CREATE TABLE `xmpp_user` ( `sys_perm_group` varchar(5) NOT NULL default '', `sys_perm_other` varchar(5) NOT NULL default '', `server_id` int(11) unsigned NOT NULL default '0', - `xmpp_domain_id` int(11) unsigned NOT NULL default '0', - `login` varchar(255) NOT NULL default '', `jid` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', - `is_domain_admin` enum('n','y') NOT NULL default 'n', - `is_muc_admin` enum('n','y') NOT NULL default 'n', `active` enum('n','y') NOT NULL DEFAULT 'n', PRIMARY KEY (`xmppuser_id`), KEY `server_id` (`server_id`,`jid`), diff --git a/interface/web/mail/form/xmpp_domain.tform.php b/interface/web/mail/form/xmpp_domain.tform.php index cc1765f3cc6ffd33a50e4456e8e3ec31f95ccd6c..6c5ff62bd50e762400683b4e8b17acc02767fd2b 100644 --- a/interface/web/mail/form/xmpp_domain.tform.php +++ b/interface/web/mail/form/xmpp_domain.tform.php @@ -98,11 +98,11 @@ $form["tabs"]['domain'] = array ( 'maxlength' => '255', 'searchable' => 1 ), - 'auth_method' => array ( + 'management_method' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', - 'default' => '1', - 'value' => array(0 => 'Plain', 1 => 'Hashed', 2 => 'By Email Mailbox') + 'default' => '0', + 'value' => array(0 => 'Normal', 1 => 'By Mail Domain') ), 'public_registration' => array ( 'datatype' => 'VARCHAR', diff --git a/interface/web/mail/form/xmpp_user.tform.php b/interface/web/mail/form/xmpp_user.tform.php new file mode 100644 index 0000000000000000000000000000000000000000..c7360787349de587e6e13b7acb666951a96bfdea --- /dev/null +++ b/interface/web/mail/form/xmpp_user.tform.php @@ -0,0 +1,127 @@ +uses('getconf'); +$global_config = $app->getconf->get_global_config(); + +$form["title"] = "XMPP Account"; +$form["description"] = ""; +$form["name"] = "xmpp_user"; +$form["action"] = "xmpp_user_edit.php"; +$form["db_table"] = "xmpp_user"; +$form["db_table_idx"] = "xmppuser_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "xmppuser"; +$form["list_default"] = "xmpp_user_list.php"; +$form["auth"] = 'yes'; // yes / no + +$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['xmppuser'] = array( + 'title' => "XMPP Account", + 'width' => 100, + 'template' => "templates/xmpp_user_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# + 'server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'jid' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'ISEMAIL', + 'errmsg'=> 'jid_error_isemail'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'jid_error_unique'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', + 'searchable' => 1 + ), + 'password' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', + 'validators' => array( + 0 => array( + 'type' => 'CUSTOM', + 'class' => 'validate_password', + 'function' => 'password_check', + 'errmsg' => 'weak_password_txt' + ) + ), + 'encryption'=> 'CRYPT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(1 => 'y', 0 => 'n') + ), + //################################# + // END Datatable fields + //################################# + ) +); + +?> diff --git a/interface/web/mail/lib/lang/en_xmpp_domain.lng b/interface/web/mail/lib/lang/en_xmpp_domain.lng index 1151f5cd44f91213c50f362f112b2d85b826768b..0cbf0c7132eb9f8bd95865e7e848783116e1c898 100644 --- a/interface/web/mail/lib/lang/en_xmpp_domain.lng +++ b/interface/web/mail/lib/lang/en_xmpp_domain.lng @@ -4,7 +4,7 @@ $wb["domain_txt"] = 'Domain'; $wb["type_txt"] = 'Type'; $wb["active_txt"] = 'Active'; $wb["client_txt"] = 'Client'; -$wb["auth_method_txt"] = 'Authentication Method'; +$wb["management_method_txt"] = 'Management of user accounts'; $wb["public_registration_txt"] = 'Enable public registration'; $wb["registration_url_txt"] = 'Registration URL'; $wb["registration_message_txt"] = 'Registration Message'; @@ -25,4 +25,5 @@ $wb["use_http_archive_txt"] = 'Enable HTTP chatroom archive'; $wb["http_archive_show_join_txt"] = 'Show join messages in archive'; $wb["http_archive_show_status_txt"] = 'Show status changes in archive'; $wb["use_status_host_txt"] = 'Enable XML Status host'; +$wb["no_corresponding_maildomain_txt"] = 'Corresponding mail domain for user management not found. Please create the mail domain first.'; ?> diff --git a/interface/web/mail/lib/lang/en_xmpp_user.lng b/interface/web/mail/lib/lang/en_xmpp_user.lng new file mode 100644 index 0000000000000000000000000000000000000000..1cc852e3cf8f9332cd168d10e82aa70fb6beaf7a --- /dev/null +++ b/interface/web/mail/lib/lang/en_xmpp_user.lng @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/interface/web/mail/list/xmpp_user.list.php b/interface/web/mail/list/xmpp_user.list.php index f9a2415c889d6817943f15f7843a200cfedc99ef..c1cdbb8d4d36b3282d7de9d6417982854e8e4171 100644 --- a/interface/web/mail/list/xmpp_user.list.php +++ b/interface/web/mail/list/xmpp_user.list.php @@ -59,23 +59,4 @@ $liste["item"][] = array( 'field' => "JID", 'width' => "", 'value' => ""); -$liste["item"][] = array( 'field' => "is_domain_admin", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('n' => "
+