├── browserid_mediawiki.body.php ├── browserid_mediawiki.i18n.php ├── browserid_mediawiki.hooks.php ├── scripts └── login.js ├── README.md ├── SpecialBrowserIDLogin.php ├── browserid_mediawiki.login.php ├── LICENSE.md └── browserid_mediawiki.php /browserid_mediawiki.body.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /browserid_mediawiki.i18n.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /browserid_mediawiki.hooks.php: -------------------------------------------------------------------------------- 1 | addScriptFile( "https://browserid.org/include.js" ); 6 | 7 | $out->addScriptFile( "{$wgScriptPath}/extensions/browserid_mediawiki/scripts/login.js" ); 8 | return true; 9 | } 10 | } 11 | ?> 12 | -------------------------------------------------------------------------------- /scripts/login.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $('#login').click(function(event) { 3 | event.preventDefault(); 4 | 5 | navigator.id.getVerifiedEmail(function(assertion) { 6 | if(assertion) { 7 | sajax_do_call('verifyAssertion', [assertion], function(xhr) { 8 | var info = JSON.parse(xhr.responseText); 9 | console.log("response: " + info.email); 10 | }); 11 | } 12 | }); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MediaWiki extension to authenticate using BrowserID 2 | 3 | This has only had a few hours of development time and does absolutely nothing with regards to authentication. Not ready for public consumption! 4 | 5 | 6 | ## Developer Info: 7 | 8 | Primary Developer: 9 | Shane Tomlinson - 10 | set117@yahoo.com, stomlinson@mozilla.com 11 | @shane_tomlinson 12 | http://www.shanetomlinson.com 13 | 14 | 15 | ## License Info: 16 | MPL 1.1, GPL 2.0, LGPL 2.1 17 | -------------------------------------------------------------------------------- /SpecialBrowserIDLogin.php: -------------------------------------------------------------------------------- 1 | setHeaders(); 12 | 13 | # Get request data from, e.g. 14 | $param = $wgRequest->getText('param'); 15 | 16 | $output='' . 17 | 'Login' . 18 | ''; 19 | 20 | 21 | $wgOut->addHTML( $output ); 22 | } 23 | } 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /browserid_mediawiki.login.php: -------------------------------------------------------------------------------- 1 | 2 | $audience, 9 | 'assertion'=>$assertion 10 | ); 11 | return BrowserIDVerify::do_post_request($url, $data); 12 | } 13 | 14 | private static function do_post_request($url, $data) { 15 | $data_string = http_build_query($data); 16 | 17 | $ch = curl_init(); 18 | curl_setopt($ch,CURLOPT_URL,$url); 19 | curl_setopt($ch,CURLOPT_POST,count($data)); 20 | curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string); 21 | $result = curl_exec($ch); 22 | $info = curl_getinfo($ch); 23 | 24 | curl_close($ch); 25 | 26 | return ''; 27 | } 28 | 29 | } 30 | 31 | ?> 32 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | ***** BEGIN LICENSE BLOCK ***** 2 | Version: MPL 1.1/LGPL 2.1/GPL 2.0 3 | 4 | The contents of this file are subject to the Mozilla Public License Version 5 | 1.1 (the "License"); you may not use this file except in compliance with 6 | ... 7 | for the specific language governing rights and limitations under the 8 | License. 9 | 10 | The Original Code is BrowserID-addon. 11 | 12 | The Initial Developer of the Original Code is 13 | Shane Tomlinson 14 | 15 | Portions created by the Initial Developer are Copyright (C) 2011 16 | the Initial Developer. All Rights Reserved. 17 | 18 | Contributor(s): 19 | 20 | Alternatively, the contents of this file may be used under the terms of 21 | either of the GNU General Public License Version 2 or later (the "GPL"), 22 | ... 23 | the terms of any one of the MPL, the GPL or the LGPL. 24 | 25 | ***** END LICENSE BLOCK ***** -------------------------------------------------------------------------------- /browserid_mediawiki.php: -------------------------------------------------------------------------------- 1 | __FILE__, 15 | 'name' => 'browserid_mediawiki', 16 | 'description' => 'User authentication using BrowserID', 17 | 'author' => 'Shane Tomlinson', 18 | 'url' => 'http://www.shanetomlinson.com', 19 | 'version' => '0.0.1a' 20 | ); 21 | 22 | 23 | 24 | 25 | $wgBrowserIDOptions = array(); 26 | $wgBrowserIDOptions['button'] = 'https://browserid.org/i/sign_in_blue.png'; 27 | 28 | $dir = dirname(__FILE__) . '/'; 29 | 30 | $wgAutoloadClasses['SpecialBrowserIDLogin'] = $dir . 'SpecialBrowserIDLogin.php'; 31 | $wgAutoloadClasses['BrowserIDHooks'] = $dir . 'browserid_mediawiki.hooks.php'; 32 | $wgAutoloadClasses['BrowserIDVerify'] = $dir . 'browserid_mediawiki.login.php'; 33 | $wgSpecialPages['BrowserIDLogin'] = 'SpecialBrowserIDLogin'; 34 | 35 | $wgHooks['BeforePageDisplay'][] = 'BrowserIDHooks::BeforePageDisplay'; 36 | 37 | $wgShowExceptionDetails = true; 38 | 39 | $wgAjaxExportList[] = 'verifyAssertion'; 40 | function verifyAssertion($assertion) { 41 | return BrowserIDVerify::login('localhost', $assertion); 42 | } 43 | ?> 44 | --------------------------------------------------------------------------------