eb2d469f3112fd42d8ef196d4f80ba7137b881b9
[lhc/web/wiklou.git] / includes / AuthPlugin.php
1 <?php
2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
19
20 /**
21 * Authentication plugin interface. Instantiate a subclass of AuthPlugin
22 * and set $wgAuth to it to authenticate against some external tool.
23 *
24 * The default behavior is not to do anything, and use the local user
25 * database for all authentication. A subclass can require that all
26 * accounts authenticate externally, or use it only as a fallback; also
27 * you can transparently create internal wiki accounts the first time
28 * someone logs in who can be authenticated externally.
29 *
30 * This interface is new, and might change a bit before 1.4.0 final is
31 * done...
32 *
33 * @package MediaWiki
34 */
35
36 class AuthPlugin {
37 /**
38 * Check whether there exists a user account with the given name.
39 * The name will be normalized to MediaWiki's requirements, so
40 * you might need to munge it (for instance, for lowercase initial
41 * letters).
42 *
43 * @param string $username
44 * @return bool
45 * @access public
46 */
47 function userExists( $username ) {
48 # Override this!
49 return false;
50 }
51
52 /**
53 * Check if a username+password pair is a valid login.
54 * The name will be normalized to MediaWiki's requirements, so
55 * you might need to munge it (for instance, for lowercase initial
56 * letters).
57 *
58 * @param string $username
59 * @param string $password
60 * @return bool
61 * @access public
62 */
63 function authenticate( $username, $password ) {
64 # Override this!
65 return false;
66 }
67
68 /**
69 * Return true if the wiki should create a new local account automatically
70 * when asked to login a user who doesn't exist locally but does in the
71 * external auth database.
72 *
73 * This is just a question, and shouldn't perform any actions.
74 *
75 * @return bool
76 * @access public
77 */
78 function autoCreate() {
79 return false;
80 }
81
82 /**
83 * Return true to prevent logins that don't authenticate here from being
84 * checked against the local database's password fields.
85 *
86 * This is just a question, and shouldn't perform any actions.
87 *
88 * @return bool
89 * @access public
90 */
91 function strict() {
92 return false;
93 }
94
95 /**
96 * When creating a user account, optionally fill in preferences and such.
97 * For instance, you might pull the email address or real name from the
98 * external user database.
99 *
100 * The User object is passed by reference so it can be modified; don't
101 * forget the & on your function declaration.
102 *
103 * @param User $user
104 * @access public
105 */
106 function initUser( &$user ) {
107 # Override this to do something.
108 }
109 }
110
111 ?>