Skip to content

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.

Notifications You must be signed in to change notification settings

Ben-Ji-L/PSR-15-Csrf-Middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PSR-15 Middleware

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.

$middleware = new CsrfMiddleware($_SESSION, 200);
$app->pipe($middleware);

// 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

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages