public function getTransparentAuthenticationCredentials()
{
$return = null;
// Make sure there are enabled transparent authentication methods
if (empty($this->authenticationMethods)) {
return $return;
}
$input = $this->container->input;
foreach ($this->authenticationMethods as $method) {
switch ($method) {
case self::Auth_HTTPBasicAuth_TOTP:
if (empty($this->totpKey)) {
continue;
}
if (empty($this->basicAuthUsername)) {
continue;
}
if (!isset($_SERVER['PHP_AUTH_USER'])) {
continue;
}
if (!isset($_SERVER['PHP_AUTH_PW'])) {
continue;
}
if ($_SERVER['PHP_AUTH_USER'] != $this->basicAuthUsername) {
continue;
}
$encryptedData = $_SERVER['PHP_AUTH_PW'];
return $this->decryptWithTOTP($encryptedData);
break;
case self::Auth_QueryString_TOTP:
if (empty($this->queryParam)) {
continue;
}
$encryptedData = $input->get($this->queryParam, '', 'raw');
if (empty($encryptedData)) {
continue;
}
$return = $this->decryptWithTOTP($encryptedData);
if (!is_null($return)) {
return $return;
}
break;
case self::Auth_HTTPBasicAuth_Plaintext:
if (!isset($_SERVER['PHP_AUTH_USER'])) {
continue;
}
if (!isset($_SERVER['PHP_AUTH_PW'])) {
continue;
}
return array('username' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']);
break;
case self::Auth_QueryString_Plaintext:
if (empty($this->queryParam)) {
continue;
}
$jsonEncoded = $input->get($this->queryParam, '', 'raw');
if (empty($jsonEncoded)) {
continue;
}
$authInfo = json_decode($jsonEncoded, true);
if (!is_array($authInfo)) {
continue;
}
if (!array_key_exists('username', $authInfo) || !array_key_exists('password', $authInfo)) {
continue;
}
return $authInfo;
break;
case self::Auth_SplitQueryString_Plaintext:
if (empty($this->queryParamUsername)) {
continue;
}
if (empty($this->queryParamPassword)) {
continue;
}
$username = $input->get($this->queryParamUsername, '', 'raw');
$password = $input->get($this->queryParamPassword, '', 'raw');
if (empty($username)) {
continue;
}
if (empty($password)) {
continue;
}
return array('username' => $username, 'password' => $password);
break;
}
}
return $return;
}