]> git.donarmstrong.com Git - roundcube.git/blob - plugins/http_authentication/http_authentication.php
Imported Upstream version 0.5.2+dfsg
[roundcube.git] / plugins / http_authentication / http_authentication.php
1 <?php
2
3 /**
4  * HTTP Basic Authentication
5  *
6  * Make use of an existing HTTP authentication and perform login with the existing user credentials
7  *
8  * @version 1.2
9  * @author Thomas Bruederli
10  */
11 class http_authentication extends rcube_plugin
12 {
13   public $task = 'login';
14
15   function init()
16   {
17     $this->add_hook('startup', array($this, 'startup'));
18     $this->add_hook('authenticate', array($this, 'authenticate'));
19   }
20
21   function startup($args)
22   {
23     // change action to login
24     if (empty($args['action']) && empty($_SESSION['user_id'])
25         && !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']))
26       $args['action'] = 'login';
27
28     return $args;
29   }
30
31   function authenticate($args)
32   {
33     if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
34       $args['user'] = $_SERVER['PHP_AUTH_USER'];
35       $args['pass'] = $_SERVER['PHP_AUTH_PW'];
36     }
37     
38     $args['cookiecheck'] = false;
39     $args['valid'] = true;
40   
41     return $args;
42   }
43
44 }
45