From 1a5b5084701b966098cf070cba6dbacd195b3424 Mon Sep 17 00:00:00 2001 From: Filipe Saraiva Date: Fri, 16 Jan 2015 10:28:10 +0100 Subject: [PATCH] Hacking to enable HTTP auth with PHP-CGI + Apache suExec. The hacking was proposed by Matthias Blaicher (http://ur1.ca/jfz9v) to access owncloud in Webfaction servers. More informations in Webfaction community support http://ur1.ca/jg37x. --- .htaccess | 3 +++ lib/base.php | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/.htaccess b/.htaccess index af7e961379c1..862fee8da794 100644 --- a/.htaccess +++ b/.htaccess @@ -28,6 +28,9 @@ RewriteRule ^apps/contacts/carddav\.php remote.php/carddav/ [QSA,L] RewriteRule ^remote/(.*) remote.php [QSA,L] RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L] RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L] +RewriteCond %{HTTP:Authorization} ^Basic.* +RewriteRule ^(.*) $1?Authorization=%{HTTP:Authorization} [QSA,C] +RequestHeader unset Authorization AddType image/svg+xml svg svgz diff --git a/lib/base.php b/lib/base.php index dbfe0eb2f278..ad1e2f481344 100644 --- a/lib/base.php +++ b/lib/base.php @@ -841,6 +841,13 @@ protected static function handleAuthHeaders() { break; } } + + // Set HTTP auth headers for HTTP Authentication with PHP-CGI + if(isset($_GET['Authorization']) && preg_match('/Basic\s+(.*)$/i', $_GET['Authorization'], $matches)) { + list($name, $password) = explode(':', base64_decode($matches[1])); + $_SERVER['PHP_AUTH_USER'] = strip_tags($name); + $_SERVER['PHP_AUTH_PW'] = strip_tags($password); + } } protected static function handleLogin() {