mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-19 22:16:49 +00:00
34 lines
865 B
PHP
34 lines
865 B
PHP
<?php
|
|
|
|
namespace AIO\Twig;
|
|
|
|
use Slim\Csrf\Guard;
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\Extension\GlobalsInterface;
|
|
|
|
class CsrfExtension extends AbstractExtension implements GlobalsInterface {
|
|
public function __construct(
|
|
protected Guard $csrf
|
|
) {
|
|
}
|
|
|
|
public function getGlobals() : array
|
|
{
|
|
// CSRF token name and value
|
|
$csrfNameKey = $this->csrf->getTokenNameKey();
|
|
$csrfValueKey = $this->csrf->getTokenValueKey();
|
|
$csrfName = $this->csrf->getTokenName();
|
|
$csrfValue = $this->csrf->getTokenValue();
|
|
|
|
return [
|
|
'csrf' => [
|
|
'keys' => [
|
|
'name' => $csrfNameKey,
|
|
'value' => $csrfValueKey
|
|
],
|
|
'name' => $csrfName,
|
|
'value' => $csrfValue
|
|
]
|
|
];
|
|
}
|
|
}
|