mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 06:51:58 +01:00
added imap authentication support to webui
This commit is contained in:
parent
ced28c70c8
commit
989f8c2211
@ -25,6 +25,10 @@ define('GOOGLE_CLIENT_ID', 'xxxxxxxxxxx');
|
|||||||
define('GOOGLE_CLIENT_SECRET', 'xxxxxxxxxxxxx');
|
define('GOOGLE_CLIENT_SECRET', 'xxxxxxxxxxxxx');
|
||||||
define('GOOGLE_DEVELOPER_KEY', 'xxxxxxxxxxxx');
|
define('GOOGLE_DEVELOPER_KEY', 'xxxxxxxxxxxx');
|
||||||
define('GOOGLE_APPLICATION_NAME', 'piler enterprise email archiver');
|
define('GOOGLE_APPLICATION_NAME', 'piler enterprise email archiver');
|
||||||
|
define('ENABLE_IMAP_AUTH', 0);
|
||||||
|
define('IMAP_HOST', 'mail.yourdomain.com');
|
||||||
|
define('IMAP_PORT', 993);
|
||||||
|
define('IMAP_SSL', true);
|
||||||
|
|
||||||
define('REMOTE_IMAGE_REPLACEMENT', '/view/theme/default/images/remote.gif');
|
define('REMOTE_IMAGE_REPLACEMENT', '/view/theme/default/images/remote.gif');
|
||||||
define('ICON_ARROW_UP', '/view/theme/default/images/arrowup.gif');
|
define('ICON_ARROW_UP', '/view/theme/default/images/arrowup.gif');
|
||||||
|
@ -5,6 +5,11 @@ class ModelUserAuth extends Model {
|
|||||||
public function checkLogin($username = '', $password = '') {
|
public function checkLogin($username = '', $password = '') {
|
||||||
$ok = 0;
|
$ok = 0;
|
||||||
|
|
||||||
|
if(ENABLE_IMAP_AUTH == 1) {
|
||||||
|
require 'Zend/Mail/Protocol/Imap.php';
|
||||||
|
$ok = $this->checkLoginAgainstIMAP($username, $password);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($username));
|
$query = $this->db->query("SELECT " . TABLE_USER . ".username, " . TABLE_USER . ".uid, " . TABLE_USER . ".realname, " . TABLE_USER . ".dn, " . TABLE_USER . ".password, " . TABLE_USER . ".isadmin, " . TABLE_USER . ".domain FROM " . TABLE_USER . ", " . TABLE_EMAIL . " WHERE " . TABLE_EMAIL . ".email=? AND " . TABLE_EMAIL . ".uid=" . TABLE_USER . ".uid", array($username));
|
||||||
|
|
||||||
if(!isset($query->row['password'])) { return 0; }
|
if(!isset($query->row['password'])) { return 0; }
|
||||||
@ -69,6 +74,35 @@ class ModelUserAuth extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private function checkLoginAgainstIMAP($username = '', $password = '') {
|
||||||
|
$user = array();
|
||||||
|
|
||||||
|
$imap = new Zend_Mail_Protocol_Imap(IMAP_HOST, IMAP_PORT, IMAP_SSL);
|
||||||
|
if($imap->login($username, $password)) {
|
||||||
|
$imap->logout();
|
||||||
|
|
||||||
|
$query = $this->db->query("SELECT email, uid FROM " . TABLE_EMAIL . " WHERE email=?", array($username));
|
||||||
|
if($query->num_rows == 0) {
|
||||||
|
$a = explode("@", $username);
|
||||||
|
|
||||||
|
$user['uid'] = $this->model_user_user->get_next_uid();
|
||||||
|
$user['username'] = $username;
|
||||||
|
$user['realname'] = $a[0];
|
||||||
|
$user['password'] = generate_random_string(8);
|
||||||
|
$user['domain'] = @$a[1];
|
||||||
|
$user['isadmin'] = 0;
|
||||||
|
$user['email'] = $username;
|
||||||
|
|
||||||
|
$this->model_user_user->add_user($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function check_ntlm_auth() {
|
public function check_ntlm_auth() {
|
||||||
if(!isset($_SERVER['REMOTE_USER'])) { return 0; }
|
if(!isset($_SERVER['REMOTE_USER'])) { return 0; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user