Web Application Firewall (WAF) package for Laravel

Web Application Firewall (WAF) package for Laravel

This package intends to protect your Laravel app from different type of attacks such as XSS, SQLi, RFI, LFI, User Agent, and a lot more.

Originally published at https://github.com/akaunting

This package intends to protect your Laravel app from different type of attacks such as XSS, SQLi, RFI, LFI, User Agent, and a lot more. It will also block repeated attacks and send notification via email and/or slack when attack is detected. Furthermore, it will log failed logins and block the IP after a number of attempts.

Note: Some middleware classes (i.e. Xss) are empty as the Base class that they extend does all of the job, dynamically. In short, they all works ;)

Getting Started

1. Install

Run the following command:

composer require akaunting/firewall

2. Register (for Laravel < 5.5)

Register the service provider in config/app.php


3. Publish

Publish configuration, language, and migrations

php artisan vendor:publish --tag=firewall

4. Database

Create db tables

php artisan migrate

5. Configure

You can change the firewall settings of your app from config/firewall.php file


Middlewares are already defined so should just add them to routes. The firewall.all middleware applies all the middlewares available in the all_middleware array of config file.

Route::group(['middleware' => 'firewall.all'], function () {
    Route::get('/', '[email protected]');

You can apply each middleware per route. For example, you can allow only whitelisted IPs to access admin:

Route::group(['middleware' => 'firewall.whitelist'], function () {
    Route::get('/admin', '[email protected]');

Or you can get notified when anyone NOT in whitelist access admin, by adding it to the inspections config:

Route::group(['middleware' => 'firewall.url'], function () {
    Route::get('/admin', '[email protected]');

Available middlewares applicable to routes:


firewall.agent firewall.geo firewall.ip firewall.lfi firewall.php firewall.referrer firewall.rfi firewall.session firewall.sqli firewall.swear firewall.url firewall.whitelist firewall.xss

You may also define routes for each middleware in config/firewall.php and apply that middleware or firewall.all at the top of all routes.


Firewall will send a notification as soon as an attack has been detected. Emails entered in notifications.email.to config must be valid Laravel users in order to send notifications. Check out the Notifications documentation of Laravel for further information.

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow me on Facebook | Twitter

Learn More about Laravel

PHP with Laravel for beginners - Become a Master in Laravel

Projects in Laravel: Learn Laravel Building 10 Projects

Laravel for RESTful: Build Your RESTful API with Laravel

Fullstack Web Development With Laravel and Vue.js

Laravel 5.8 Ajax CRUD tutorial using Datatable JS

Laravel 5.8 Tutorial from Scratch for Beginners

Build RESTful API In Laravel 5.8 Example

Login with Google in Laravel 5.8 App using Socialite Package

Laravel PHP Framework Tutorial - Full Course for Beginners (2019)

laravel web-development security

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Laravel Development Company

Skenix Infotech is a top Laravel Website Development Company with Expert Laravel Developers that provides robust Laravel Development Services at fair costs.

How to Hire Laravel Developers and How Much Does It Cost.

Want to make the most out of the latest Laravel technology? Here is your guide on how to hire the best Laravel developer, and at the right price. 

Hire Web Developer

Looking for an attractive & user-friendly web developer? HourlyDeveloper.io, a leading web, and mobile app development company, offers web developers for hire through flexible engagement models. You can **[Hire Web...

Why Web Development is Important for your Business

With the rapid development in technology, the old ways to do business have changed completely. A lot more advanced and developed ways are ...

Laravel Development Company

SemiDot Infotech is a leading Laravel Development company that offers high quality Laravel development services by expert Laravel developers.