Overview

Packages

  • Auth

Classes

  • Horde_Auth
  • Horde_Auth_Auto
  • Horde_Auth_Base
  • Horde_Auth_Composite
  • Horde_Auth_Customsql
  • Horde_Auth_Cyrsql
  • Horde_Auth_Exception
  • Horde_Auth_Ftp
  • Horde_Auth_Http
  • Horde_Auth_Http_Remote
  • Horde_Auth_Imap
  • Horde_Auth_Ipbasic
  • Horde_Auth_Kolab
  • Horde_Auth_Ldap
  • Horde_Auth_Login
  • Horde_Auth_Msad
  • Horde_Auth_Pam
  • Horde_Auth_Passwd
  • Horde_Auth_Peclsasl
  • Horde_Auth_Radius
  • Horde_Auth_Shibboleth
  • Horde_Auth_Smb
  • Horde_Auth_Smbclient
  • Horde_Auth_Sql
  • Horde_Auth_Translation
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Horde_Auth_Auto class transparently logs users in to Horde using ONE
 4:  * username, either defined in the config or defaulting to 'horde_user'.
 5:  * This is only for use in testing or behind a firewall; it should NOT be
 6:  * used on a public, production machine.
 7:  *
 8:  * Copyright 1999-2012 Horde LLC (http://www.horde.org/)
 9:  *
10:  * See the enclosed file COPYING for license information (LGPL). If you did
11:  * not receive this file, http://www.horde.org/licenses/lgpl21
12:  *
13:  * @author   Chuck Hagenbuch <chuck@horde.org>
14:  * @category Horde
15:  * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
16:  * @package  Auth
17:  */
18: class Horde_Auth_Auto extends Horde_Auth_Base
19: {
20:     /**
21:      * An array of capabilities, so that the driver can report which
22:      * operations it supports and which it doesn't.
23:      *
24:      * @var array
25:      */
26:     protected $_capabilities = array(
27:         'transparent' => true
28:     );
29: 
30:     /**
31:      * Constructor.
32:      *
33:      * @param array $params  Optional parameters:
34:      * <pre>
35:      * 'password' - (string) The password to record in the user's credentials.
36:      *              DEFAULT: none
37:      * 'requestuser' - (boolean) If true, allow username to be passed by GET,
38:      *                 POST or cookie.
39:      *                 DEFAULT: No
40:      * 'username' - (string) The username to authenticate everyone as.
41:      *              DEFAULT: 'horde_user'
42:      * </pre>
43:      */
44:     public function __construct(array $params = array())
45:     {
46:         $params = array_merge(array(
47:             'password' => '',
48:             'requestuser' => false,
49:             'username' => 'horde_user'
50:         ), $params);
51: 
52:         parent::__construct($params);
53:     }
54: 
55:     /**
56:      * Horde_Auth_Exception should pass a message string (if any) in the message
57:      * field, and the REASON_* constant in the code field (defaults to
58:      * REASON_MESSAGE).
59:      *
60:      * @param string $userID      The userID to check.
61:      * @param array $credentials  An array of login credentials.
62:      *
63:      * @throws Horde_Auth_Exception
64:      */
65:     protected function _authenticate($userId, $credentials)
66:     {
67:         throw new Horde_Auth_Exception('Unsupported.');
68:     }
69: 
70:     /**
71:      * Automatic authentication: Set the user allowed IP block.
72:      *
73:      * @return boolean  Whether or not the client is allowed.
74:      */
75:     public function transparent()
76:     {
77:         $this->_credentials['userId'] = (!empty($this->_params['requestuser']) && isset($_REQUEST['username']))
78:             ? $_REQUEST['username']
79:             : $this->_params['username'];
80:         $this->_credentials['credentials'] = array(
81:             'password' => isset($this->_params['password']) ? $this->_params['password'] : null
82:         );
83: 
84:         return true;
85:     }
86: 
87: }
88: 
API documentation generated by ApiGen