| 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.3 |
|---|
| 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 | // Allow entering other user data in login form, |
|---|
| 34 | // e.g. after log out (#1487953) |
|---|
| 35 | if (!empty($args['user'])) { |
|---|
| 36 | return $args; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { |
|---|
| 40 | $args['user'] = $_SERVER['PHP_AUTH_USER']; |
|---|
| 41 | $args['pass'] = $_SERVER['PHP_AUTH_PW']; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | $args['cookiecheck'] = false; |
|---|
| 45 | $args['valid'] = true; |
|---|
| 46 | |
|---|
| 47 | return $args; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | } |
|---|
| 51 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.