aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2014-10-08 21:24:35 +0200
committerChristian Weiske <cweiske@cweiske.de>2014-10-08 21:24:35 +0200
commitdab31d3882a398d5f459a0aca71b2e35ab641708 (patch)
tree2b74a0a3a9296d98b6dbe3a0c49954e6b55ac5e6
parent9b69209d884a6d01e890ec3360cb88fe7cf64f6a (diff)
downloadgrauphel-dab31d3882a398d5f459a0aca71b2e35ab641708.tar.gz
grauphel-dab31d3882a398d5f459a0aca71b2e35ab641708.zip
Fix bug #10: OAuth does not work on ovh.com server
This ovh.com server always has $_SERVER['HTTP_AUTHORIZATION'] set. By default it has an empty string as value, and this breaks the PHP OAuth extension - see https://bugs.php.net/bug.php?id=68168 We work around that by forcing the signature method in this special case, so that no exception is thrown. Thanks to Julien Daviaud for giving me access to his server for debugging.
-rw-r--r--lib/oauth.php19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/oauth.php b/lib/oauth.php
index 9fea742..4a652fc 100644
--- a/lib/oauth.php
+++ b/lib/oauth.php
@@ -158,23 +158,18 @@ class OAuth
*/
public static function getProvider()
{
+ $params = array();
//$_SERVER['REDIRECT_HTTP_AUTHORIZATION'] = $_SERVER['HTTP_AUTHORIZATION'];
- //unset($_SERVER['HTTP_AUTHORIZATION']);
- if ((isset($_SERVER['HTTP_AUTHORIZATION'])
- && strlen($_SERVER['HTTP_AUTHORIZATION'])
- && strtolower(substr($_SERVER['HTTP_AUTHORIZATION'], 0, 5)) != 'oauth')
- || (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])
- && strlen($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])
- && strtolower(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 0, 5)) != 'oauth')
+
+ if (isset($_SERVER['HTTP_AUTHORIZATION'])
+ && $_SERVER['HTTP_AUTHORIZATION'] == ''
) {
//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
- );
+ //#68168: HTTP Basic auth and empty auth header reported
+ // as "signature_method_rejected"
+ $params['oauth_signature_method'] = OAUTH_SIG_METHOD_PLAINTEXT;
}
- $params = array();
if (!isset($_SERVER['HTTP_AUTHORIZATION'])
&& isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])
) {