dev-master
9999999-dev http://github.com/peec/minibase-plugin-csrfprotectionPlugin that enabled CSRF Protection by default for Minibase framework apps.
MIT
The Requires
- php >=5.4.0
- minibase/minibase dev-master
Plugin that enabled CSRF Protection by default for Minibase framework apps.
CSRF Protection plugin for Minibase applications., (*2)
Handle evil CSRF attacks for all your routes except GET., (*3)
{ "require":{ "pkj/minibase-plugin-csrfprotection": "dev-master" } }
Add the plugin to your app., (*4)
$mb->initPlugins(array('Pkj\Minibase\Plugin\Csrf\CsrfPlugin' => null));
Echo $csrfTokenInput
in the forms that does post requests. Note, also $csrfToken
is available, it contains only the token., (*5)
You are now safe for CSRF protection., (*6)
cookie
or session
. Note SESSION must be started if session is used. I recommend using cookie
.You may customize the error exception if a token is invalid by adding event handler., (*7)
$mb->events->on("csrf:invalid", function ($request) { return function () { return $this->respond("html")->view("csrfinvalid.html.php"); }; });
First, use the class . use Pkj\Minibase\Plugin\Csrf\Annotation\IgnoreCsrfProtection
., (*8)
Can be applied to controllers or a controller method. Useful for RESTful API's. (JSON API). In such where we do not need to check for CSRF protection., (*9)
Plugin that enabled CSRF Protection by default for Minibase framework apps.
MIT