Download the PHP package coosos/ip-filter-bundle without Composer
On this page you can find all versions of the php package coosos/ip-filter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package ip-filter-bundle
IpFilterBundle
Note : This project was forked from Spomky-Labs/IpFilterBundle because is abandoned.
Description
This bundle will help you to restrict access of your application using IP addresses
and ranges of IP addresses
.
It supports both IPv4
and IPv6
addresses and multiple environments.
For example, you can grant access of a range of addresses from 192.168.1.1
to 192.168.1.100
on dev
and test
environments and deny all others.
Please note that this bundle has bad results in term of performance compared to similar functionality offered by a .htaccess
file for example.
This bundle required or used
Package | Version |
---|---|
PHP | ^7.1 |
Symfony | ^4.0|~5.0 |
Doctrine | ^2.6 |
Policy
Please note that authorized IPs have a higher priority than unauthorized ones.
For example, if range 192.168.1.10
to 192.168.1.100
is unauthorized and 192.168.1.20
is authorized, then 192.168.1.20
will be granted.
Installation
Installation is a quick 4 steps process:
- Download the bundle
- Enable the Bundle
- Create your model class
- Configure the application
Step 1: Install the bundle
The preferred way to install this bundle is to rely on Composer:
Step 2: Enable the bundle
Enable the bundle in config/bundles.php
:
Step 3: Create IP classes
This bundle needs a database to persist filtered IPs.
Your first job, then, is to create Ip
classes for your application.
These classes can look and act however you want: add any properties or methods you find useful.
In the following sections, you'll see an example of how your classes should look.
Ip class:
Step 4: Configure your application
Set your classes and managers
If you have your own managers, you can use them. They just need to implement Coosos\IpFilterBundle\Model\IpManagerInterface
.
Security Strategy
In order for this bundle to take effect, you need to change the default access decision strategy, which, by default, grants access if any voter grants access.
You also need to place your site behind a firewall rule.
How to
Small example
How to grant access for 192.168.1.10
on dev
and test
environments and deny all others?
Network support
Networks can be supported using a Range object. You just need to get first and last IP addresses. This bundle provides a range calculator, so you can easily extend your range entity using it.