]> git.wh0rd.org Git - tt-rss.git/blob - classes/auth/imap.php
add IMAP authenticator module (closes #485)
[tt-rss.git] / classes / auth / imap.php
1 <?php
2 /* Requires php-imap
3         Put the following options in config.php:
4
5         define('IMAP_AUTH_SERVER', 'your.imap.server:port');
6         define('IMAP_AUTH_OPTIONS', '/tls/novalidate-cert/norsh');
7         // More about options: http://php.net/manual/ru/function.imap-open.php
8
9  */
10
11 class Auth_Imap extends Auth_Base {
12
13         function authenticate($login, $password) {
14
15                 if ($login && $password) {
16                         $imap = imap_open(
17                                 "{".IMAP_AUTH_SERVER.IMAP_AUTH_OPTIONS."}INBOX",
18                                 $login,
19                                 $password);
20
21                         if ($imap) {
22                                 imap_close($imap);
23
24                                 return $this->auto_create_user($login);
25                         }
26                 }
27
28                 return false;
29         }
30
31 }
32 ?>