PHP code example of zakirullin / csrf-middleware
1. Go to this page and download the library: Download zakirullin/csrf-middleware library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
zakirullin / csrf-middleware example snippets
$getIdentity = function (\Psr\Http\Message\ServerRequestInterface $request) {
$session = $request->getAttribute('session');
return $session->get('id');
};
$dispatcher = new Dispatcher([
...
new \Zakirullin\Middlewares\CSRF($getIdentity, 'secret'),
...
]);
__construct(
callable $getIdentity,
string $secret,
string $attribute = self::ATTRIBUTE,
int $ttl = self::TTL,
string $algorithm = self::ALGORITHM
)