Update: 2026-05-15 13:49:20
This commit is contained in:
@@ -51,11 +51,18 @@ if ($providedKey !== $expectedApiKey) {
|
||||
}
|
||||
|
||||
// Extra Security: App Signature Fingerprint Validation (Optional)
|
||||
$expectedAppSignature = $_ENV['APP_SIGNATURE_SHA256'] ?? null;
|
||||
if (!empty($expectedAppSignature)) {
|
||||
$expectedSignatures = $_ENV['APP_SIGNATURE_SHA256'] ?? null;
|
||||
if (!empty($expectedSignatures)) {
|
||||
$providedSignature = $headers['X-App-Signature'] ?? ($headers['x-app-signature'] ?? null);
|
||||
// Ignore case and compare
|
||||
if (strcasecmp($providedSignature, $expectedAppSignature) !== 0) {
|
||||
$validSignatures = explode(',', $expectedSignatures);
|
||||
$isValid = false;
|
||||
foreach ($validSignatures as $sig) {
|
||||
if (strcasecmp(trim($sig), trim($providedSignature)) === 0) {
|
||||
$isValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
http_response_code(403);
|
||||
echo json_encode(['success' => false, 'message' => 'Forbidden: Invalid App Signature (Anti-Tamper)']);
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user