Store sessions in database (#1736)

This commit is contained in:
Kevin Papst
2020-06-11 16:54:51 +02:00
committed by GitHub
parent a75bdc52f6
commit ea4e930cbb
23 changed files with 507 additions and 20 deletions

View File

@@ -54,9 +54,6 @@ class RedirectToLocaleSubscriber implements EventSubscriberInterface
$this->urlGenerator = $urlGenerator;
$this->locales = explode('|', trim($locales));
if (empty($this->locales)) {
throw new \UnexpectedValueException('The list of supported locales must not be empty.');
}
$this->defaultLocale = $defaultLocale ?: $this->locales[0];
if (!\in_array($this->defaultLocale, $this->locales)) {

View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DoctrineMigrations;
use App\Doctrine\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* @version 1.10
*/
final class Version20200524142042 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add table to store sessions in database';
}
public function up(Schema $schema): void
{
$sessions = $schema->createTable('kimai2_sessions');
$sessions->addColumn('id', 'string', ['length' => 128, 'notnull' => true]);
$sessions->addColumn('data', 'blob', ['length' => 65535, 'notnull' => true]);
$sessions->addColumn('time', 'integer', ['unsigned' => true, 'notnull' => true]);
$sessions->addColumn('lifetime', 'integer', ['unsigned' => true, 'notnull' => true]);
$sessions->setPrimaryKey(['id']);
}
public function down(Schema $schema): void
{
$schema->dropTable('kimai2_sessions');
}
}

View File

@@ -20,7 +20,6 @@ class PluginManager
/**
* @param PluginInterface[] $plugins
* @throws \Exception
*/
public function __construct(iterable $plugins)
{
@@ -31,7 +30,6 @@ class PluginManager
/**
* @param PluginInterface $plugin
* @throws \Exception
*/
public function addPlugin(PluginInterface $plugin)
{

View File

@@ -17,11 +17,8 @@ class AclDecisionManager
/**
* @var AccessDecisionManagerInterface
*/
protected $decisionManager;
private $decisionManager;
/**
* @param AccessDecisionManagerInterface $decisionManager
*/
public function __construct(AccessDecisionManagerInterface $decisionManager)
{
$this->decisionManager = $decisionManager;

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Security;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
class SessionHandler extends PdoSessionHandler
{
public function __construct($pdoOrDsn = null)
{
parent::__construct($pdoOrDsn, [
'db_table' => 'kimai2_sessions',
'db_id_col' => 'id',
'db_data_col' => 'data',
'db_lifetime_col' => 'lifetime',
'db_time_col' => 'time',
'lock_mode' => PdoSessionHandler::LOCK_ADVISORY,
]);
}
}