Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -75,6 +75,7 @@ |
76 | 76 | 'ExternalStoreHttp' => 'includes/ExternalStoreHttp.php', |
77 | 77 | 'ExternalStore' => 'includes/ExternalStore.php', |
78 | 78 | 'ExternalUser' => 'includes/ExternalUser.php', |
| 79 | + 'ExternalUser_Hardcoded' => 'includes/extauth/Hardcoded.php', |
79 | 80 | 'ExternalUser_vB' => 'includes/extauth/vB.php', |
80 | 81 | 'FatalError' => 'includes/Exception.php', |
81 | 82 | 'FakeTitle' => 'includes/FakeTitle.php', |
Index: trunk/phase3/includes/extauth/Hardcoded.php |
— | — | @@ -0,0 +1,77 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +# Copyright (C) 2009 Aryeh Gregor |
| 5 | +# |
| 6 | +# This program is free software; you can redistribute it and/or modify |
| 7 | +# it under the terms of the GNU General Public License as published by |
| 8 | +# the Free Software Foundation; either version 2 of the License, or |
| 9 | +# (at your option) any later version. |
| 10 | +# |
| 11 | +# This program is distributed in the hope that it will be useful, |
| 12 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | +# GNU General Public License for more details. |
| 15 | +# |
| 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 | +# http://www.gnu.org/copyleft/gpl.html |
| 20 | + |
| 21 | +/** |
| 22 | + * This class supports external authentication from a literal array dumped in |
| 23 | + * LocalSettings.php. It's mostly useful for testing. Example configuration: |
| 24 | + * |
| 25 | + * $wgExternalAuthType = 'Hardcoded'; |
| 26 | + * $wgExternalAuthConf = array( |
| 27 | + * 'Bob Smith' => array( |
| 28 | + * 'password' => 'literal string', |
| 29 | + * 'emailaddress' => 'bob@example.com', |
| 30 | + * ), |
| 31 | + * ); |
| 32 | + * |
| 33 | + * Multiple names may be provided. The keys of the inner arrays can be either |
| 34 | + * 'password', or the name of any preference. |
| 35 | + */ |
| 36 | +class ExternalUser_Hardcoded extends ExternalUser { |
| 37 | + private $mName; |
| 38 | + |
| 39 | + protected function initFromName( $name ) { |
| 40 | + global $wgExternalAuthConf; |
| 41 | + |
| 42 | + if ( isset( $wgExternalAuthConf[$name] ) ) { |
| 43 | + $this->mName = $name; |
| 44 | + return true; |
| 45 | + } |
| 46 | + return false; |
| 47 | + } |
| 48 | + |
| 49 | + protected function initFromId( $id ) { |
| 50 | + return $this->initFromName( $id ); |
| 51 | + } |
| 52 | + |
| 53 | + public function getId() { |
| 54 | + return $this->mName; |
| 55 | + } |
| 56 | + |
| 57 | + public function getName() { |
| 58 | + return $this->mName; |
| 59 | + } |
| 60 | + |
| 61 | + public function authenticate( $password ) { |
| 62 | + global $wgExternalAuthConf; |
| 63 | + |
| 64 | + return isset( $wgExternalAuthConf[$this->mName]['password'] ) |
| 65 | + && $wgExternalAuthConf[$this->mName]['password'] == $password; |
| 66 | + } |
| 67 | + |
| 68 | + public function getPref( $pref ) { |
| 69 | + global $wgExternalAuthConf; |
| 70 | + |
| 71 | + if ( isset( $wgExternalAuthConf[$this->mName][$pref] ) ) { |
| 72 | + return $wgExternalAuthConf[$this->mName][$pref]; |
| 73 | + } |
| 74 | + return null; |
| 75 | + } |
| 76 | + |
| 77 | + # TODO: Implement setPref() via regex on LocalSettings. (Just kidding.) |
| 78 | +} |
Property changes on: trunk/phase3/includes/extauth/Hardcoded.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 79 | + native |