CSteipp has submitted this change and it was merged.

Change subject: Created skeleton code for the OAuth extension.
......................................................................


Created skeleton code for the OAuth extension.

Change-Id: I660ac5717bb7b99b24b8dd88c80062c2ebf4fe7c
---
A OAuth.config.php
A OAuth.php
A OAuth.setup.php
A api/OAuthAPI.setup.php
A backend/OAuthUtils.php
A backend/schema/OAuthUpdater.hooks.php
A backend/schema/mysql/OAuth.sql
A frontend/OAuthUI.setup.php
A frontend/language/OAuth.alias.php
A frontend/language/OAuth.i18n.php
10 files changed, 205 insertions(+), 0 deletions(-)

Approvals:
  CSteipp: Verified; Looks good to me, approved



diff --git a/OAuth.config.php b/OAuth.config.php
new file mode 100644
index 0000000..fb7d4d5
--- /dev/null
+++ b/OAuth.config.php
@@ -0,0 +1,8 @@
+<?php
+
+# ######## Configuration variables ########
+# IMPORTANT: DO NOT EDIT THIS FILE
+# When configuring globals, set them at LocalSettings.php instead
+
+# End of configuration variables.
+# ########
diff --git a/OAuth.php b/OAuth.php
new file mode 100644
index 0000000..fabbaac
--- /dev/null
+++ b/OAuth.php
@@ -0,0 +1,48 @@
+<?php
+/*
+ (c) Aaron Schulz 2013, GPL
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ http://www.gnu.org/copyleft/gpl.html
+*/
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       echo "OAuth extension\n";
+       exit( 1 ) ;
+}
+
+$wgExtensionCredits['other'][] = array(
+       'path'           => __FILE__,
+       'name'           => 'OAuth 1.0a API authentication',
+       'descriptionmsg' => 'oath-desc',
+       'author'         => array( 'Aaron Schulz' ),
+       'url'            => 'https://www.mediawiki.org/wiki/Extension:OAuth',
+);
+
+# Load default config variables
+require( __DIR__ . '/OAuth.config.php' );
+
+# Define were PHP files and i18n files are located
+require( __DIR__ . '/OAuth.setup.php' );
+OAuthSetup::defineSourcePaths( $wgAutoloadClasses, $wgExtensionMessagesFiles );
+
+# Define JS/CSS modules and file locations
+OAuthUISetup::defineResourceModules( $wgResourceModules );
+
+# Actually register special pages
+OAuthUISetup::defineSpecialPages( $wgSpecialPages, $wgSpecialPageGroups );
+
+# API-related hook handlers
+OAuthAPISetup::defineHookHandlers( $wgHooks );
diff --git a/OAuth.setup.php b/OAuth.setup.php
new file mode 100644
index 0000000..52d15ac
--- /dev/null
+++ b/OAuth.setup.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Class containing basic setup functions.
+ */
+class OAuthSetup {
+       /**
+        * Register source code paths.
+        * This function must NOT depend on any config vars.
+        *
+        * @param $classes Array $classes
+        * @param $messagesFiles Array $messagesFiles
+        * @return void
+        */
+       public static function defineSourcePaths( array &$classes, array 
&$messagesFiles ) {
+               $dir = __DIR__;
+
+               # Basic directory layout
+               $backendDir       = "$dir/backend";
+               $schemaDir        = "$dir/backend/schema";
+               $businessDir      = "$dir/business";
+               $apiDir           = "$dir/api";
+               $frontendDir      = "$dir/frontend";
+               $langDir          = "$dir/frontend/language/";
+               $spActionDir      = "$dir/frontend/specialpages/actions";
+
+               # Main i18n file and special page alias file
+               $messagesFiles['OAuth'] = "$langDir/OAuth.i18n.php";
+               $messagesFiles['OAuthAliases'] = "$langDir/OAuth.alias.php";
+
+               $classes['OAuthAPISetup'] = "$apiDir/OAuthAPI.setup.php";
+               $classes['OAuthUISetup'] = "$frontendDir/OAuthUI.setup.php";
+
+               # API for "initiate"?
+               # API for "token"?
+
+               # Special:OAuthClientRegistration
+               # Special:OAuthClientRegistrationApproval
+               # Special:OAuth/authorize
+               # Special:OAuth/initiate?
+               # Special:OAuth/token?
+
+               # Utility functions
+               $classes['OAuth'] = "$backendDir/OAuthUtils.php";
+
+               # Data access objects
+
+               # Business logic
+
+               # Schema changes
+               $classes['OAuthUpdaterHooks'] = 
"$schemaDir/OAuthUpdater.hooks.php";
+       }
+}
diff --git a/api/OAuthAPI.setup.php b/api/OAuthAPI.setup.php
new file mode 100644
index 0000000..e937607
--- /dev/null
+++ b/api/OAuthAPI.setup.php
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Class containing hooked functions for an OAuth environment
+ */
+class OAuthAPISetup {
+       /**
+        * Register hooks handlers
+        * @param $hooks Array $wgHooks (assoc array of hooks and handlers)
+        * @return void
+        */
+       public static function defineHookHandlers( array &$hooks ) {
+
+       }
+}
diff --git a/backend/OAuthUtils.php b/backend/OAuthUtils.php
new file mode 100644
index 0000000..31141b9
--- /dev/null
+++ b/backend/OAuthUtils.php
@@ -0,0 +1,7 @@
+<?php
+/**
+ * Static utility functions for OAuth
+ */
+class OAuthUtils {
+
+}
diff --git a/backend/schema/OAuthUpdater.hooks.php 
b/backend/schema/OAuthUpdater.hooks.php
new file mode 100644
index 0000000..d05544d
--- /dev/null
+++ b/backend/schema/OAuthUpdater.hooks.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Class containing updater functions for an OAuth environment
+ */
+class OAuthUpdaterHooks {
+
+       /**
+        * @param DatabaseUpdater $updater
+        * @return bool
+        */
+       public static function addSchemaUpdates( DatabaseUpdater $updater ) {
+               $base = dirname( __FILE__ );
+               if ( $updater->getDB()->getType() == 'mysql' ) {
+                       $base = "$base/mysql";
+
+                       // $updater->addExtensionTable( 'oauth_registration', 
"$base/OAuth.sql" );
+               } elseif ( $updater->getDB()->getType() == 'postgres' ) {
+                       $base = "$base/postgres";
+
+                       // @TODO
+               }
+               return true;
+       }
+}
diff --git a/backend/schema/mysql/OAuth.sql b/backend/schema/mysql/OAuth.sql
new file mode 100644
index 0000000..193d1a6
--- /dev/null
+++ b/backend/schema/mysql/OAuth.sql
@@ -0,0 +1,3 @@
+-- (c) Aaron Schulz, 2013
+
+-- Replace /*_*/ with the proper prefix
diff --git a/frontend/OAuthUI.setup.php b/frontend/OAuthUI.setup.php
new file mode 100644
index 0000000..c5d0c58
--- /dev/null
+++ b/frontend/OAuthUI.setup.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Class containing hooked functions for an OAuth environment
+ */
+class OAuthUISetup {
+       /**
+        * Register special pages as needed.
+        * @param $pages Array $wgSpecialPages (list of special pages)
+        * @param $groups Array $wgSpecialPageGroups (assoc array of special 
page groups)
+        * @return void
+        */
+       public static function defineSpecialPages( array &$pages, array 
&$groups ) {
+
+       }
+
+       /**
+        * Append resource module definitions
+        * @param $modules Array $wgResourceModules
+        * @return void
+        */
+       public static function defineResourceModules( array &$modules ) {
+
+       }
+}
diff --git a/frontend/language/OAuth.alias.php 
b/frontend/language/OAuth.alias.php
new file mode 100644
index 0000000..9d384a4
--- /dev/null
+++ b/frontend/language/OAuth.alias.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Aliases for extension OAuth
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$specialPageAliases = array();
+
+/** English (English) */
+$specialPageAliases['en'] = array();
diff --git a/frontend/language/OAuth.i18n.php b/frontend/language/OAuth.i18n.php
new file mode 100644
index 0000000..5c9deab
--- /dev/null
+++ b/frontend/language/OAuth.i18n.php
@@ -0,0 +1,13 @@
+<?php
+/**
+ * Internationalisation file for OAuth extension.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+$messages['en'] = array(
+       'oath-desc' => 'OAuth 1.0a API authentication',
+);

-- 
To view, visit https://gerrit.wikimedia.org/r/67286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I660ac5717bb7b99b24b8dd88c80062c2ebf4fe7c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OAuth
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: CSteipp <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to