Documentation
¶
Index ¶
- type AttackerStats
- type ListBasedProtectionService
- func (service *ListBasedProtectionService) BlockDevice(deviceId string)
- func (service *ListBasedProtectionService) BlockIpAddress(ipAddress string)
- func (service *ListBasedProtectionService) GetWatchingAttackersCount() int
- func (service *ListBasedProtectionService) IsDeviceBlocked(deviceId string) bool
- func (service *ListBasedProtectionService) IsIpAddressBlocked(ipAddress string) bool
- func (service *ListBasedProtectionService) RegisterDeviceAttempt(deviceId string) bool
- func (service *ListBasedProtectionService) RegisterIpAddressAttempt(ipAddress string) bool
- func (service *ListBasedProtectionService) UnblockDevice(deviceId string)
- func (service *ListBasedProtectionService) UnblockIpAddress(ipAddress string)
- type ProtectionService
- type ProtectionServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttackerStats ¶
type AttackerStats struct {
// contains filtered or unexported fields
}
AttackerStats is a public exporting type that is representing for the attackers statistics
Attackers (all people and robots that were entered invalid credentials) are analyzing in * background where it could be made one of the following decision * 1. attacker is not an attacker and should be removed from the list (if attackCount < watchThreshold) * 2. attacker could be added to the list AUTO (if attackCount >= blockThreshold with blockTill * expiration) or MANUALLY (permanent block)
type ListBasedProtectionService ¶
type ListBasedProtectionService struct {
// contains filtered or unexported fields
}
ListBasedProtectionService is bruteforce protection service that uses lists of blocked ip addresses/devices
func (*ListBasedProtectionService) BlockDevice ¶
func (service *ListBasedProtectionService) BlockDevice(deviceId string)
func (*ListBasedProtectionService) BlockIpAddress ¶
func (service *ListBasedProtectionService) BlockIpAddress(ipAddress string)
func (*ListBasedProtectionService) GetWatchingAttackersCount ¶
func (service *ListBasedProtectionService) GetWatchingAttackersCount() int
func (*ListBasedProtectionService) IsDeviceBlocked ¶
func (service *ListBasedProtectionService) IsDeviceBlocked(deviceId string) bool
func (*ListBasedProtectionService) IsIpAddressBlocked ¶
func (service *ListBasedProtectionService) IsIpAddressBlocked(ipAddress string) bool
func (*ListBasedProtectionService) RegisterDeviceAttempt ¶
func (service *ListBasedProtectionService) RegisterDeviceAttempt(deviceId string) bool
func (*ListBasedProtectionService) RegisterIpAddressAttempt ¶
func (service *ListBasedProtectionService) RegisterIpAddressAttempt(ipAddress string) bool
func (*ListBasedProtectionService) UnblockDevice ¶
func (service *ListBasedProtectionService) UnblockDevice(deviceId string)
func (*ListBasedProtectionService) UnblockIpAddress ¶
func (service *ListBasedProtectionService) UnblockIpAddress(ipAddress string)
type ProtectionService ¶
type ProtectionService interface {
// RegisterIpAddressAttempt function that register attempt to enter non-valid credentials from ipAddress
RegisterIpAddressAttempt(ipAddress string) bool
// RegisterDeviceAttempt function that register attempt to enter non-valid credentials from specific deviceId
RegisterDeviceAttempt(deviceId string) bool
// BlockDevice functions that adds record for blocking access for deviceId to the list
BlockDevice(deviceId string)
// BlockIpAddress functions that adds record for blocking access for ipAddress to the list
BlockIpAddress(ipAddress string)
// IsIpAddressBlocked checks that sender was blocked
IsIpAddressBlocked(ipAddress string) bool
// IsDeviceBlocked checks that sender device was blocked
IsDeviceBlocked(deviceId string) bool
// UnblockIpAddress is a function for direct IP Address unblock
UnblockIpAddress(ipAddress string)
// UnblockDevice is a function for direct Device unblock
UnblockDevice(ipAddress string)
// GetWatchingAttackersCount returns number of watching attackers
GetWatchingAttackersCount() int
}
ProtectionService is a struct that is using for
Service manages Sender (someone who sends request on issue token or|and auth) * Sender is representing by the following fingerprint * 1. Combination of IP addresses via headers X-Forwarded-For or X-Real-IP (for gin could be obtained * through ClientIP()) * 2. X-Device-ID header send by frontend (usually identifies Browser) * Useful articles: * 1. https://www.sobyte.net/post/2021-09/gin-get-client-real-ip/
func CreateProtectionService ¶
func CreateProtectionService(ctx context.Context, config *ProtectionServiceConfig, logger *logging.AppLogger) ProtectionService
CreateProtectionService is a factory function that build implementation of ProtectionService
type ProtectionServiceConfig ¶
type ProtectionServiceConfig struct {
// WatchTimeSec is set a period for inspect potential attackers
WatchTimeSec int
}
ProtectionServiceConfig contains a set of properties that defines bruteforce protection behaviour
Click to show internal directories.
Click to hide internal directories.