Try to fix issue #10; work around bug https://bugs.php.net/bug.php?id=68168
authorChristian Weiske <cweiske@cweiske.de>
Mon, 6 Oct 2014 21:38:47 +0000 (23:38 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 6 Oct 2014 21:38:47 +0000 (23:38 +0200)
lib/oauth.php

index 231a177..41af349 100644 (file)
@@ -160,6 +160,17 @@ class OAuth
     {
         //$_SERVER['REDIRECT_HTTP_AUTHORIZATION'] = $_SERVER['HTTP_AUTHORIZATION'];
         //unset($_SERVER['HTTP_AUTHORIZATION']);
+        if ((isset($_SERVER['HTTP_AUTHORIZATION'])
+                && strtolower(substr($_SERVER['HTTP_AUTHORIZATION'], 0, 5)) != 'oauth')
+            || (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])
+                && strtolower(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 0, 5)) != 'oauth')
+        ) {
+            //work around bug https://bugs.php.net/bug.php?id=68168
+            //#68168: HTTP Basic auth reported as "signature_method_rejected"
+            throw new \OAuthException(
+                'No oauth auth header', OAUTH_PARAMETER_ABSENT
+            );
+        }
 
         $params = array();
         if (!isset($_SERVER['HTTP_AUTHORIZATION'])