[Fusionforge-commits] r12921 - in trunk/src/plugins/oauthprovider: . example include www

Olivier Berger olberger at fusionforge.org
Fri Mar 25 19:47:53 CET 2011


Author: olberger
Date: 2011-03-25 19:47:52 +0100 (Fri, 25 Mar 2011)
New Revision: 12921

Added:
   trunk/src/plugins/oauthprovider/example/
   trunk/src/plugins/oauthprovider/example/command-line.php
Modified:
   trunk/src/plugins/oauthprovider/README
   trunk/src/plugins/oauthprovider/include/oauthprovider_plugin.php
   trunk/src/plugins/oauthprovider/www/access_tokens.php
   trunk/src/plugins/oauthprovider/www/authorize.php
   trunk/src/plugins/oauthprovider/www/consumer_delete.php
   trunk/src/plugins/oauthprovider/www/index.php
   trunk/src/plugins/oauthprovider/www/request_tokens.php
   trunk/src/plugins/oauthprovider/www/token_authorize.php
   trunk/src/plugins/oauthprovider/www/token_delete.php
   trunk/src/plugins/oauthprovider/www/token_deny.php
Log:
A bunch of changes and a demo client

Modified: trunk/src/plugins/oauthprovider/README
===================================================================
--- trunk/src/plugins/oauthprovider/README	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/README	2011-03-25 18:47:52 UTC (rev 12921)
@@ -3,4 +3,43 @@
 Depends on OAuth PHP library (http://code.google.com/p/oauth/source/browse/#svn%2Fcode%2Fphp) as of rev. 622
 (packaged in Debian in liboauth-php package).
 
+To test the OAuth plugin, you may use the 'command-line.php' provided script :
+
+1. Create a consumer in FF : this will generate a key and secret that you'll need to pass to command-line.php 
+(for instance, let's assume that you get 2a879dc112593828254c5127381d1b9a and 6cd7286abbdd0740c6fdfefcae3c8ec2, 
+that we'll use in the example runs below) :
+
+2. Generate a request token for that consumer (assuming that the forge runs on https://192.168.122.90) :
+
+ $ php example/command-line.php request_token 2a879dc112593828254c5127381d1b9a 6cd7286abbdd0740c6fdfefcae3c8ec2
+ 
+You'll get :
+
+ received request token :
+  $oauth_token : 2a38e3972926eb155514
+  $oauth_token_secret : 0920d9d074892dc96697
+
+ Go to the following URL in your FusionForge session to authorize the request token:
+  https://192.168.122.90/plugins/oauthprovider/authorize.php?oauth_token=2a38e3972926eb155514
+
+ Upon completion, you will be able request access tokens with the authorized token.
+
+3. Follow the provided instructions to access the authorization dialog (here by browsing 
+https://192.168.122.90/plugins/oauthprovider/authorize.php?oauth_token=2a38e3972926eb155514 with a valid 
+FusionForge session) where you'll be prompted for a role to grant to the consumer for that request token.
+
+4. Once you've authorized it, you may use your consumer and your request token's keys and secrets, to request 
+an access token :
+ 
+ $ php example/command-line.php access_token 2a879dc112593828254c5127381d1b9a 6cd7286abbdd0740c6fdfefcae3c8ec2 2a38e3972926eb155514 0920d9d074892dc96697
+ 
+5. Hopefully, you'll get an access token :
+
+ received access token :
+  $oauth_token : 471cd074f441556f70bc
+  $oauth_token_secret : 72a2fa4d05b5b9c47c3a
+
+6. You may now use this access token to access FusionForge scripts.
+
+
 -- OlivierBerger

Added: trunk/src/plugins/oauthprovider/example/command-line.php
===================================================================
--- trunk/src/plugins/oauthprovider/example/command-line.php	                        (rev 0)
+++ trunk/src/plugins/oauthprovider/example/command-line.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -0,0 +1,160 @@
+<?php
+
+require_once("OAuth.php");
+
+function usage($code=0) {
+	echo "php command-line.php [command] [args]\n";
+	echo "\n";
+	echo "where command in : request_token, ...\n";
+	echo "\n";
+	echo " request_token [consumer_key] [consumer_secret]\n";
+	echo "\n";
+	echo " authorize [request_token]\n";
+	echo "\n";
+	echo " access_token [consumer_key] [consumer_secret] [request_token] [request_token_secret]\n";
+	
+	exit($code);
+}
+
+if ($argc < 2) {
+	usage();
+}
+
+	
+function request_curl($url, $params=array()) {
+	$method='GET';
+        $params = http_build_query($params, '', '&');
+        $curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
+        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
+        curl_setopt($curl, CURLOPT_HEADER, false);
+        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+        curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
+
+        curl_setopt($curl, CURLOPT_HTTPGET, true);
+        
+        $response = curl_exec($curl);
+	return $response;
+}
+
+function retrieve_request_token($request_token_endpoint, $consumer_key, $consumer_secret) {
+	$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+	
+	$test_consumer = new OAuthConsumer($consumer_key, $consumer_secret);
+	
+	//print_r($test_consumer);
+
+	//$parsed = parse_url($endpoint);
+	$params = array();
+	//parse_str($parsed['query'], $params);
+	
+	$req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $request_token_endpoint, $params);
+	
+	//$rsa_method = new TestOAuthSignatureMethod_RSA_SHA1();
+	//$sig_method = $rsa_method;
+	$sig_method = $hmac_method;
+	
+	$req_req->sign_request($sig_method, $test_consumer, NULL);
+	
+	//print "request url: " . $req_req->to_url(). "\n";
+	//print_r($req_req);
+	
+	$response = request_curl($req_req->to_url());
+	
+	//print_r($response);
+	$params = array();
+	parse_str($response, $params);
+	//print_r($params);
+	
+	echo "received request token :\n";
+	echo ' $oauth_token : '. $params['oauth_token'] ."\n";
+	echo ' $oauth_token_secret : '. $params['oauth_token_secret'] ."\n";
+	echo "\n";
+	authorize_request_token(fusionforge_authorize_endpoint(), $params['oauth_token']);
+}
+
+function fusionforge_authorize_endpoint() {
+	return 'https://192.168.122.90/plugins/oauthprovider/authorize.php';
+}
+
+function authorize_request_token($authorize_endpoint, $oauth_token) {
+	echo "Go to the following URL in your FusionForge session to authorize the request token:\n";
+	echo ' '. $authorize_endpoint. '?oauth_token='. $oauth_token . "\n";
+	echo "\n";
+	echo "Upon completion, you will be able request access tokens with the authorized token.";
+	echo "\n";
+}
+
+
+function retrieve_access_token($access_token_endpoint, $consumer_key, $consumer_secret, $request_token, $token_secret) {
+
+	$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
+	
+	$test_consumer = new OAuthConsumer($consumer_key, $consumer_secret);
+	
+  	$test_token = new OAuthConsumer($request_token, $token_secret);
+
+	
+	//print_r($test_consumer);
+
+	//$parsed = parse_url($endpoint);
+	$params = array();
+	//parse_str($parsed['query'], $params);
+	
+	$acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, "GET", $access_token_endpoint, $params);
+	
+	//$rsa_method = new TestOAuthSignatureMethod_RSA_SHA1();
+	//$sig_method = $rsa_method;
+	$sig_method = $hmac_method;
+	
+	$acc_req->sign_request($sig_method, $test_consumer, $test_token);
+	
+	//print "request url: " . $req_req->to_url(). "\n";
+	//print_r($req_req);
+		
+	$response = request_curl($acc_req->to_url());
+	
+	//print_r($response)
+	
+	$params = array();
+	parse_str($response, $params);
+	//print_r($params);
+	
+	echo "received access token :\n";
+	echo ' $oauth_token : '. $params['oauth_token'] ."\n";
+	echo ' $oauth_token_secret : '. $params['oauth_token_secret'] ."\n";
+	echo "\n";
+	
+}
+
+
+switch ($argv[1]) {
+	case 'request_token':
+		if($argc < 4) usage(1);
+		$consumer_key = $argv[2];
+		$consumer_secret = $argv[3];
+		$request_token_endpoint = 'https://192.168.122.90/plugins/oauthprovider/request_token.php';
+		retrieve_request_token($request_token_endpoint, $consumer_key, $consumer_secret);
+		break;
+	case 'authorize':
+		if($argc < 3) usage(1);
+		$oauth_token = $argv[2];
+		$authorize_endpoint = fusionforge_authorize_endpoint();
+		authorize_request_token($authorize_endpoint, $oauth_token);
+		break;
+	case 'access_token':
+		if($argc < 6) usage(1);
+		$consumer_key = $argv[2];
+		$consumer_secret = $argv[3];
+		$request_token = $argv[4];
+		$token_secret = $argv[5];
+		$access_token_endpoint = 'https://192.168.122.90/plugins/oauthprovider/access_token.php';
+		retrieve_access_token($access_token_endpoint, $consumer_key, $consumer_secret, $request_token, $token_secret);
+		break;
+	default:
+		usage(1);
+}
+
+
+
+//
\ No newline at end of file

Modified: trunk/src/plugins/oauthprovider/include/oauthprovider_plugin.php
===================================================================
--- trunk/src/plugins/oauthprovider/include/oauthprovider_plugin.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/include/oauthprovider_plugin.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -36,7 +36,7 @@
 		$this->_addHook("userisactivecheckbox"); // The "use ..." checkbox in user account
 		$this->_addHook("userisactivecheckboxpost"); //
 		$this->_addHook("project_admin_plugins"); // to show up in the admin page fro group
-		$this->_addHook("manage_menu");
+		$this->_addHook("site_admin_option_hook");
 		$this->_addHook("account_menu");
 	}
 
