restrict access by ip address for CakePHP3 Component
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require tyrellsys/cakephp3-ip-filter
Controller::initialize
...
public function initialize($event)
{
....
$this->loadComponent('Tyrellsys/CakePHP3IpFilter.IpFilter', [
'trustProxy' => true,
'whitelist' => '192.168.0.0/24' // array OR comma separate value
]);
...
bool check(string $ip = null)
- returns comparewhitelist
.void checkOrFail(string $ip = null)
- throws \Cake\Http\Exception\ForbiddenException when bad ip address.