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:
committed by
GitHub
parent
6a7cac7704
commit
d627d01544
32
framework/core/src/Extend/Csrf.php
Normal file
32
framework/core/src/Extend/Csrf.php
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user