From 46fd3ad561c27991cec37abf7a1c1a6d4b36c447 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 13 May 2010 08:49:32 +0000 Subject: [PATCH] "Support for basic auth when using PHP CGI" --- phpgwapi/inc/class.egw_digest_auth.inc.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/phpgwapi/inc/class.egw_digest_auth.inc.php b/phpgwapi/inc/class.egw_digest_auth.inc.php index 0dd21f1f08..fe811e0f12 100644 --- a/phpgwapi/inc/class.egw_digest_auth.inc.php +++ b/phpgwapi/inc/class.egw_digest_auth.inc.php @@ -61,6 +61,15 @@ class egw_digest_auth $realm = $GLOBALS['egw_info']['flags']['auth_realm']; if (empty($realm)) $realm = 'EGroupware'; + // Support for basic auth when using PHP CGI (what about digest auth?) + if (!isset($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['Authorization']) && strpos($_SERVER['Authorization'],'Basic ') === 0) + { + $hash = base64_decode(substr($_SERVER['Authorization'],6)); + if (strpos($hash, ':') !== false) + { + list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', $hash, 2); + } + } if (!isset($_SERVER['PHP_AUTH_USER']) && !isset($_SERVER['PHP_AUTH_DIGEST']) || isset($_SERVER['PHP_AUTH_DIGEST']) && (!self::is_valid($realm,$_SERVER['PHP_AUTH_DIGEST'],$username,$password) || !($sessionid = $GLOBALS['egw']->session->create($username,$password,'text'))) ||