ZP-765 Moved the content of AuthenticationInfo into the initialize section of...

ZP-765 Moved the content of AuthenticationInfo into the initialize section of the Request static class. Released under the Affero GNU General Public License (AGPL) version 3.
parent 56aeae90
...@@ -167,7 +167,7 @@ include_once('version.php'); ...@@ -167,7 +167,7 @@ include_once('version.php');
$backend = ZPush::GetBackend(); $backend = ZPush::GetBackend();
// always request the authorization header // always request the authorization header
if (! Request::AuthenticationInfo() || !Request::GetGETUser()) if (! Request::HasAuthenticationInfo() || !Request::GetGETUser())
throw new AuthenticationRequiredException("Access denied. Please send authorisation information"); throw new AuthenticationRequiredException("Access denied. Please send authorisation information");
// check the provisioning information // check the provisioning information
......
...@@ -186,6 +186,16 @@ class Request { ...@@ -186,6 +186,16 @@ class Request {
self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser); self::$getUser = Utils::GetLocalPartFromEmail(self::$getUser);
} }
} }
// authUser & authPassword are unfiltered!
// split username & domain if received as one
if (isset($_SERVER['PHP_AUTH_USER'])) {
list(self::$authUser, self::$authDomain) = Utils::SplitDomainUser($_SERVER['PHP_AUTH_USER']);
self::$authPassword = (isset($_SERVER['PHP_AUTH_PW']))?$_SERVER['PHP_AUTH_PW'] : "";
}
if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
self::$authUser = Utils::GetLocalPartFromEmail(self::$authUser);
}
} }
/** /**
...@@ -234,21 +244,10 @@ class Request { ...@@ -234,21 +244,10 @@ class Request {
} }
/** /**
* Reads and parses the HTTP-Basic-Auth data
*
* @access public * @access public
* @return boolean data sent or not * @return boolean data sent or not
*/ */
static public function AuthenticationInfo() { static public function HasAuthenticationInfo() {
// split username & domain if received as one
if (isset($_SERVER['PHP_AUTH_USER'])) {
list(self::$authUser, self::$authDomain) = Utils::SplitDomainUser($_SERVER['PHP_AUTH_USER']);
self::$authPassword = (isset($_SERVER['PHP_AUTH_PW']))?$_SERVER['PHP_AUTH_PW'] : "";
}
if(defined('USE_FULLEMAIL_FOR_LOGIN') && ! USE_FULLEMAIL_FOR_LOGIN) {
self::$authUser = Utils::GetLocalPartFromEmail(self::$authUser);
}
// authUser & authPassword are unfiltered!
return (self::$authUser != "" && self::$authPassword != ""); return (self::$authUser != "" && self::$authPassword != "");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment