diff options
author | Andrew Dolgov <[email protected]> | 2012-12-30 13:36:40 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2012-12-30 13:36:40 +0400 |
commit | e938b1de117cfde17a5773fe0c6fc92185c873fe (patch) | |
tree | 4afe7134ba505ba9209833cf193603beb32706cb /plugins/auth_imap/init.php | |
parent | 0e44c2a0d422617a59e3926cf3ae22872aac041a (diff) |
rename plugin main class files
Diffstat (limited to 'plugins/auth_imap/init.php')
-rw-r--r-- | plugins/auth_imap/init.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/auth_imap/init.php b/plugins/auth_imap/init.php new file mode 100644 index 000000000..cca279cb3 --- /dev/null +++ b/plugins/auth_imap/init.php @@ -0,0 +1,51 @@ +<?php +/* Requires php-imap + Put the following options in config.php: + + define('IMAP_AUTH_SERVER', 'your.imap.server:port'); + define('IMAP_AUTH_OPTIONS', '/tls/novalidate-cert/norsh'); + // More about options: http://php.net/manual/ru/function.imap-open.php + +*/ +class Auth_Imap extends Plugin implements IAuthModule { + + private $link; + private $host; + private $base; + + function about() { + return array(1.0, + "Authenticates against an IMAP server (configured in config.php)", + "fox", + true); + } + + function init($host) { + $this->link = $host->get_link(); + $this->host = $host; + $this->base = new Auth_Base($this->link); + + $host->add_hook($host::HOOK_AUTH_USER, $this); + } + + function authenticate($login, $password) { + + if ($login && $password) { + $imap = imap_open( + "{".IMAP_AUTH_SERVER.IMAP_AUTH_OPTIONS."}INBOX", + $login, + $password); + + if ($imap) { + imap_close($imap); + + return $this->base->auto_create_user($login); + } + } + + return false; + } + +} + +?> |