feat: o login reporta falhas à frota (activo no próximo refresh do platform-tools)
O login desta plataforma é próprio, por isso é daqui que o hub fica a saber dos logins falhados e dos bloqueios do throttle. A cópia vendorizada do platform-tools (ea3616a, ver VENDORED.md) ainda não traz functions_security_events.php, e até lá isto não faz nada. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7097ccbe0b
commit
8a494d59a5
1 file changed
+14
@@ -19,6 +19,18 @@ if (!empty($_SESSION['user_id'])) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// O login é deste site, não o partilhado, por isso é daqui que a frota fica a
|
||||||
|
// saber das falhas (platform-tools/functions_security_events.php). A cópia
|
||||||
|
// vendorizada ainda não traz esse ficheiro (ver VENDORED.md); até ao próximo
|
||||||
|
// refresh isto não faz nada.
|
||||||
|
$report_login = function (string $kind) use ($pdo): void {
|
||||||
|
$f = dirname(__DIR__, 2) . '/shared/platform-tools/functions_security_events.php';
|
||||||
|
if (!is_file($f)) return;
|
||||||
|
require_once $f;
|
||||||
|
platform_security_event($pdo, $kind, hub_security_mask_identifier((string) ($_POST['email'] ?? '')));
|
||||||
|
hub_security_maybe_sync($pdo);
|
||||||
|
};
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
csrf_check();
|
csrf_check();
|
||||||
@@ -26,6 +38,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
// Counts successes too, so a guessed password can't be parlayed into
|
// Counts successes too, so a guessed password can't be parlayed into
|
||||||
// stuffing the rest of the user list from the same IP.
|
// stuffing the rest of the user list from the same IP.
|
||||||
if (!throttle_check($pdo, 'login')) {
|
if (!throttle_check($pdo, 'login')) {
|
||||||
|
$report_login('login_throttled');
|
||||||
throttle_block('login form');
|
throttle_block('login form');
|
||||||
}
|
}
|
||||||
throttle_record($pdo, 'login');
|
throttle_record($pdo, 'login');
|
||||||
@@ -36,6 +49,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
header('Location: ' . base_url($destination($user['role'])));
|
header('Location: ' . base_url($destination($user['role'])));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
$report_login('login_failed');
|
||||||
// Deliberately vague — doesn't reveal whether the address exists.
|
// Deliberately vague — doesn't reveal whether the address exists.
|
||||||
$error = 'Email ou palavra-passe incorretos.';
|
$error = 'Email ou palavra-passe incorretos.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user