-
Notifications
You must be signed in to change notification settings - Fork 99
CakePHP Framework
CakePHP is an open-source web framework, following the MVC approach, which is one of the most popular frameworks in the PHP community.
This guide has been tested successfully in version 3.8
, I think it can be used older versions as well.
Use PHP Composer:
composer require shieldon/shieldon ^2
This will also install dependencies built for Shieldon:
- shieldon/psr-http The PSR-7, 15, 17 Implementation with full documented and well tested.
- shieldon/event-dispatcher The simplest event dispatcher.
- shieldon/web-security The collection of functions about web security.
- shieldon/messenger The collection of modules of sending message to third-party API or service, such as Telegram, Line, RocketChat, Slack, SendGrid, MailGun and more...
Step 1 and step 2 are applied to the same file located at /config/route.php
.
A middleware for CakePHP here is ready for you. Just register it on your application.
Example:
/**
* Apply Shieldon Firewall tp the current route scope.
*/
$routes->registerMiddleware(
'firewall',
new \Shieldon\Firewall\Integration\CakePhp()
);
$routes->applyMiddleware('firewall');
Example:
/**
* Define the route for the firewall panel.
*/
$routes->connect('/firewall/panel/*', [
'controller' => 'FirewallPanel',
'action' => 'entry'
]);
Create a controller named FirewallPanelController
and then add the following code into it.
Example:
$panel = new \Shieldon\Firewall\Panel();
$panel->entry();
exit;
If you have CSRF enabled, add these lines:
Example:
$panel->csrf([
'_csrfToken' => $this->request->getParam('_csrfToken')
]);
The full example will look like this:
Example:
<?php
namespace App\Controller;
class FirewallPanelController extends AppController
{
/**
* This is the entry of our Firewall Panel.
*/
public function entry()
{
// Get into the Firewall Panel.
$panel = new \Shieldon\Firewall\Panel();
$panel->csrf([
'_csrfToken' => $this->request->getParam('_csrfToken')
]);
$panel->entry();
exit;
}
}
That's it.
You can access the Firewall Panel by /firewall/panel
, to see the page, go to this URL in your browser.
https://for.example.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.
- Author: Terry L. from Taiwan.
- Website: shieldon.io
- GitHub repository: github.com/terrylinooo/shieldon
- WordPress plugin: wordpress.org/plugins/wp-shieldon/
Docs: Laravel, Symfony, CodeIgniter, CakePHP, Yii, Zend, Slim, Fat-Free, Fuel, PHPixie