]> git.donarmstrong.com Git - roundcube.git/blob - plugins/http_authentication/http_authentication.php
Imported Upstream version 0.3
[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.0
9  * @author Thomas Bruederli
10  */
11 class http_authentication extends rcube_plugin
12 {
13
14   function init()
15   {
16     $this->add_hook('startup', array($this, 'startup'));
17     $this->add_hook('authenticate', array($this, 'authenticate'));
18   }
19
20   function startup($args)
21   {
22     // change action to login
23     if ($args['task'] == 'mail' && empty($args['action']) && empty($_SESSION['user_id'])
24         && !empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW']))
25       $args['action'] = 'login';
26
27     return $args;
28   }
29
30   function authenticate($args)
31   {
32     if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
33       $args['user'] = $_SERVER['PHP_AUTH_USER'];
34       $args['pass'] = $_SERVER['PHP_AUTH_PW'];
35     }
36   
37     return $args;
38   }
39
40 }
41