Harden for public launch: rate limiting, CORS, error display, Gitea webhook sig
- User::login() locks an account for 15 min after 5 failed attempts - CORS now restricted to an explicit origin whitelist instead of * - display_errors disabled in production (errors still logged server-side) - webhook.php now checks Gitea's actual signature header (X-Gitea-Signature, raw hex) instead of GitHub's format, which never matched on this Gitea instance Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
<?php
|
||||
// index.php
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
// En prod on ne balance plus les erreurs PHP au visiteur (fuite d'infos internes) ;
|
||||
// elles restent loguées côté serveur via error_log.
|
||||
ini_set('display_errors', 0);
|
||||
ini_set('display_startup_errors', 0);
|
||||
ini_set('log_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// --- HEADERS CORS (Indispensables pour ton site et ton appli mobile) ---
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
// --- HEADERS CORS ---
|
||||
// Les apps mobiles natives ne sont pas concernées par CORS (c'est une restriction de navigateur),
|
||||
// donc restreindre ici n'affecte que les navigateurs web.
|
||||
$allowed_origins = [
|
||||
'https://watchgether.whykioh.fr',
|
||||
'null', // ouverture du HTML en double-clic (file://) pendant le dev local
|
||||
];
|
||||
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
||||
if (in_array($origin, $allowed_origins, true)) {
|
||||
header("Access-Control-Allow-Origin: $origin");
|
||||
}
|
||||
header("Content-Type: application/json; charset=UTF-8");
|
||||
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
|
||||
|
||||
Reference in New Issue
Block a user