class IpAccessControlService implements LoggerAwareInterface (View source)

Traits

Trait LoggerAwareTrait A trait used with LoggerAwareInterface

LoggerAwareTrait

Constants

IPRANGEFLAG_BLACKLIST

Bit mask for blacklist ranges.

IPRANGEFLAG_WHITELIST

Bit mask for whitelist ranges.

IPRANGEFLAG_MANUAL

Bit mask for manually generated ranges.

IPRANGEFLAG_AUTOMATIC

Bit mask for automatically generated ranges.

IPRANGETYPE_BLACKLIST_MANUAL

IP range type: manually added to the blacklist.

IPRANGETYPE_BLACKLIST_AUTOMATIC

IP range type: automatically added to the blacklist.

IPRANGETYPE_WHITELIST_MANUAL

IP range type: manually added to the whitelist.

Properties

protected EntityManagerInterface $em
protected Site $site
protected IpAccessControlCategory $category

The IP Access Control Category.

protected AddressInterface $defaultIpAddress

Methods

getLoggerChannel()

No description

__construct(EntityManagerInterface $em, Site $site, IpAccessControlCategory $category, AddressInterface $defaultIpAddress)

Initialize the instance.

getCategory()

Get the IP Access Control Category.

bool
isBlacklisted(AddressInterface $ipAddress = null)

Check if an IP address is blacklisted.

bool
isWhitelisted(AddressInterface $ipAddress = null)

Check if an IP address is whitelisted.

registerEvent(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Create and save an IP Access Control Event.

bool
isThresholdReached(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Check if the IP address has reached the threshold.

addToBlacklistForThresholdReached(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Add an IP address to the list of blacklisted IP address when too many events occur.

createRange(RangeInterface $range, int $type, DateTime $expiration = null)

Add persist an IP address range type.

Collection|IpAccessControlRange[]
getRanges(int $type, bool $includeExpired = false)

Get the list of currently available ranges.

getRangeByID(int $id)

Get a saved range for this category given its ID.

deleteRange(IpAccessControlRange|int $range)

Delete a saved range given its instance or its ID.

int
deleteEvents(int|null $minAge = null)

Delete the recorded events.

int
deleteAutomaticBlacklist(bool $onlyExpired = true)

Clear the IP addresses automatically blacklisted.

string
getErrorMessage()

Get the (localized) message telling the users that their IP address has been banned.

getRange(AddressInterface $ipAddress = null)

No description

Details

getLoggerChannel()

__construct(EntityManagerInterface $em, Site $site, IpAccessControlCategory $category, AddressInterface $defaultIpAddress)

Initialize the instance.

Parameters

EntityManagerInterface $em
Site $site
IpAccessControlCategory $category
AddressInterface $defaultIpAddress

IpAccessControlCategory getCategory()

Get the IP Access Control Category.

bool isBlacklisted(AddressInterface $ipAddress = null)

Check if an IP address is blacklisted.

Parameters

AddressInterface $ipAddress

Return Value

bool

bool isWhitelisted(AddressInterface $ipAddress = null)

Check if an IP address is whitelisted.

Parameters

AddressInterface $ipAddress

Return Value

bool

IpAccessControlEvent|null registerEvent(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Create and save an IP Access Control Event.

Parameters

AddressInterface $ipAddress
bool $evenIfDisabled

Return Value

IpAccessControlEvent|null

bool isThresholdReached(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Check if the IP address has reached the threshold.

Parameters

AddressInterface $ipAddress
bool $evenIfDisabled

Return Value

bool

IpAccessControlRange|null addToBlacklistForThresholdReached(AddressInterface $ipAddress = null, bool $evenIfDisabled = false)

Add an IP address to the list of blacklisted IP address when too many events occur.

Parameters

AddressInterface $ipAddress

the IP to add to the blacklist (if null, we'll use the current IP address)

bool $evenIfDisabled

if set to true, we'll add the IP address even if the IP ban system is disabled in the configuration

Return Value

IpAccessControlRange|null

IpAccessControlRange createRange(RangeInterface $range, int $type, DateTime $expiration = null)

Add persist an IP address range type.

Parameters

RangeInterface $range

the IP address range to persist

int $type

The range type (one of the IpAccessControlService::IPRANGETYPE_... constants)

DateTime $expiration

The optional expiration of the range type

Return Value

IpAccessControlRange

Collection|IpAccessControlRange[] getRanges(int $type, bool $includeExpired = false)

Get the list of currently available ranges.

Parameters

int $type

(one of the IPService::IPRANGETYPE_... constants)

bool $includeExpired

Include expired records?

Return Value

Collection|IpAccessControlRange[]

getRangeByID(int $id)

Get a saved range for this category given its ID.

Parameters

int $id \Concrete\Core\Entity\Permission\IpAccessControlRange|null

deleteRange(IpAccessControlRange|int $range)

Delete a saved range given its instance or its ID.

Parameters

IpAccessControlRange|int $range

int deleteEvents(int|null $minAge = null)

Delete the recorded events.

Parameters

int|null $minAge

the minimum age (in seconds) of the records (specify an empty value to delete all records)

Return Value

int

the number of records deleted

int deleteAutomaticBlacklist(bool $onlyExpired = true)

Clear the IP addresses automatically blacklisted.

Parameters

bool $onlyExpired

Return Value

int

the number of records deleted

string getErrorMessage()

Get the (localized) message telling the users that their IP address has been banned.

Return Value

string

IpAccessControlRange|null getRange(AddressInterface $ipAddress = null)

No description

Parameters

AddressInterface $ipAddress

Return Value

IpAccessControlRange|null