r17234 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17233‎ | r17234 | r17235 >
Date:04:34, 24 October 2006
Author:evan
Status:old
Tags:
Comment:
An extension to add support for the MicroID (http://www.microid.org/)
standard to validate ownership of a user account on a Web service.
Despite the name, not directly related to OpenID.
Modified paths:
  • /trunk/extensions/MicroID (added) (history)
  • /trunk/extensions/MicroID/MicroID.php (added) (history)
  • /trunk/extensions/MicroID/README (added) (history)

Diff [purge]

Index: trunk/extensions/MicroID/MicroID.php
@@ -0,0 +1,104 @@
 2+<?php
 3+/**
 4+ * MicroID.php -- Generate MicroID meta info for user pages
 5+ * Copyright 2006 Internet Brands (http://www.internetbrands.com/)
 6+ * By Evan Prodromou <evan@wikitravel.org>
 7+ *
 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.
 12+ *
 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.
 17+ *
 18+ * You should have received a copy of the GNU General Public License
 19+ * along with this program; if not, write to the Free Software
 20+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 21+ *
 22+ * @author Evan Prodromou <evan@wikitravel.org>
 23+ * @package MediaWiki
 24+ * @subpackage Extensions
 25+ */
 26+
 27+if (defined('MEDIAWIKI')) {
 28+
 29+ define('MEDIAWIKI_MICROID_VERSION', '0.1');
 30+
 31+ $wgExtensionFunctions[] = 'setupMicroID';
 32+ $wgExtensionCredits['other'][] = array('name' => 'MicroID',
 33+ 'version' => MEDIAWIKI_MICROID_VERSION,
 34+ 'author' => 'Evan Prodromou',
 35+ 'url' => 'http://www.mediawiki.org/wiki/MicroID_extension',
 36+ 'description' => 'adds a [http://www.microid.org/ MicroID] ' .
 37+ 'to user pages to confirm account with external services');
 38+
 39+ function setupMicroID() {
 40+
 41+ global $wgOut, $wgRequest, $wgMessageCache, $wgHooks;
 42+
 43+ $wgMessageCache->addMessages(array('tog-microid' =>
 44+ 'Publish a <a href="http://microid.org/">MicroID</a> ' .
 45+ 'to confirm account with external services'));
 46+
 47+ $wgHooks['UserToggles'][] = 'MicroIDUserToggle';
 48+
 49+ $action = $wgRequest->getText('action', 'view');
 50+
 51+ if ($action == 'view') {
 52+
 53+ $title = $wgRequest->getText('title');
 54+
 55+ if (!isset($title) || strlen($title) == 0) {
 56+ # If there's no title, and Cache404 is in use, check using its stuff
 57+ if (defined('CACHE404_VERSION')) {
 58+ if ($_SERVER['REDIRECT_STATUS'] == 404) {
 59+ $url = getRedirectUrl($_SERVER);
 60+ if (isset($url)) {
 61+ $title = cacheUrlToTitle($url);
 62+ }
 63+ }
 64+ } else {
 65+ $title = wfMsg('mainpage');
 66+ }
 67+ }
 68+
 69+ $nt = Title::newFromText($title);
 70+
 71+ // If the page being viewed is a user page...
 72+
 73+ if ($nt &&
 74+ ($nt->getNamespace() == NS_USER) &&
 75+ strpos($nt->getText(), '/') === false)
 76+ {
 77+ // If the user qualifies...
 78+ wfDebug("MicroID: on User page " . $nt->getText() . "\n");
 79+
 80+ $user = User::newFromName($nt->getText());
 81+
 82+ if ($user && // got a user
 83+ $user->getID() != 0 && // they're real
 84+ $user->getEmail() && // they've added an email address
 85+ $user->isEmailConfirmed() && // it's been confirmed
 86+ $user->getOption('microid')) // they authorize microid
 87+ {
 88+ wfDebug("MicroID: on User page " . $nt->getText() . "\n");
 89+ $wgOut->addMeta('microid', MakeMicroID($user->getEmail(), $nt->getFullURL()));
 90+ }
 91+ }
 92+ }
 93+ }
 94+
 95+ function MakeMicroID($email, $url) {
 96+ return sha1( sha1( 'mailto:' . $email ) . sha1( $url ) );
 97+ }
 98+
 99+ function MicroIDUserToggle(&$arr) {
 100+ $arr[] = 'microid';
 101+ return true;
 102+ }
 103+}
 104+
 105+?>
\ No newline at end of file
Index: trunk/extensions/MicroID/README
@@ -0,0 +1,117 @@
 2+MediaWiki MicroID extension
 3+
 4+version 0.1
 5+24 Oct 2006
 6+
 7+This is the README file for the MicroID extension for MediaWiki
 8+software. The extension is only useful if you've got a MediaWiki
 9+installation; it can only be installed by the administrator of the site.
 10+
 11+The extension lets users verify their account on the wiki with an
 12+external service that understands MicroID (http://www.microid.org/). A
 13+microid is a special hash of the user's email address and user page
 14+URL that asserts that the user has that particular email address. One
 15+service that understands MicroID is ClaimID (http://claimid.com/).
 16+
 17+This is an early version of the extension and it's almost sure to have
 18+bugs. (Don't despair, though: this is running in production on
 19+Wikitravel [http://wikitravel.org/], a fairly big MW installation.)
 20+See the BUGS section below for info on how to report problems.
 21+
 22+== License ==
 23+
 24+Copyright 2006 Internet Brands (http://www.internetbrands.com/)
 25+
 26+This program is free software; you can redistribute it and/or modify
 27+it under the terms of the GNU General Public License as published by
 28+the Free Software Foundation; either version 2 of the License, or
 29+(at your option) any later version.
 30+
 31+This program is distributed in the hope that it will be useful,
 32+but WITHOUT ANY WARRANTY; without even the implied warranty of
 33+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 34+GNU General Public License for more details.
 35+
 36+You should have received a copy of the GNU General Public License
 37+along with this program; if not, write to the Free Software
 38+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 39+
 40+== Author ==
 41+
 42+Evan Prodromou <evan@wikitravel.org>
 43+
 44+== Pre-requisites ==
 45+
 46+This software was tested with MediaWiki 1.8.2 (which is what
 47+Wikitravel was running at the time.) It may or may not work with
 48+earlier or later versions, but please test it.
 49+
 50+It requires PHP 4.3.0 or greater to get the sha1() function to
 51+generate the special microid hash.
 52+
 53+== Installation ==
 54+
 55+To install, copy all the files in the archive you downloaded to the
 56+MicroID subdirectory of the extensions subdirectory of your MediaWiki
 57+installation.
 58+
 59+In your MediaWiki LocalSettings.php, add the following line some place
 60+towards the bottom of the file:
 61+
 62+ require_once("$IP/extensions/MicroID/MicroID.php");
 63+
 64+Theoretically it should work out of the box. On your wiki, if you go
 65+to to the [[Special:Version]] page, you should see the MicroID
 66+extension listed.
 67+
 68+== Usage ==
 69+
 70+The usage of the MicroID extension is mostly passive. User pages for
 71+registered users who have an email address stored in the system, and
 72+who've confirmed the address (or confirmation is disabled), and who've
 73+enabled MicroID (see below), will have a special <meta> tag with an
 74+appropriate MicroID. The page can be provided to identification
 75+services as verification of ownership of the account.
 76+
 77+== Privacy ==
 78+
 79+MicroID lets an external entity that knows an email address and the
 80+URL of a user page verify that the owner of that user page is also the
 81+owner of that email address. The external entity can't figure out the
 82+email address if they don't know it already; they can just confirm a
 83+tip (or guess).
 84+
 85+Because there may be cases where this is unacceptable to the user,
 86+each user can optionally enable or disable whether MicroIDs are
 87+created. A checkbox on the "Misc" tab of [[Special:Preferences]] lets
 88+the user decide whether or not to have a microid on their user page.
 89+
 90+== Configuration ==
 91+
 92+The administrator can decide whether MicroIDs are generated by
 93+default, or if the default is that the IDs will not be generated. In
 94+the LocalSettings.php file, you can turn on the default by adding this
 95+line:
 96+
 97+ $wgDefaultUserOptions['microid'] = 1;
 98+
 99+You can turn off the default by adding this line:
 100+
 101+ $wgDefaultUserOptions['microid'] = 0;
 102+
 103+== Translation ==
 104+
 105+The text of the MicroID checkbox on the user preferences page can be
 106+changed or translated like other MediaWiki interface string. The key
 107+is 'tog-microid', and on most systems editing
 108+[[MediaWiki:Tog-microid]] as an administrator will be enough to modify
 109+the prompt.
 110+
 111+== Bugs and enhancements ==
 112+
 113+If MicroIDs are not verifying correctly, check that the $wgServer
 114+configuration variable is set and is correct.
 115+
 116+Bugs or feature requests can be sent to the author at
 117+evan@wikitravel.org.
 118+