Update: 2026-05-15 04:16:32
This commit is contained in:
@@ -39,6 +39,29 @@ if (!$envLoaded) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Security: API Key Validation
|
||||
$expectedApiKey = $_ENV['API_KEY'] ?? 'JORDAN_BOT_SECRET_2026'; // Fallback if not in .env
|
||||
$headers = getallheaders();
|
||||
$providedKey = $headers['X-API-Key'] ?? ($headers['x-api-key'] ?? null);
|
||||
|
||||
if ($providedKey !== $expectedApiKey) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['success' => false, 'message' => 'Unauthorized: Invalid or missing API Key']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Extra Security: App Signature Fingerprint Validation (Optional)
|
||||
$expectedAppSignature = $_ENV['APP_SIGNATURE_SHA256'] ?? null;
|
||||
if (!empty($expectedAppSignature)) {
|
||||
$providedSignature = $headers['X-App-Signature'] ?? ($headers['x-app-signature'] ?? null);
|
||||
// Ignore case and compare
|
||||
if (strcasecmp($providedSignature, $expectedAppSignature) !== 0) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['success' => false, 'message' => 'Forbidden: Invalid App Signature (Anti-Tamper)']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$host = $_ENV['DB_HOST'] ?? 'localhost';
|
||||
$dbname = $_ENV['DB_NAME'] ?? 'jordan_bot_db';
|
||||
$username = $_ENV['DB_USER'] ?? 'root';
|
||||
|
||||
Reference in New Issue
Block a user