Widen SimpleSearch search box in Vector from 9em to 14em
[mediawiki.git] / includes / extauth / Hardcoded.php
bloba9a60beaf3993243719c56dc7db79ecc5f731194
1 <?php
3 # Copyright (C) 2009 Aryeh Gregor
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.
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.
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 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # http://www.gnu.org/copyleft/gpl.html
20 /**
21 * This class supports external authentication from a literal array dumped in
22 * LocalSettings.php. It's mostly useful for testing. Example configuration:
24 * $wgExternalAuthType = 'ExternalUser_Hardcoded';
25 * $wgExternalAuthConf = array(
26 * 'Bob Smith' => array(
27 * 'password' => 'literal string',
28 * 'emailaddress' => 'bob@example.com',
29 * ),
30 * );
32 * Multiple names may be provided. The keys of the inner arrays can be either
33 * 'password', or the name of any preference.
35 * @ingroup ExternalUser
37 class ExternalUser_Hardcoded extends ExternalUser {
38 private $mName;
40 protected function initFromName( $name ) {
41 global $wgExternalAuthConf;
43 if ( isset( $wgExternalAuthConf[$name] ) ) {
44 $this->mName = $name;
45 return true;
47 return false;
50 protected function initFromId( $id ) {
51 return $this->initFromName( $id );
54 public function getId() {
55 return $this->mName;
58 public function getName() {
59 return $this->mName;
62 public function authenticate( $password ) {
63 global $wgExternalAuthConf;
65 return isset( $wgExternalAuthConf[$this->mName]['password'] )
66 && $wgExternalAuthConf[$this->mName]['password'] == $password;
69 public function getPref( $pref ) {
70 global $wgExternalAuthConf;
72 if ( isset( $wgExternalAuthConf[$this->mName][$pref] ) ) {
73 return $wgExternalAuthConf[$this->mName][$pref];
75 return null;
78 # TODO: Implement setPref() via regex on LocalSettings. (Just kidding.)