1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 03:01:22 +02:00

Added CSRF Extender (#2095)

This commit is contained in:
Alexander Skvortsov
2020-04-03 15:32:18 -04:00
committed by GitHub
parent 6a7cac7704
commit d627d01544
6 changed files with 193 additions and 2 deletions

View File

@@ -0,0 +1,32 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Extend;
use Flarum\Extension\Extension;
use Illuminate\Contracts\Container\Container;
class Csrf implements ExtenderInterface
{
protected $csrfExemptPaths = [];
public function exemptPath(string $path)
{
$this->csrfExemptPaths[] = $path;
return $this;
}
public function extend(Container $container, Extension $extension = null)
{
$container->extend('flarum.http.csrfExemptPaths', function ($existingExemptPaths) {
return array_merge($existingExemptPaths, $this->csrfExemptPaths);
});
}
}