1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
<?php
/**
* The Auth_auto class transparently logs users in to Horde using ONE
* username, either defined in the config or defaulting to
* 'horde_user'. This is only for use in testing or behind a firewall;
* it should NOT be used on a public, production machine.
*
* Optional parameters:<pre>
* 'username' The username to authenticate everyone as.
* DEFAULT: 'horde_user'
* 'password' The password to record in the user's credentials.
* DEFAULT: none
* 'requestuser' If true, allow username to be passed by GET, POST or
* cookie.</pre>
*
*
* $Horde: framework/Auth/Auth/auto.php,v 1.12.4.8 2006/01/01 21:28:07 jan Exp $
*
* Copyright 1999-2006 Chuck Hagenbuch <chuck@horde.org>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Chuck Hagenbuch <chuck@horde.org>
* @since Horde 2.2
* @package Horde_Auth
*/
class Auth_auto extends Auth {
/**
* An array of capabilities, so that the driver can report which
* operations it supports and which it doesn't.
*
* @var array
*/
var $capabilities = array('add' => false,
'update' => false,
'resetpassword' => false,
'remove' => false,
'list' => false,
'transparent' => true);
/**
* Constructs a new Automatic authentication object.
*
* @param array $params A hash containing parameters.
*/
function Auth_auto($params = array())
{
$this->_setParams($params);
}
/**
* Set parameters for the Auth_auto object.
*
* @access private
*
* @param array $params Parameters. None currently required;
* 'username', 'password', and 'requestuser' are optional.
*/
function _setParams($params)
{
if (!isset($params['username'])) {
$params['username'] = 'horde_user';
}
$this->_params = $params;
}
/**
* Automatic authentication: Set the user allowed IP block.
*
* @return boolean Whether or not the client is allowed.
*/
function transparent()
{
$username = (!empty($this->_params['requestuser']) && isset($_REQUEST['username'])) ?
$_REQUEST['username'] :
$this->_params['username'];
$this->setAuth($username,
array('transparent' => 1,
'password' => isset($this->_params['password']) ? $this->_params['password'] : null));
return true;
}
}
|