From 8f669880bc86c71388b20471c3b96bd86ae14fa7 Mon Sep 17 00:00:00 2001 From: Stefan Seidel Date: Fri, 9 Nov 2012 13:30:07 +0100 Subject: [PATCH] Fix WebDAV (and Android Client) not being able to authorize on Debian Squeeze + mod_fcgid installs. --- .htaccess | 8 ++++++++ lib/base.php | 4 ++++ lib/setup.php | 10 +++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.htaccess b/.htaccess index a5d51c78087..2d7b7dcc364 100755 --- a/.htaccess +++ b/.htaccess @@ -1,3 +1,11 @@ + + + +SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1 +RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION + + + ErrorDocument 403 /core/templates/403.php ErrorDocument 404 /core/templates/404.php diff --git a/lib/base.php b/lib/base.php index d4eeac82daa..bed50c904c7 100644 --- a/lib/base.php +++ b/lib/base.php @@ -356,6 +356,10 @@ class OC{ //try to set the session lifetime to 60min @ini_set('gc_maxlifetime', '3600'); + //copy http auth headers for apache+php-fcgid work around + if (isset($_SERVER['HTTP_XAUTHORIZATION']) && !isset($_SERVER['HTTP_AUTHORIZATION'])) { + $_SERVER['HTTP_AUTHORIZATION'] = $_SERVER['HTTP_XAUTHORIZATION']; + } //set http auth headers for apache+php-cgi work around if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) { diff --git a/lib/setup.php b/lib/setup.php index 726b3352d50..013ae2f6efc 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -573,7 +573,15 @@ class OC_Setup { * create .htaccess files for apache hosts */ private static function createHtaccess() { - $content = "ErrorDocument 403 ".OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page + $content = "\n"; + $content.= "\n"; + $content.= "\n"; + $content.= "SetEnvIfNoCase ^Authorization$ \"(.+)\" XAUTHORIZATION=$1\n"; + $content.= "RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION\n"; + $content.= "\n"; + $content.= "\n"; + $content.= "\n"; + $content.= "ErrorDocument 403 ".OC::$WEBROOT."/core/templates/403.php\n";//custom 403 error page $content.= "ErrorDocument 404 ".OC::$WEBROOT."/core/templates/404.php\n";//custom 404 error page $content.= "\n"; $content.= "php_value upload_max_filesize 512M\n";//upload limit -- 2.39.5