From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- includes/extauth/Hardcoded.php | 84 --------------------- includes/extauth/MediaWiki.php | 168 ----------------------------------------- includes/extauth/vB.php | 146 ----------------------------------- 3 files changed, 398 deletions(-) delete mode 100644 includes/extauth/Hardcoded.php delete mode 100644 includes/extauth/MediaWiki.php delete mode 100644 includes/extauth/vB.php (limited to 'includes/extauth') diff --git a/includes/extauth/Hardcoded.php b/includes/extauth/Hardcoded.php deleted file mode 100644 index dfb46742..00000000 --- a/includes/extauth/Hardcoded.php +++ /dev/null @@ -1,84 +0,0 @@ - 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.) -} diff --git a/includes/extauth/MediaWiki.php b/includes/extauth/MediaWiki.php deleted file mode 100644 index c7f6a204..00000000 --- a/includes/extauth/MediaWiki.php +++ /dev/null @@ -1,168 +0,0 @@ - 'mysql', - * 'DBserver' => 'localhost', - * 'DBname' => 'wikidb', - * 'DBuser' => 'quasit', - * 'DBpassword' => 'a5Cr:yf9u-6[{`g', - * 'DBprefix' => '', - * ); - * - * All fields must be present. These mean the same things as $wgDBtype, - * $wgDBserver, etc. This implementation is quite crude; it could easily - * support multiple database servers, for instance, and memcached, and it - * probably has bugs. Kind of hard to reuse code when things might rely on who - * knows what configuration globals. - * - * If either wiki uses the UserComparePasswords hook, password authentication - * might fail unexpectedly unless they both do the exact same validation. - * There may be other corner cases like this where this will fail, but it - * should be unlikely. - * - * @ingroup ExternalUser - */ -class ExternalUser_MediaWiki extends ExternalUser { - private $mRow; - - /** - * @var DatabaseBase - */ - private $mDb; - - /** - * @param $name string - * @return bool - */ - protected function initFromName( $name ) { - # We might not need the 'usable' bit, but let's be safe. Theoretically - # this might return wrong results for old versions, but it's probably - # good enough. - $name = User::getCanonicalName( $name, 'usable' ); - - if ( !is_string( $name ) ) { - return false; - } - - return $this->initFromCond( array( 'user_name' => $name ) ); - } - - /** - * @param $id int - * @return bool - */ - protected function initFromId( $id ) { - return $this->initFromCond( array( 'user_id' => $id ) ); - } - - /** - * @param $cond array - * @return bool - */ - private function initFromCond( $cond ) { - global $wgExternalAuthConf; - - $this->mDb = DatabaseBase::factory( $wgExternalAuthConf['DBtype'], - array( - 'host' => $wgExternalAuthConf['DBserver'], - 'user' => $wgExternalAuthConf['DBuser'], - 'password' => $wgExternalAuthConf['DBpassword'], - 'dbname' => $wgExternalAuthConf['DBname'], - 'tablePrefix' => $wgExternalAuthConf['DBprefix'], - ) - ); - - $row = $this->mDb->selectRow( - 'user', - array( - 'user_name', 'user_id', 'user_password', 'user_email', - 'user_email_authenticated' - ), - $cond, - __METHOD__ - ); - if ( !$row ) { - return false; - } - $this->mRow = $row; - - return true; - } - - # TODO: Implement initFromCookie(). - - public function getId() { - return $this->mRow->user_id; - } - - /** - * @return string - */ - public function getName() { - return $this->mRow->user_name; - } - - public function authenticate( $password ) { - # This might be wrong if anyone actually uses the UserComparePasswords hook - # (on either end), so don't use this if you those are incompatible. - return User::comparePasswords( $this->mRow->user_password, $password, - $this->mRow->user_id ); - } - - public function getPref( $pref ) { - # @todo FIXME: Return other prefs too. Lots of global-riddled code that does - # this normally. - if ( $pref === 'emailaddress' - && $this->row->user_email_authenticated !== null ) { - return $this->mRow->user_email; - } - return null; - } - - /** - * @return array - */ - public function getGroups() { - # @todo FIXME: Untested. - $groups = array(); - $res = $this->mDb->select( - 'user_groups', - 'ug_group', - array( 'ug_user' => $this->mRow->user_id ), - __METHOD__ - ); - foreach ( $res as $row ) { - $groups[] = $row->ug_group; - } - return $groups; - } - - # TODO: Implement setPref(). -} diff --git a/includes/extauth/vB.php b/includes/extauth/vB.php deleted file mode 100644 index 0565a2e3..00000000 --- a/includes/extauth/vB.php +++ /dev/null @@ -1,146 +0,0 @@ -, versions 3.5 and up. It calls no functions or - * code, only reads from the database. Example lines to put in - * LocalSettings.php: - * - * $wgExternalAuthType = 'ExternalUser_vB'; - * $wgExternalAuthConf = array( - * 'server' => 'localhost', - * 'username' => 'forum', - * 'password' => 'udE,jSqDJ<""p=fI.K9', - * 'dbname' => 'forum', - * 'tablePrefix' => '', - * 'cookieprefix' => 'bb' - * ); - * - * @ingroup ExternalUser - */ -class ExternalUser_vB extends ExternalUser { - private $mRow; - - protected function initFromName( $name ) { - return $this->initFromCond( array( 'username' => $name ) ); - } - - protected function initFromId( $id ) { - return $this->initFromCond( array( 'userid' => $id ) ); - } - - protected function initFromCookie() { - # Try using the session table. It will only have a row if the user has - # an active session, so it might not always work, but it's a lot easier - # than trying to convince PHP to give us vB's $_SESSION. - global $wgExternalAuthConf, $wgRequest; - if ( !isset( $wgExternalAuthConf['cookieprefix'] ) ) { - $prefix = 'bb'; - } else { - $prefix = $wgExternalAuthConf['cookieprefix']; - } - if ( $wgRequest->getCookie( 'sessionhash', $prefix ) === null ) { - return false; - } - - $db = $this->getDb(); - - $row = $db->selectRow( - array( 'session', 'user' ), - $this->getFields(), - array( - 'session.userid = user.userid', - 'sessionhash' => $wgRequest->getCookie( 'sessionhash', $prefix ), - ), - __METHOD__ - ); - if ( !$row ) { - return false; - } - $this->mRow = $row; - - return true; - } - - private function initFromCond( $cond ) { - $db = $this->getDb(); - - $row = $db->selectRow( - 'user', - $this->getFields(), - $cond, - __METHOD__ - ); - if ( !$row ) { - return false; - } - $this->mRow = $row; - - return true; - } - - private function getDb() { - global $wgExternalAuthConf; - return DatabaseBase::factory( 'mysql', - array( - 'host' => $wgExternalAuthConf['server'], - 'user' => $wgExternalAuthConf['username'], - 'password' => $wgExternalAuthConf['password'], - 'dbname' => $wgExternalAuthConf['dbname'], - 'tablePrefix' => $wgExternalAuthConf['tablePrefix'], - ) - ); - } - - private function getFields() { - return array( 'user.userid', 'username', 'password', 'salt', 'email', - 'usergroupid', 'membergroupids' ); - } - - public function getId() { return $this->mRow->userid; } - public function getName() { return $this->mRow->username; } - - public function authenticate( $password ) { - # vBulletin seemingly strips whitespace from passwords - $password = trim( $password ); - return $this->mRow->password == md5( md5( $password ) - . $this->mRow->salt ); - } - - public function getPref( $pref ) { - if ( $pref == 'emailaddress' && $this->mRow->email ) { - # TODO: only return if validated? - return $this->mRow->email; - } - return null; - } - - public function getGroups() { - $groups = array( $this->mRow->usergroupid ); - $groups = array_merge( $groups, explode( ',', $this->mRow->membergroupids ) ); - $groups = array_unique( $groups ); - return $groups; - } -} -- cgit v1.2.2