2017 © Pedro Peláez
 

library minibase-plugin-csrfprotection

Plugin that enabled CSRF Protection by default for Minibase framework apps.

image

pkj/minibase-plugin-csrfprotection

Plugin that enabled CSRF Protection by default for Minibase framework apps.

  • Friday, April 26, 2013
  • by peec
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

CSRF Protection Plugin

CSRF Protection plugin for Minibase applications., (*2)

Handle evil CSRF attacks for all your routes except GET., (*3)

Install

{
  "require":{
         "pkj/minibase-plugin-csrfprotection": "dev-master"
    }
}

Usage

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)

Configuration array:

  • store: cookie or session. Note SESSION must be started if session is used. I recommend using cookie.
  • token_name: the name of the token. Default is "csrfToken".

Events

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");
    };
});

Annotations

First, use the class . use Pkj\Minibase\Plugin\Csrf\Annotation\IgnoreCsrfProtection., (*8)

@IgnoreCsrfProtection

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)

The Versions

26/04 2013

dev-master

9999999-dev http://github.com/peec/minibase-plugin-csrfprotection

Plugin that enabled CSRF Protection by default for Minibase framework apps.

  Sources   Download

MIT

The Requires