TsgcWebSocketFirewallMethods › RegisterFailedAttempt

RegisterFailedAttempt Method

Application-level hook that records a failed authentication attempt from the given IP, feeding the BruteForce tracker and potentially triggering an automatic ban.

Syntax

procedure RegisterFailedAttempt(const aIP: string);

Parameters

NameTypeDescription
aIPconst stringIPv4 or IPv6 address of the client whose authentication or protocol-level handshake just failed.

Remarks

BruteForce can only track what the application reports. Call RegisterFailedAttempt from any OnAuthentication, OnConnectAuth, JWT-validation or API-key handler when the credentials are rejected. Once MaxAttempts accumulate within BruteForce.TimeWindowSec the IP is automatically banned for BanDurationSec (extended by BanEscalation when enabled). The call also contributes to the threat score via the configured weight.

Example

procedure TForm1.ServerAuthentication(Connection: TsgcWSConnection;
  aUser, aPassword: string; var Authenticated: Boolean);
begin
  Authenticated := (aUser = 'admin') and (aPassword = 'secret');
  if not Authenticated then
    sgcWebSocketFirewall1.RegisterFailedAttempt(Connection.IP);
end;

Back to Methods