use BasicAuth in encrypted folder. fix: error_log in SCF

This commit is contained in:
root
2021-01-16 17:12:03 +08:00
parent 5e49a44ec1
commit 34599a6e71
13 changed files with 133 additions and 93 deletions
+27
View File
@@ -28,6 +28,11 @@ function GetGlobalVariable($event)
$pos = strpos($cookievalues,"=");
$_COOKIE[urldecode(substr($cookievalues,0,$pos))]=urldecode(substr($cookievalues,$pos+1));
}
if (isset($event['headers']['Authorization'])) {
$basicAuth = splitfirst(base64_decode(splitfirst($event['headers']['Authorization'][0], 'Basic ')[1]), ':');
$_SERVER['PHP_AUTH_USER'] = $basicAuth[0];
$_SERVER['PHP_AUTH_PW'] = $basicAuth[1];
}
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
}
@@ -454,3 +459,25 @@ function addFileToZip($zip, $rootpath, $path = '')
}
@closedir($path);
}
function myErrorHandler($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & $errno)) {
return false;
}
switch ($errno) {
case E_USER_ERROR:
$errInfo = array(
"errorMessage" => $errstr,
"errorType" => \ServerlessFC\friendly_error_type($errno),
"stackTrace" => array(
"file" => $errfile,
"line" => $errline,
),
);
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
break;
default: // E_USER_WARNING | E_USER_NOTICE
break;
}
return true;
}