adasd
All checks were successful
Deploy / deploy (push) Successful in 46s

This commit is contained in:
2026-07-17 00:19:05 +02:00
parent dca3ce93e6
commit 429258156a
4 changed files with 117 additions and 110 deletions

View File

@@ -12,9 +12,14 @@ $isRetoolPath = ($uriPath === 'retool' || str_starts_with($uriPath, 'retool/'));
if (defined('APP_ENV') && APP_ENV === 'staging' && !$isRetoolPath) {
$authUser = getenv('STAGING_AUTH_USER') ?: 'staging';
$authPass = getenv('STAGING_AUTH_PASS') ?: 'staging123';
$remoteUser = $_SERVER['REMOTE_USER'] ?? null;
$user = $_SERVER['PHP_AUTH_USER'] ?? null;
$pass = $_SERVER['PHP_AUTH_PW'] ?? null;
if ($user !== $authUser || $pass !== $authPass) {
// If Apache already authenticated the request via .htaccess, trust that layer.
$hasUpstreamBasicAuth = is_string($remoteUser) && $remoteUser !== '';
if (!$hasUpstreamBasicAuth && ($user !== $authUser || $pass !== $authPass)) {
header('WWW-Authenticate: Basic realm="Staging"');
header('HTTP/1.0 401 Unauthorized');
echo 'Unauthorized';