2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 require_once('./includes/api_user.php');
25 * Abstract Authentication
27 * This is an abstract class that is used to provide authentication for
31 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
39 * The database connection to AUTHENTICATE against; can be to a separate database
45 * The database connection to the BUGDAR database
57 * Array of user data from the AUTHENTICATION database
63 * Array of user data from the BUGDAR database
68 // ###################################################################
72 function __construct()
76 $this->registry
=& $bugsys;
77 $this->db
=& $bugsys->db
;
79 $this->_setupDatabase();
82 // ###################################################################
84 * Sets up the database to authenticate against. You can create a new
85 * database object here. Whatever you choose, you need to reference
86 * Authentication->authDb to the object
88 function _setupDatabase() {}
90 // ###################################################################
92 * Returns the sanitized value of the user ID or unique identifier
93 * found in the cookie of an already-authenticated user.
95 function _fetchCookieUniqueId() {}
97 // ###################################################################
99 * Returns the sanitized value of the authentication key or cookie-safe
100 * password found in the cookies of an already-authenticated user.
102 function _fetchCookiePassword() {}
104 // ###################################################################
106 * Returns an array of user data fetched using the user information
107 * values found in cookies. It should NOT be responsible for verifying
108 * the authentication information, but only fetching it.
110 function _fetchUserUsingCookies() {}
112 // ###################################################################
114 * Returns TRUE if the cookie data values are valid in the data array
115 * returned from _fetchUserUsingCookies(), and FALSE if they are not.
117 function _verifyCookieData() {}
119 // ###################################################################
121 * Authenticates the user using cookie data. You shouldn't need to
122 * customize this method if you implement all the helpers correctly.
123 * Returns TRUE if the cookies are valid and the user is logged in.
125 function authenticateCookies()
127 if (!$this->_fetchCookieUniqueId() OR !$this->_fetchCookiePassword())
129 $this->_clearCookies();
133 $this->authUser
= $this->_fetchUserUsingCookies();
135 if (!$this->authUser
)
137 $this->authUser
= null
;
138 $this->_clearCookies();
142 if ($this->_verifyCookieData())
144 $this->_setCookies();
145 $this->bugdarUser
= $this->_fetchBugdarUserFromAuthUser();
150 $this->authUser
= null
;
151 $this->_clearCookies();
156 // ###################################################################
158 * Returns an array with the authentication user information, found
159 * by the unique login identifier passed to the function.
161 function _fetchUserWithIdentifier($string) {}
163 // ###################################################################
165 * Verifies that the authUser's password matches the plain-text password
166 * passed to this function. This is basically the transformation of
167 * the plaintext to the hashed password and the result of the comparison.
169 function _verifyLoginUser($password) {}
171 // ###################################################################
173 * Authenticates a user at login from two keys: an identifier and
174 * a password. In Bugdar, the identifier is an email, but it can be
175 * any unique string found in the authentication database. Returns
176 * TRUE if the authentication is successful, and FALSE if not.
178 function authenticateLogin($string, $password)
180 $this->authUser
= $this->_fetchUserWithIdentifier($string);
182 if (!$this->authUser
)
184 $this->authUser
= null
;
188 if ($this->_verifyLoginUser())
190 $this->_setCookies();
191 $this->bugdarUser
= $this->_fetchBugdarUserFromAuthUser();
196 $this->authUser
= null
201 // ###################################################################
203 * Returns the BUGDAR user array from the data in the AUTHENTICATION user
204 * array. If the Bugdar user does not exist, call _createBugdarUser()
205 * to add the user into the Bugdar database. This is necessary so Bugdar options
206 * can be saved in the Bugdar database (and not in the auth one), however
207 * authentication details will NOT be stored in the Bugdar database.
209 function _fetchBugdarUserFromAuthUser() {}
211 // ###################################################################
213 * Creates a Bugdar user with the authentication details specified in
214 * the auth array and returns it. You need to call this in
215 * _fetchBugdarUserFromAuthUser() and use the UserAPI to create the user.
216 * Example for this function is this (all of these fields are required):
218 * $user = new UserAPI($this->registry); // do not change this
219 * $user->set('email', $this->authUser['email']);
220 * $user->set('displayname', $this->authUser['name']);
221 * $user->set('password', $this->authUser['password']); // some random value that won't be used for authentication
222 * $user->set('usergroupid', 2); // default "Registered Users" group
223 * $user->set('authid', $this->authUser['userid']); // This must be a COMPLETELY STATIC key that is found in the auth db that will permanently link Bugdar to the auth user
224 * $user->insert(); // saves the user
226 * return $user->values; // returns the newly created user array
228 function _createBugdarUser() {}
230 // ###################################################################
232 * Responsible for unsetting all authentication cookies because they
235 function _clearCookies() {}
237 // ###################################################################
239 * Sets the authentication cookies; this is done both at login and
240 * for renewing the cookies upon successful cookie validation
242 function _setCookies() {}
245 /*=====================================================================*\
246 || ###################################################################
249 || ###################################################################
250 \*=====================================================================*/