2017 © Pedro Peláez
 

library csrf-middleware

PSR-15 middleware to handle CSRF-token verification

image

zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  • Friday, June 1, 2018
  • by zakirullin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 18 % Grown

The README.md

zakirullin/csrf-middleware

Build Status Scrutinizer PHP from Packagist GitHub commits Software License, (*1)

A PSR-15 middleware to automate CSRF-token verification process, (*2)

Requirements

Installation

This package is installable and autoloadable via Composer as zakirullin/csrf-middleware., (*3)

composer require zakirullin/csrf-middleware 

PHP

$getIdentity = function (\Psr\Http\Message\ServerRequestInterface $request) {
    $session = $request->getAttribute('session');
    return $session->get('id');
};

$dispatcher = new Dispatcher([
    ...
    new \Zakirullin\Middlewares\CSRF($getIdentity, 'secret'),
    ...
]);

HTML

<form method="POST" action="/dangerous/action">
    ...
    <input type="hidden" name="csrf" value="<?= $request->getAttribute('csrf') ?>">
    ...
</form>

Options

__construct(
    callable $getIdentity,
    string $secret,
    string $attribute = self::ATTRIBUTE,
    int $ttl = self::TTL,
    string $algorithm = self::ALGORITHM
)

$getIdentity(ServerRequestInterface $request)

A callback that should return a string containing some per-user unique identity. For example - session id., (*4)


The MIT License (MIT). Please see LICENSE for more information., (*5)

The Versions

01/06 2018

dev-master

9999999-dev https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

15/05 2018

0.6.1

0.6.1.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

15/05 2018

0.6.0

0.6.0.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

15/05 2018

0.5.0

0.5.0.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

14/05 2018

0.4.0

0.4.0.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

12/05 2018

0.3.1

0.3.1.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

12/05 2018

v0.3.0

0.3.0.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to handle CSRF-token verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15

11/05 2018

0.1.0

0.1.0.0 https://github.com/zakirullin/csrf-middleware

PSR-15 middleware to manage CSRF verification

  Sources   Download

MIT

The Requires

 

The Development Requires

by Artem Zakirullin

middleware psr-7 server http token csrf psr-15