5 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
6 # http://www.mediawiki.org/
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 # http://www.gnu.org/copyleft/gpl.html
24 * Authentication plugin interface. Instantiate a subclass of AuthPlugin
25 * and set $wgAuth to it to authenticate against some external tool.
27 * The default behavior is not to do anything, and use the local user
28 * database for all authentication. A subclass can require that all
29 * accounts authenticate externally, or use it only as a fallback; also
30 * you can transparently create internal wiki accounts the first time
31 * someone logs in who can be authenticated externally.
33 * This interface is new, and might change a bit before 1.4.0 final is
40 * Check whether there exists a user account with the given name.
41 * The name will be normalized to MediaWiki's requirements, so
42 * you might need to munge it (for instance, for lowercase initial
45 * @param string $username
49 function userExists( $username ) {
55 * Check if a username+password pair is a valid login.
56 * The name will be normalized to MediaWiki's requirements, so
57 * you might need to munge it (for instance, for lowercase initial
60 * @param string $username
61 * @param string $password
65 function authenticate( $username, $password ) {
71 * Modify options in the login template.
73 * @param UserLoginTemplate $template
76 function modifyUITemplate( &$template ) {
78 $template->set( 'usedomain', false );
82 * Set the domain this plugin is supposed to use when authenticating.
84 * @param string $domain
87 function setDomain( $domain ) {
88 $this->domain
= $domain;
92 * Check to see if the specific domain is a valid domain.
94 * @param string $domain
98 function validDomain( $domain ) {
104 * When a user logs in, optionally fill in preferences and such.
105 * For instance, you might pull the email address or real name from the
106 * external user database.
108 * The User object is passed by reference so it can be modified; don't
109 * forget the & on your function declaration.
114 function updateUser( &$user ) {
115 # Override this and do something
121 * Return true if the wiki should create a new local account automatically
122 * when asked to login a user who doesn't exist locally but does in the
123 * external auth database.
125 * If you don't automatically create accounts, you must still create
126 * accounts in some way. It's not possible to authenticate without
129 * This is just a question, and shouldn't perform any actions.
134 function autoCreate() {
139 * Set the given password in the authentication database.
140 * Return true if successful.
142 * @param string $password
146 function setPassword( $password ) {
151 * Update user information in the external authentication database.
152 * Return true if successful.
158 function updateExternalDB( $user ) {
163 * Check to see if external accounts can be created.
164 * Return true if external accounts can be created.
168 function canCreateAccounts() {
173 * Add a user to the external authentication database.
174 * Return true if successful.
177 * @param string $password
181 function addUser( $user, $password ) {
187 * Return true to prevent logins that don't authenticate here from being
188 * checked against the local database's password fields.
190 * This is just a question, and shouldn't perform any actions.
200 * When creating a user account, optionally fill in preferences and such.
201 * For instance, you might pull the email address or real name from the
202 * external user database.
204 * The User object is passed by reference so it can be modified; don't
205 * forget the & on your function declaration.
210 function initUser( &$user ) {
211 # Override this to do something.
215 * If you want to munge the case of an account name before the final
216 * check, now is your chance.
218 function getCanonicalName( $username ) {