[Fusionforge-commits] r12942 - trunk/src/plugins/oauthprovider/3rd-party/oauth-php

Olivier Berger olberger at fusionforge.org
Tue Mar 29 08:51:53 CEST 2011


Author: olberger
Date: 2011-03-29 08:51:53 +0200 (Tue, 29 Mar 2011)
New Revision: 12942

Modified:
   trunk/src/plugins/oauthprovider/3rd-party/oauth-php/OAuth.php
Log:
Add 400 or 401 return codes to exceptions

Apply patch submitted upstream at http://code.google.com/p/oauth/issues/detail?id=48#c4

Modified: trunk/src/plugins/oauthprovider/3rd-party/oauth-php/OAuth.php
===================================================================
--- trunk/src/plugins/oauthprovider/3rd-party/oauth-php/OAuth.php	2011-03-29 06:51:45 UTC (rev 12941)
+++ trunk/src/plugins/oauthprovider/3rd-party/oauth-php/OAuth.php	2011-03-29 06:51:53 UTC (rev 12942)
@@ -534,7 +534,7 @@
       $version = 1.0;
     }
     if ($version && $version != $this->version) {
-      throw new OAuthException("OAuth version '$version' not supported");
+      throw new OAuthException("OAuth version '$version' not supported", 400);
     }
     return $version;
   }/*}}}*/
@@ -551,7 +551,7 @@
     if (!in_array($signature_method, 
                   array_keys($this->signature_methods))) {
       throw new OAuthException(
-        "Signature method '$signature_method' not supported try one of the following: " . implode(", ", array_keys($this->signature_methods))
+        "Signature method '$signature_method' not supported try one of the following: " . implode(", ", array_keys($this->signature_methods)), 400
       );      
     }
     return $this->signature_methods[$signature_method];
@@ -563,12 +563,12 @@
   private function get_consumer(&$request) {/*{{{*/
     $consumer_key = @$request->get_parameter("oauth_consumer_key");
     if (!$consumer_key) {
-      throw new OAuthException("Invalid consumer key");
+      throw new OAuthException("Invalid consumer key", 400);
     }
 
     $consumer = $this->data_store->lookup_consumer($consumer_key);
     if (!$consumer) {
-      throw new OAuthException("Invalid consumer");
+      throw new OAuthException("Invalid consumer", 401);
     }
 
     return $consumer;
@@ -583,7 +583,7 @@
       $consumer, $token_type, $token_field
     );
     if (!$token) {
-      throw new OAuthException("Invalid $token_type token: $token_field");
+      throw new OAuthException("Invalid $token_type token: $token_field", 401);
     }
     return $token;
   }/*}}}*/
@@ -611,7 +611,7 @@
     );
 
     if (!$valid_sig) {
-      throw new OAuthException("Invalid signature");
+      throw new OAuthException("Invalid signature", 401);
     }
   }/*}}}*/
 
@@ -622,7 +622,7 @@
     // verify that timestamp is recentish
     $now = time();
     if ($now - $timestamp > $this->timestamp_threshold) {
-      throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
+      throw new OAuthException("Expired timestamp, yours $timestamp, ours $now", 401);
     }
   }/*}}}*/
 
@@ -633,7 +633,7 @@
     // verify that the nonce is uniqueish
     $found = $this->data_store->lookup_nonce($consumer, $token, $nonce, $timestamp);
     if ($found) {
-      throw new OAuthException("Nonce already used: $nonce");
+      throw new OAuthException("Nonce already used: $nonce", 401);
     }
   }/*}}}*/
 
@@ -719,7 +719,7 @@
     $secret = time() + time();
     $token = new OAuthToken($key, md5(md5($secret)));
     if (!dba_insert("${type}_$key", serialize($token), $this->dbh)) {
-      throw new OAuthException("doooom!");
+      throw new OAuthException("doooom!", 400);
     }
     return $token;
   }/*}}}*/




More information about the Fusionforge-commits mailing list