This package is abandoned and no longer maintained. No replacement package was suggested.

PSR15 Middleware For CSRF Security

1.0.2 2018-01-28 12:30 UTC

This package is auto-updated.

Last update: 2021-01-09 17:47:48 UTC


Build Status Coverage Status

This middleware check every POST, PUT or DELETE request for a CSRF Token. Token are persisted using an ArrayAccess compatible Session and are generated on demand.


composer require nuboxdevcom/psr15-csrf-middleware

How to use it

$middleware = new CsrfMiddleware($_SESSION, 200);

// Generate input
$input = "<input type='hidden' name='{$middleware->getFormKey()}' value='{$middleware->generateToken()}'/>"

Middleware are constructed with this parameters:

  • session, ArrayAccess|array, used to store token
  • limit, int, limit the number of token to persist
  • sessionKey, string
  • formKey, string