@@ -45,9 +45,8 @@
 		if ($hookname == "usermenu") {
 			$text = $this->text; // this is what shows in the tab
 			if ($G_SESSION->usesPlugin("oauthprovider")) {
-				$param = '?type=user&id=' . $G_SESSION->getId(); // we indicate the part we're calling is the user one
-				echo ' | ' . $HTML->PrintSubMenu (array ($text),
-						  array ('/plugins/oauthprovider/index.php' . $param ));				
+				echo  $HTML->PrintSubMenu (array ($text),
+						  array ('/plugins/oauthprovider/index.php'), array(''));				
 			}
 		} elseif ($hookname == "groupmenu") {
 			$group_id=$params['group'];
@@ -133,7 +132,7 @@
 			//check if the user has the plugin activated
 			if ($user->usesPlugin($this->name)) {
 				echo '	<p>' ;
-				echo util_make_link ("/plugins/oauthprovider/index.php?id=$userid&type=user",
+				echo util_make_link ("/plugins/oauthprovider/index.php?type=user",
 						     _('View Personal oauthprovider')
 					);
 				echo '</p>';
@@ -147,8 +146,8 @@
 						     _('oauthprovider Admin')).'</p>' ;
 			}
 		}
-		elseif ($hookname == "manage_menu")	{
-			$this->manage_menu();
+		elseif ($hookname == "site_admin_option_hook")	{
+			$this->site_admin_option_hook();
 		}						
 		elseif ($hookname == "account_menu")	{
 			$this->account_menu();
@@ -158,8 +157,8 @@
 		} 
 	}
 	
