Skip to content

IPBanManager

The IPBanManager class handles temporary IP bans.


Methods

def ban_ip(ip: str, duration: int) -> None: """Ban an IP address for a specified duration."""

def is_ip_banned(ip: str) -> bool: """Check if an IP address is currently banned."""

def reset() -> None: """Reset all banned IPs."""

Usage with DjangoAPIGuard

# settings.py
GUARD_SECURITY_CONFIG = SecurityConfig(
    auto_ban_threshold=5,
    auto_ban_duration=3600
)