mirror of
https://github.com/filegator/filegator.git
synced 2025-08-15 09:04:05 +02:00
session handler config upd
This commit is contained in:
@@ -30,7 +30,7 @@ class SessionStorage implements Service, SessionStorageInterface
|
|||||||
{
|
{
|
||||||
// we don't have a previous session attached
|
// we don't have a previous session attached
|
||||||
if (! $this->getSession()) {
|
if (! $this->getSession()) {
|
||||||
$handler = $config['available'][$config['session_handler']];
|
$handler = $config['handler'];
|
||||||
$session = new Session($handler());
|
$session = new Session($handler());
|
||||||
$session->setName('filegator');
|
$session->setName('filegator');
|
||||||
|
|
||||||
|
@@ -32,16 +32,13 @@ return [
|
|||||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||||
'config' => [
|
'config' => [
|
||||||
'session_handler' => 'filesession',
|
'handler' => function () {
|
||||||
'available' => [
|
$save_path = null; // use default system path
|
||||||
'filesession' => function () {
|
//$save_path = __DIR__.'/private/sessions';
|
||||||
$save_path = null; // use default system path
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path);
|
||||||
//$save_path = __DIR__.'/private/sessions';
|
|
||||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path);
|
|
||||||
|
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
||||||
},
|
},
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'Filegator\Services\Cors\Cors' => [
|
'Filegator\Services\Cors\Cors' => [
|
||||||
|
@@ -21,4 +21,4 @@ Default handler will use simple ```/private/logs/app.log``` file to store applic
|
|||||||
],
|
],
|
||||||
```
|
```
|
||||||
|
|
||||||
There are many different handlers you can use. Some of them are listed [here](https://github.com/Seldaek/monolog#documentation).
|
There are many different handlers you can add ot top of the stack (monolog_handlers array). Some of them are listed [here](https://github.com/Seldaek/monolog#documentation).
|
||||||
|
@@ -18,16 +18,13 @@ Then, open ```configuration.php``` and update Session handler to:
|
|||||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||||
'config' => [
|
'config' => [
|
||||||
'session_handler' => 'database',
|
'handler' => function () {
|
||||||
'available' => [
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
||||||
'database' => function () {
|
|
||||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
|
||||||
'mysql://root:password@localhost:3360/filegator'
|
'mysql://root:password@localhost:3360/filegator'
|
||||||
);
|
);
|
||||||
|
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
||||||
},
|
},
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
@@ -43,18 +40,15 @@ For example you can pass ```cookie_lifetime``` parameter to extend default sessi
|
|||||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||||
'config' => [
|
'config' => [
|
||||||
'session_handler' => 'database',
|
'handler' => function () {
|
||||||
'available' => [
|
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
||||||
'database' => function () {
|
|
||||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
|
||||||
'mysql://root:password@localhost:3360/filegator'
|
'mysql://root:password@localhost:3360/filegator'
|
||||||
);
|
);
|
||||||
|
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([
|
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([
|
||||||
'cookie_lifetime' => 365 * 24 * 60 * 60, // one year
|
'cookie_lifetime' => 365 * 24 * 60 * 60, // one year
|
||||||
], $handler);
|
], $handler);
|
||||||
},
|
},
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@@ -25,12 +25,9 @@ abstract class AuthTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->session = new SessionStorage(new Request());
|
$this->session = new SessionStorage(new Request());
|
||||||
$this->session->init([
|
$this->session->init([
|
||||||
'session_handler' => 'mockfilesession',
|
'handler' => function () {
|
||||||
'available' => [
|
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
||||||
'mockfilesession' => function () {
|
},
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->setAuth();
|
$this->setAuth();
|
||||||
|
@@ -25,12 +25,9 @@ class SessionStorageTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->session_service = new SessionStorage(new Request());
|
$this->session_service = new SessionStorage(new Request());
|
||||||
$this->session_service->init([
|
$this->session_service->init([
|
||||||
'session_handler' => 'mockfilesession',
|
'handler' => function () {
|
||||||
'available' => [
|
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
||||||
'mockfilesession' => function () {
|
},
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
|
||||||
},
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@@ -28,12 +28,9 @@ return [
|
|||||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||||
'config' => [
|
'config' => [
|
||||||
'session_handler' => 'mockfilesession',
|
'handler' => function () {
|
||||||
'available' => [
|
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
||||||
'mockfilesession' => function () {
|
},
|
||||||
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'Filegator\Services\Tmpfs\TmpfsInterface' => [
|
'Filegator\Services\Tmpfs\TmpfsInterface' => [
|
||||||
|
Reference in New Issue
Block a user