[Fusionforge-commits] r12791 - in trunk/src/plugins/oslc: etc/plugins/oslc include/oslc-zend/application/controllers

Sabri LABBENE labbenes at fusionforge.org
Wed Mar 16 16:23:42 CET 2011


Author: labbenes
Date: 2011-03-16 16:23:42 +0100 (Wed, 16 Mar 2011)
New Revision: 12791

Modified:
   trunk/src/plugins/oslc/etc/plugins/oslc/config.php
   trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
   trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
Log:
Enable OAuth authentication possibility for oslc plugin. Needs to be coupled with recents devs on oauthplugin and external auths.

Modified: trunk/src/plugins/oslc/etc/plugins/oslc/config.php
===================================================================
--- trunk/src/plugins/oslc/etc/plugins/oslc/config.php	2011-03-16 11:40:00 UTC (rev 12790)
+++ trunk/src/plugins/oslc/etc/plugins/oslc/config.php	2011-03-16 15:23:42 UTC (rev 12791)
@@ -44,7 +44,8 @@
 		throw new Exception('Unsupported TRACKER_TYPE : '. TRACKER_TYPE .' !');
 		break;
 }
-
+/*
+define(AUTH_TYPE, 'oauth');
 // Define the backend tracker type : by defaut : mantis
 defined('AUTH_TYPE')
     || define('AUTH_TYPE', (getenv('AUTH_TYPE') ? getenv('AUTH_TYPE') : 'basic'));
@@ -75,5 +76,5 @@
 		throw new Exception('Unsupported AUTH_TYPE : '. AUTH_TYPE .' !');
 		break;
 }
-
+*/
 ?>

Modified: trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2011-03-16 11:40:00 UTC (rev 12790)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeCmController.php	2011-03-16 15:23:42 UTC (rev 12791)
@@ -120,7 +120,7 @@
 		$params = $this->getRequest()->getParams();
 
 		// check authentication although it's not yet really useful
-		/*$login = null;
+		$login = null;
 		$authenticated = $this->retrieveAuthentication($login);
 		if(isset($login)) {
 			// Basic auth requested
@@ -129,7 +129,7 @@
 				// can't go on;
 				throw new Exception('Invalid authentication provided !');
 			}
-		}*/
+		}
 
 		// handle OSLC services catalog access (http://open-services.net/bin/view/Main/OslcServiceProviderCatalogV1)
 		if ( isset($params['id']) && ($params['id'] == "oslc-services")) {
@@ -580,29 +580,34 @@
 		$this->view->data = $data;
 	}
 	
-		/**
-	 * Performs authentication according to the configured AUTH_TYPE configured
+	/**
+	 * Performs authentication according to the authorization header recieved.
 	 *
 	 * @param string $login
-	 * @return True if auth is valid, in which case $login is modified.
-	 * 		   If there was actually no auth requested, then return False, but $login will be set to null.
+	 * @return True if auth is valid, FALSE otherwise.
 	 */
 
 	private function retrieveAuthentication(&$login) {
-		switch (AUTH_TYPE) {
-			case 'basic':
+		$request = $this->getRequest();
+		$auth = $request->getHeader('Authorization');
+		if ($auth) {
+			$auth_type = explode(' ',$auth);
+			$auth_type = $auth_type[0];
+			if (strcasecmp($auth_type, 'OAuth')) {
+				$returned = $this->oslc->checkOauthAuthorization($auth);
+				return $returned;
+			} elseif (strcasecmp($auth_type, 'basic')) {
 				return $this->retrieveRequestAuthHttpBasic($login);
-				break;
-			case 'oauth':
-				return $this->checkOauthAuthorization($login);
-				break;
-			default:
-				throw new BadRequestException('Unsupported AUTH_TYPE : '. AUTH_TYPE .' !');
-				break;
+			} else {
+				throw new BadRequestException('Unsupported Authorization type : '. $auth_type .' !');	
+			}
+		} else {
+			return FALSE;
 		}
+
 	}
 	
-/**
+	/**
 	 * Helper function that performs HTTP Basic authentication from request parameters/headers
 	 *
 	 * @param string $login

Modified: trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php
===================================================================
--- trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	2011-03-16 11:40:00 UTC (rev 12790)
+++ trunk/src/plugins/oslc/include/oslc-zend/application/controllers/FusionForgeOSLCConnector.php	2011-03-16 15:23:42 UTC (rev 12791)
@@ -703,6 +703,10 @@
 		$basicResolver = new FusionForge_Http_Auth_Resolver($login, $password);
 		return $basicResolver;
 	}
+	
+	public function checkOauthAuthorization($auth){
+		// Add code for Oauth authentication.
+	}
 }
 
 // HTTP auth adapater's resolver using FusionForge APIs for user + password verification




More information about the Fusionforge-commits mailing list