mirror of
https://github.com/flarum/core.git
synced 2025-10-29 06:26:17 +01:00
* Extender docblocks cleanup * Excplicit type hinting in extenders * Bring method under constructor * Mark some classes and methods as internal * Remove beta references Co-authored-by: Clark Winkelmann <clark.winkelmann@gmail.com>
39 lines
900 B
PHP
39 lines
900 B
PHP
<?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 $csrfExemptRoutes = [];
|
|
|
|
/**
|
|
* Exempt a named route from CSRF checks.
|
|
*
|
|
* @param string $routeName
|
|
* @return self
|
|
*/
|
|
public function exemptRoute(string $routeName): self
|
|
{
|
|
$this->csrfExemptRoutes[] = $routeName;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function extend(Container $container, Extension $extension = null)
|
|
{
|
|
$container->extend('flarum.http.csrfExemptPaths', function ($existingExemptPaths) {
|
|
return array_merge($existingExemptPaths, $this->csrfExemptRoutes);
|
|
});
|
|
}
|
|
}
|