source: github/plugins/http_authentication/http_authentication.php @ 5375e84

release-0.6
Last change on this file since 5375e84 was 5375e84, checked in by thomascube <thomas@…>, 22 months ago

Copying plugins into 0.6 release branch

  • Property mode set to 100644
File size: 993 bytes
Line 
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 */
11class 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
Note: See TracBrowser for help on using the repository browser.