PHPackages                             m6web/firewall-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. m6web/firewall-bundle

AbandonedArchivedSymfony-bundle[Security](/categories/security)

m6web/firewall-bundle
=====================

Bundle providing IP filtering features for controllers and actions

v3.0.0(6y ago)22303.0k—0%10[2 issues](https://github.com/M6Web/FirewallBundle/issues)2MITPHPPHP &gt;=7.0.0

Since May 28Pushed 6y ago70 watchersCompare

[ Source](https://github.com/M6Web/FirewallBundle)[ Packagist](https://packagist.org/packages/m6web/firewall-bundle)[ RSS](/packages/m6web-firewall-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (20)Used By (2)

Firewall Bundle [![Build Status](https://camo.githubusercontent.com/b82d5f3173ac3bf039aebdd43ed7b5a2dfbb2db5dc344dce88cb25211e2cb540/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f4d365765622f4669726577616c6c42756e646c652e706e67)](http://travis-ci.org/M6Web/FirewallBundle)
============================================================================================================================================================================================================================================================================================

[](#firewall-bundle-)

This bundle provides IP filtering features for your Symfony applications.
It uses the [Firewall component](https://github.com/M6Web/Firewall) and offers service and annotations configuration.

For implementation into a Symfony 3 or Symfony 4 application, please use the release `v3.0.0` at least.

Installation
------------

[](#installation)

Add this line in your `composer.json` :

```
{
    "require": {
        "m6web/firewall-bundle": "dev-master"
    }
}
```

Update your vendors :

```
composer update m6web/firewall-bundle

```

Registering
-----------

[](#registering)

```
class AppKernel extends \Symfony\Component\HttpKernel\Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            new M6Web\Bundle\FirewallBundle\M6WebFirewallBundle(),
        );
    }
}
```

Usage
-----

[](#usage)

#### Configuration

[](#configuration)

```
m6web_firewall:
    lists:             	                   # Define some IP lists into the Firewall Provider
        self: 				                    # Define a list named "self"
            - '127.0.0.1' 			                # IPV4
            - '::1'      	 	        	        # IPV6 short notation
        lan:     			                    # Define a list named "lan"
            - '192.168.0.*' 		                # IPV4 with Wildcard (* = all)
            - '192.168.0.0/24' 		                # IPV4 with CIDR Mask
            - '192.168.0.0/255.255.255.0' 	        # IPV4 with Subnet Mask
    configs: 				               # Define some pre-defined configurations into the Firewall Provider
        default: 				                # Define a configuration named "default"
            default_state: true 		            # Default returned value (default: true)
            throw_error: true 		                # Throw an exception for rejected users (default: true)
            error_code: 403 		                # Exception status code (default: 403)
            error_message: 'Forbidden' 	            # Exception message (default: Forbidden)
            lists: 			                        # Lists access state
                self: true 			                    # "self" list records will be allowed by the firewall
                lan: false 			                    # "lan" list records will be rejected by the firewall
            entries: 			                    # Define custom IP's access state
                '192.168.0.10': true 	                # "192.168.0.10" will be allowed
                '192.168.0.20': false 	                # "192.168.0.20" will be rejected
```

#### Global annotation

[](#global-annotation)

```
use M6Web\Bundle\FirewallBundle\Annotation\Firewall;

/**
 * @Firewall(
 *      config="default",
 *      actions={
 *          'myFirstAction'
 *      },
 *      default_state=true,
 *      lists={
 *          'default': true
 *      },
 *      entries={
 *          '192.168.0.50': false
 *      },
 *      throw_error: false,
 *      callback="myFirewallResponseHandler",
 *      error_message: 'Forbiden',
 *      error_code: 403
 * )
 */
```

- `config` parameter sets which pre-defined configuration to use,
- `actions` parameter sets which actions of the controller are protected (in case of Class Annotation).

All default [set](#configuration) parameters can be overloaded by annotation.

#### Class annotation

[](#class-annotation)

```
use M6Web\Bundle\FirewallBundle\Annotation\Firewall;

/**
 * @Firewall(
 *      config="default",
 *      actions={
 *          'myFirstAction'
 *      }
 * )
 */
class MyBundleController extends Controller
{
    public function myFirstAction()
    {
    }

    public function mySecondAction()
    {
    }
}
```

- `myFirstAction` is protected by the [pre-defined configuration](#configuration) `default`.
    In this case we can set one (or many) firewall used for many actions.

#### Method annotation

[](#method-annotation)

```
use M6Web\Bundle\FirewallBundle\Annotation\Firewall;

class MyBundleController extends Controller
{
    /**
     * @Firewall(
     *      config="default"
     * )
     */
    public function myFirstAction()
    {
    }

    /**
     * @Firewall(
     *      default_state=true,
     *      lists={
     *           'lan': false
     *      },
     *      entries={
     *          '20.30.40.50': false
     *      }
     * )
     */
    public function mySecondAction()
    {
    }
}
```

- `myFirstAction` uses its own firewall with [pre-defined configuration](#configuration) `default`,
- `mySecondAction` uses its own firewall with a custom configuration.

#### Path configuration

[](#path-configuration)

```
m6web_firewall:
    patterns:                             # define some routing pattern to filter
        api:
            config: default                         # config associed to the path
            path: /api                              # path to filter
```

- `config` parameter sets which pre-defined configuration to use,
- `path` parameter sets which path are protected.

Running the tests
-----------------

[](#running-the-tests)

```
$ php composer.phar install --dev
$ ./vendor/bin/atoum -d Tests/

```

Credits
-------

[](#credits)

Developped by the [Cytron Team](http://cytron.fr/) of [M6 Web](http://tech.m6web.fr/).
Tested with [atoum](http://atoum.org).

License
-------

[](#license)

The FirewallBundle is licensed under the [MIT license](LICENSE).

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~169 days

Recently: every ~182 days

Total

15

Last Release

2373d ago

Major Versions

v0.3.2 → v1.0.02015-06-17

v1.1.1 → V2.0.02017-11-19

v2.1.0 → v3.0.02019-11-18

PHP version history (2 changes)0.1.0PHP &gt;=5.4.0

V2.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2069361?v=4)[Patrick](/maintainers/Bedrock)[@Bedrock](https://github.com/Bedrock)

---

Top Contributors

[![KuiKui](https://avatars.githubusercontent.com/u/748924?v=4)](https://github.com/KuiKui "KuiKui (14 commits)")[![omansour](https://avatars.githubusercontent.com/u/1131098?v=4)](https://github.com/omansour "omansour (8 commits)")[![Meroje](https://avatars.githubusercontent.com/u/304101?v=4)](https://github.com/Meroje "Meroje (4 commits)")[![adriensamson](https://avatars.githubusercontent.com/u/520234?v=4)](https://github.com/adriensamson "adriensamson (3 commits)")[![dipston](https://avatars.githubusercontent.com/u/4101731?v=4)](https://github.com/dipston "dipston (3 commits)")[![lotholf](https://avatars.githubusercontent.com/u/1133480?v=4)](https://github.com/lotholf "lotholf (3 commits)")[![jubianchi](https://avatars.githubusercontent.com/u/327237?v=4)](https://github.com/jubianchi "jubianchi (1 commits)")[![fdubost](https://avatars.githubusercontent.com/u/3973818?v=4)](https://github.com/fdubost "fdubost (1 commits)")[![Aylarius](https://avatars.githubusercontent.com/u/19950092?v=4)](https://github.com/Aylarius "Aylarius (1 commits)")[![DocRoms](https://avatars.githubusercontent.com/u/12815769?v=4)](https://github.com/DocRoms "DocRoms (1 commits)")[![mikaelrandy](https://avatars.githubusercontent.com/u/187703?v=4)](https://github.com/mikaelrandy "mikaelrandy (1 commits)")[![ickbinhier](https://avatars.githubusercontent.com/u/2810904?v=4)](https://github.com/ickbinhier "ickbinhier (1 commits)")

---

Tags

symfonybundleIPfilteringfirewall

### Embed Badge

![Health badge](/badges/m6web-firewall-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/m6web-firewall-bundle/health.svg)](https://phpackages.com/packages/m6web-firewall-bundle)
```

###  Alternatives

[rezzza/security-bundle

Signed requests check

1753.6k](/packages/rezzza-security-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