-	function manage_menu( ) {
-		return array( '<a href="' . $gfplugins.'oauthprovider/www/manage.php' . '">' . $plugin_oauthprovider_menu_advanced_summary. '</a>', );
+	function site_admin_option_hook( ) {
+		echo '<li>'. util_make_link ('/plugins/oauthprovider/consumer.php', _('Manage OAuth consumers'). ' [' . _('OAuth provider plugin') . ']'). '</li>';
 	  }
 	
 	function account_menu( ) {

Modified: trunk/src/plugins/oauthprovider/www/access_tokens.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/access_tokens.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/access_tokens.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -46,16 +46,16 @@
 }
 
 $headers = array(
-	$plugin_oauthprovider_consumer_name,
-	$plugin_oauthprovider_key,
-	$plugin_oauthprovider_secret,
-	$plugin_oauthprovider_role,
-	$plugin_oauthprovider_user,
-	$plugin_oauthprovider_time_stamp,
+	_('Consumer name'),
+	_('Key'),
+	_('Secret'),
+	_('Role'),
+	_('User'),
+	_('Authorized on'),
 	'DELETE'
 	);
-echo $HTML->boxTop($plugin_oauthprovider_access_tokens);
-echo $HTML->boxBottom();
+echo $HTML->boxTop(_('Access Tokens'));
+
 echo $HTML->listTableTop($headers);
 
 $i = 0;
@@ -63,7 +63,7 @@
 	$consumer = OauthAuthzConsumer::load($t_token->getConsumerId());
 	echo '<tr '.$HTML->boxGetAltRowStyle($i).'>';
 	if($admin_access)	{
-		echo '<td>'.util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?type='.$type.'&id='.$id. '&consumer_id=' . $t_token->getConsumerId(),$consumer->getName()).'</td>';
+		echo '<td>'.util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_token->getConsumerId(), $consumer->getName()).'</td>';
 	}else {
 		echo '<td>'.$consumer->getName().'</td>';
 	}
