Translations of this page?:

IMAP/pop3 authentication

What does it do?

This authentication module, changes the password check for dokuWiki, from using the password file, to use an IMAP or pop3 server. It is build on the plain authentication backend, and works in the same way, with the only change that user passwords are cheked against an IMAP/pop3 server.

NB: You still need to create you users in dokuWiki before they can log in.

Requirements

  • php imap (for ubuntu use: aptitude install php5-imap)

Install

Copy the file imap.class.php to “inc/auth”.

Or manually create the file by applying the following steps:
Copy the plain module:

cp plain.class.php imap.class.php 

Change the following lines in the file imap.class.php:

[...]
class auth_imap extends auth_basic {
[...]
function auth_imap() {
[...]
 
  $this->cando['modPass'] = false;
  [...]
 function checkPass($user,$pass){
   $userinfo = $this->getUserData($user);
      if ($userinfo === false) return false;
 
        $toReturn=false;
 
        $imap_login = @imap_open("{imap.server:143/novalidate-cert}", $user."@domain.tld", $pass, OP_HALFOPEN, 1);
        if ($imap_login == false){
                $toReturn = false;
        }
        else {
                $toReturn = true;
                imap_close($imap_login);
        }
 
        return $toReturn;
  }
  [...]
 function createUser($user,$pwd,$name,$mail,$grps=null){
[...]
      $tmppass = time();
      $pass = auth_cryptPassword($tmppass);
[...]

Now update the IMAP/pop3 server connection string.

imap_open("{imap.server:143/novalidate-cert}", $user."@domain.tld", $pass, OP_HALFOPEN, 1);

See http://dk.php.net/imap_open for documentation on the imap_open function.

Patch User Manager

As noted in pam there seams to be a bug in the User Manager, it won't create a user if no password is specified. Fix it by either applying the patch on pam or by setting “$this→cando['modPass']” to true, and specifying a random password when the user is created.

Comments

Please leave your comments here.

 
wiki/auth/imap.txt · Last modified: 2008/06/14 17:38 by yrke
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate