Skip to content

CodeIgniter 4 Framework

Terry L edited this page Aug 21, 2020 · 1 revision

In this guide, I will share with you the tips for implementing Shieldon Firewall on your CodeIgniter application.

Firewall in CodeIgniter Framework

Installation

Use PHP Composer:

composer require shieldon/shieldon ^2

This will also install dependencies built for Shieldon:

Implementing

1. Register a Filter.

In your app/Config/Filter.php, add the following code to the $aliases property.

'firewall' => \Shieldon\Firewall\Intergration\CodeIgniter4::class,

And then, add the string firewall to the $globals property, before array.

public $globals = [
    'before' => [
        'firewall'
    ],
];

2. Defind a Controller for Firewall Panel.

<?php 

namespace App\Controllers;

class Firewall extends BaseController
{
    public function panel()
    {
        $panel = new \Shieldon\Firewall\Panel();
        $panel->csrf(csrf_token(), csrf_hash());
        $panel->entry();
    }
}

That's it.

You can access the Firewall Panel by /firewall/panel, to see the page, go to this URL in your browser.

https://yoursite.com/firewall/panel/

The default login is shieldon_user and password is shieldon_pass. After logging in the Firewall Panel, the first thing you need to do is to change the login and password.

Shieldon Firewall will start watching your website if it get enabled in Deamon setting section, make sure you have set up the settings correctly.

Clone this wiki locally