@@ -86,11 +86,13 @@
 	}
 	echo '<td>'.$user.'</td>';
 	echo '<td>'.date(DATE_RFC822, $t_token->gettime_stamp()) .'</td>';
-	echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?type='.$type.'&id='.$id.'&token_id=' . $t_token->getId() . '&token_type=access' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), $plugin_oauthprovider_delete). '</td>';
+	echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?token_id=' . $t_token->getId() . '&token_type=access' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), _('Delete')). '</td>';
 	echo '</tr>';
 	$i++;
 }
 	
 echo $HTML->listTableBottom();
 
+echo $HTML->boxBottom();
+
 site_project_footer(array());
\ No newline at end of file

Modified: trunk/src/plugins/oauthprovider/www/authorize.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/authorize.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/authorize.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -38,13 +38,9 @@
 //non-admin users shud be able to do authorisations
 //session_require_global_perm('project_admin');
 
+$pluginname = 'oauthprovider';
 
-?>
 
-<h2><?php echo $plugin_oauthprovider_pending_authorizations ?></h2>
-
-<?php
-
 try {
 	
 	$req = OAuthRequest::from_request();
@@ -54,7 +50,11 @@
 	//  echo "token : $p_token";
 
 	$t_request_token = OauthAuthzRequestToken::load_by_key($p_token);
+
+	oauthprovider_CheckUser();
 	
+	echo '<h2>'. _('Pending authorization requests via OAuth') .'</h2>';
+	
 	if($type=="group") $groupname = $name;
 	else $groupname = null;
 	$group = group_get_object_by_name($groupname);
@@ -63,9 +63,24 @@
 	//echo "group: ".$groupid;
 	$user = user_get_object($user_id);
 	$roles = array () ;
-	foreach (RBACEngine::getInstance()->getAvailableRolesForUser ($user) as $role) {
-		if ($role->getHomeProject() && $role->getHomeProject()->getID() == $group->getID()) {
-			$roles[] = $role ;
+	
+	foreach (RBACEngine::getInstance()->getAvailableRolesForUser($user) as $role) {
+		//print_r('role :');
+		//print_r($role);
+		
+		if ($role->getHomeProject()) {
+			if($groupname) {
+				if ($role->getHomeProject()->getID() == $group->getID()) {
+					print_r('role :');
+					print_r($role);
+				}
+			}
+			else {
+				print_r('role :');
+				print_r($role);
+				$roles[] = $role ;
+			}
+			
 		}
 	}
 	
@@ -94,37 +109,37 @@
 		}
 	
 		// Now we can display the pending request token and point to the authorization confirmation dialog
-	echo sprintf( $plugin_oauthprovider_pending_authorization, $consumer->getName(), $date ) . ' ';
+	echo sprintf( _('Consumer <b>"%s"</b> wants to be authorized to access Fusionforge on your behalf (asked %s)'), $consumer->getName(), $date ) . ' ';
 	echo "<table><tr><td>";
 	if( isset($time_stamp) ) {
 		// the time_stamp is recent enough so we can allow authorization
 		//echo "<br />";
-		echo '<form action="token_authorize.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname.'" method="post">';
+		echo '<form action="token_authorize.php" method="post">';
 		echo '<input type="hidden" name="plugin_oauthprovider_token_authorize_token" value="'.form_generate_key().'"/>';
 		echo '<input type="hidden" name="token_id" value="'.$t_request_token->getId().'"/>';
 		echo '<input type="hidden" name="callback_url" value="'.urlencode($callback_url).'"/>';
 			
 		echo "<table><tr><td>Role:</td><td><select name=\"rolelist\">";
 		foreach($roles as $role)	{
-			echo '<option value="'.$role->getID().'">'.$role->getName().'</option>';
+			echo '<option value="'.$role->getID().'">'.$role->getDisplayableName().'</option>';
 		}
 		echo "</select></td>";
 		
-		echo '<td><input type="submit" value="'. $plugin_oauthprovider_authorize .'"/></td></tr></table>';
+		echo '<td><input type="submit" value="'. _('Authorize') .'"/></td></tr></table>';
 		echo '</form>';
 		
 	}
 	else {
 		// just display an inactive authorization link
-		print "<a href=\"\">". $plugin_oauthprovider_authorize ."</a>" ;
+		print "<a href=\"\">". _('Authorize') ."</a>" ;
 	}
 	echo '</td><td>';
 	// Denying it is always an option
-	echo '<form action="token_deny.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname.'" method="post">';
+	echo '<form action="token_deny.php" method="post">';
 	echo '<input type="hidden" name="plugin_oauthprovider_token_deny_token" value="'.form_generate_key().'"/>';
 	echo '<input type="hidden" name="token_id" value="'.$t_request_token->getId().'"/>';
 	echo "<table><tr><td><b>OR</b></td>";
-	echo '<td><input type="submit" value="'. $plugin_oauthprovider_deny .'"/></td></tr></table>';
+	echo '<td><input type="submit" value="'. _('Deny') .'"/></td></tr></table>';
 	echo '</form>';
 	echo '</td></tr></table>'
 	?>

Modified: trunk/src/plugins/oauthprovider/www/consumer_delete.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/consumer_delete.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/consumer_delete.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -37,7 +37,7 @@
 
 $t_consumer = OauthAuthzConsumer::load( $f_consumer_id );
 
-//helper_ensure_confirmed( sprintf( $plugin_oauthprovider_ensure_consumer_delete, $t_consumer->getName() ), $plugin_oauthprovider_delete_consumer );
+//helper_ensure_confirmed( sprintf( $plugin_oauthprovider_ensure_consumer_delete, $t_consumer->getName() ), _('Delete')_consumer );
 
 $t_consumer->delete();
 

Modified: trunk/src/plugins/oauthprovider/www/index.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/index.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/index.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -61,14 +61,14 @@
   <p>The <b>HMAC_SHA1</b> signature method is the only one supported at the moment.</p>
 
 <?php
-//global $plugin_oauthprovider_consumers, $plugin_oauthprovider_request_tokens;
+//global $plugin_oauthprovider_consumers, _('Request Tokens');
 # Create a basic href link to the manage.php plugin page
 if( forge_check_global_perm ('forge_admin') ){
 	echo util_make_link('/plugins/'.$pluginname.'/consumer.php', _('Consumers')). ' <br />';
 }
 
 
-echo '<a href="', '/plugins/'.$pluginname.'/request_tokens.php?type='.$type.'&id='.$id , '">', 'Request tokens', '</a><br> ';
+echo '<a href="', '/plugins/'.$pluginname.'/request_tokens.php?type='.$type , '">', _('Request tokens'), '</a><br> ';
 echo util_make_link('/plugins/'.$pluginname.'/access_tokens.php', _('Access tokens')).'<br /> ';
 
 //html_page_bottom();

Modified: trunk/src/plugins/oauthprovider/www/request_tokens.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/request_tokens.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/request_tokens.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -27,6 +27,8 @@
 
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
 /*if($type!=admin)
 {
 	exit_error("Only the Project Admin can access this page.", 'oauthprovider');
@@ -35,24 +37,25 @@
 if(forge_check_global_perm ('forge_admin'))	$admin_access=true;
 
 if($admin_access)	{
+	oauthprovider_CheckSiteAdmin();
 	$t_tokens = OauthAuthzRequestToken::load_all();
 }else {
+	oauthprovider_CheckUser();
 	$t_tokens = OauthAuthzRequestToken::load_all(user_getid());
 }
 
 $headers = array(
-	$plugin_oauthprovider_consumer_name,
-	$plugin_oauthprovider_key,
-	$plugin_oauthprovider_secret,
-	$plugin_oauthprovider_authorized,
-	$plugin_oauthprovider_role,
-	$plugin_oauthprovider_user,
-	$plugin_oauthprovider_time_stamp,
+	_('Consumer name'),
+	_('Key'),
+	_('Secret'),
+	_('Authorized'),
+	_('Role'),
+	_('User'),
+	_('Authorized on'),
 	'DELETE'
 	);
 
-echo $HTML->boxTop($plugin_oauthprovider_request_tokens);
-echo $HTML->boxBottom();
+echo $HTML->boxTop(_('Request Tokens'));
 echo $HTML->listTableTop($headers);
 
 $i=0;
@@ -60,7 +63,7 @@
 	$consumer = OauthAuthzConsumer::load($t_token->getConsumerId());
 	echo '<tr '.$HTML->boxGetAltRowStyle($i).'>';
 	if($admin_access)	{
-		echo '<td>'.util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname.'&token_id=' . $t_token->getConsumerId(), $consumer->getName()).'</td>';
+		echo '<td>'.util_make_link('/plugins/'.$pluginname.'/consumer_manage.php?consumer_id=' . $t_token->getConsumerId(), $consumer->getName()).'</td>';
 	}else {
 		echo '<td>'.$consumer->getName().'</td>';
 	}
@@ -86,13 +89,14 @@
 	}
 	echo '<td>'.$user.'</td>';
 	echo '<td>'.date(DATE_RFC822, $t_token->gettime_stamp()) .'</td>';
-	echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname.'&token_id=' . $t_token->getId() . '&token_type=request' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), $plugin_oauthprovider_delete).'</td>';
+	echo '<td>'.util_make_link('/plugins/'.$pluginname.'/token_delete.php?token_id=' . $t_token->getId() . '&token_type=request' . '&plugin_oauthprovider_token_delete_token='.form_generate_key(), _('Delete')).'</td>';
 	echo '</tr>';
 	$i++;
 	
 }
 
 echo $HTML->listTableBottom();
+echo $HTML->boxBottom();
 
 //html_page_bottom1( __FILE__ );
 site_project_footer(array());
\ No newline at end of file

Modified: trunk/src/plugins/oauthprovider/www/token_authorize.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/token_authorize.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/token_authorize.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -36,8 +36,9 @@
 	$f_callback_url = urldecode(getStringFromPost( 'callback_url' ));
 	$f_role_id = getStringFromPost( 'rolelist' );
 
-	//  echo "token_id : $f_token_id \n";
-	//  echo "callback_url: $f_callback_url \n";
+	//echo "token_id : $f_token_id \n";
+	//echo "callback_url: $f_callback_url \n";
+	//exit(0);
 	$t_token = OauthAuthzRequestToken::load( $f_token_id );
 
 	if($t_token) {
@@ -56,9 +57,14 @@
 
 		form_release_key(getStringFromRequest('plugin_oauthprovider_token_authorize_token'));
 		
+		if($f_callback_url) {
 		//echo "Redirect : $callback_url?oauth_token=$p_token \n";exit;
 		Header("Location: $f_callback_url?oauth_token=$p_token");
 		//session_redirect( $f_callback_url . "?oauthprovider_token=$p_token" );
+		}
+		else {
+			echo "Succesfully authorized oauth_token:". $p_token ."\n";
+		}
 	}
 
 } catch (OAuthException $e) {

Modified: trunk/src/plugins/oauthprovider/www/token_delete.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/token_delete.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/token_delete.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -26,6 +26,7 @@
 require_once $gfwww.'include/pre.php';
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
 
 form_key_is_valid(getStringFromRequest('plugin_oauthprovider_token_delete_token'));
 
@@ -42,10 +43,10 @@
 	$t_token = OauthAuthzRequestToken::load( $f_token_id );
 }
 
-//helper_ensure_confirmed( sprintf( $plugin_oauthprovider_ensure_token_delete, $t_token->key ), $plugin_oauthprovider_delete_token );
+//helper_ensure_confirmed( sprintf( $plugin_oauthprovider_ensure_token_delete, $t_token->key ), _('Delete')_token );
 //equivalent for fusionforge not found yet
 
 $t_token->delete();
 
 form_release_key(getStringFromRequest('plugin_oauthprovider_token_delete_token'));
-session_redirect( '/plugins/'.$pluginname.'/'. $f_type.'_tokens.php?type='.$type.'&id='.$id.'&pluginname='.$pluginname);
+session_redirect( '/plugins/'.$pluginname.'/'. $f_type.'_tokens.php');

Modified: trunk/src/plugins/oauthprovider/www/token_deny.php
===================================================================
--- trunk/src/plugins/oauthprovider/www/token_deny.php	2011-03-25 18:47:42 UTC (rev 12920)
+++ trunk/src/plugins/oauthprovider/www/token_deny.php	2011-03-25 18:47:52 UTC (rev 12921)
@@ -28,6 +28,8 @@
 
 require_once 'checks.php';	
 
+$pluginname = 'oauthprovider';
+
 // deletes a request token if the users refuses to authorize it for a consumer
 form_key_is_valid(getStringFromRequest('plugin_oauthprovider_token_deny_token'));
 
@@ -47,11 +49,13 @@
 
     $t_token->delete();
     
+    oauthprovider_CheckUser();
+    
     ?>
 
-<h2><?php echo $plugin_oauthprovider_authorization_denied ?></h2>
+<h2><?php echo _('Authorization Denied') ?></h2>
 
-<p><?php echo sprintf( $plugin_oauthprovider_denied_consumer_authorization, $consumer->getName() )?></p>
+<p><?php echo sprintf( _('You have denied Consumer "%s" access to Fusionforge on your behalf. The pending OAuth token request has been deleted.'), $consumer->getName() )?></p>
 
 <?php
 
@@ -65,3 +69,7 @@
 	exit_error( "Error trying to deny/delete token!", 'oauthprovider' );
 	
 }
+
+site_project_footer(array());
+
+?>




More information about the Fusionforge-commits mailing list