array( * 'password' => 'literal string', * 'emailaddress' => 'bob@example.com', * ), * ); * * Multiple names may be provided. The keys of the inner arrays can be either * 'password', or the name of any preference. * * @ingroup ExternalUser */ class ExternalUser_Hardcoded extends ExternalUser { private $mName; protected function initFromName( $name ) { global $wgExternalAuthConf; if ( isset( $wgExternalAuthConf[$name] ) ) { $this->mName = $name; return true; } return false; } protected function initFromId( $id ) { return $this->initFromName( $id ); } public function getId() { return $this->mName; } public function getName() { return $this->mName; } public function authenticate( $password ) { global $wgExternalAuthConf; return isset( $wgExternalAuthConf[$this->mName]['password'] ) && $wgExternalAuthConf[$this->mName]['password'] == $password; } public function getPref( $pref ) { global $wgExternalAuthConf; if ( isset( $wgExternalAuthConf[$this->mName][$pref] ) ) { return $wgExternalAuthConf[$this->mName][$pref]; } return null; } # TODO: Implement setPref() via regex on LocalSettings. (Just kidding.) }