mirror of
https://github.com/filegator/filegator.git
synced 2025-08-16 09:54:19 +02:00
docs update
This commit is contained in:
42
docs/configuration/auth.md
Normal file
42
docs/configuration/auth.md
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
### Configuring Auth service to use database
|
||||
You can store your users inside mysql database (default is json file).
|
||||
|
||||
First, create a table ```users``` with this sql:
|
||||
```
|
||||
CREATE TABLE `users` (
|
||||
`id` int(10) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(255) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`role` varchar(20) NOT NULL,
|
||||
`permissions` varchar(200) NOT NULL,
|
||||
`homedir` varchar(2000) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `username` (`username`)
|
||||
) CHARSET=utf8 COLLATE=utf8_bin;
|
||||
```
|
||||
Then, import default users with this query:
|
||||
|
||||
```
|
||||
INSERT INTO `users` (`username`, `name`, `role`, `permissions`, `homedir`, `password`)
|
||||
VALUES
|
||||
('guest', 'Guest', 'guest', '', '/', ''),
|
||||
('admin', 'Admin', 'admin', 'read|write|upload|download|batchdownload|zip', '/', '$2y$10$Nu35w4pteLfc7BDCIkDPkecjw8wsH8Y2GMfIewUbXLT7zzW6WOxwq');
|
||||
```
|
||||
|
||||
Ath the end, open ```configuration.php``` and update Auth handler under section ```services``` to something like this:
|
||||
|
||||
```
|
||||
'Filegator\Services\Auth\AuthInterface' => [
|
||||
'handler' => '\Filegator\Services\Auth\Adapters\Database',
|
||||
'config' => [
|
||||
'driver' => 'mysqli',
|
||||
'host' => 'localhost',
|
||||
'username' => 'root',
|
||||
'password' => 'password',
|
||||
'database' => 'filegator',
|
||||
],
|
||||
],
|
||||
```
|
||||
|
159
docs/configuration/default.md
Normal file
159
docs/configuration/default.md
Normal file
@@ -0,0 +1,159 @@
|
||||
### Configuring FileGator
|
||||
All configuration options are stored inside ```configuration.php``` file.
|
||||
In this file you can configure all the options, services and their handlers.
|
||||
|
||||
|
||||
### Default Configuration options
|
||||
|
||||
|
||||
```
|
||||
'public_path' => APP_PUBLIC_PATH,
|
||||
'public_dir' => APP_PUBLIC_DIR,
|
||||
|
||||
'frontend_config' => [
|
||||
'app_name' => 'FileGator',
|
||||
'app_version' => APP_VERSION,
|
||||
'language' => 'english',
|
||||
'logo' => 'https://raw.githubusercontent.com/filegator/filegator/master/dist/img/logo.png',
|
||||
'upload_max_size' => 100 * 1024 * 1024, // 100MB
|
||||
'upload_chunk_size' => 1 * 1024 * 1024, // 1MB
|
||||
'upload_simultaneous' => 3,
|
||||
'default_archive_name' => 'archive.zip',
|
||||
],
|
||||
|
||||
'services' => [
|
||||
'Filegator\Services\Logger\LoggerInterface' => [
|
||||
'handler' => '\Filegator\Services\Logger\Adapters\MonoLogger',
|
||||
'config' => [
|
||||
'monolog_handlers' => [
|
||||
function () {
|
||||
return new \Monolog\Handler\StreamHandler(
|
||||
__DIR__.'/private/logs/app.log',
|
||||
\Monolog\Logger::DEBUG
|
||||
);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||
'config' => [
|
||||
'session_handler' => 'filesession',
|
||||
'available' => [
|
||||
'filesession' => function () {
|
||||
$save_path = null; // use default system 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);
|
||||
},
|
||||
'database' => function () {
|
||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
||||
'mysql://root:password@localhost:3360/filegator'
|
||||
);
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Cors\Cors' => [
|
||||
'handler' => '\Filegator\Services\Cors\Cors',
|
||||
'config' => [
|
||||
'enabled' => APP_ENV == 'production' ? false : true,
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Tmpfs\TmpfsInterface' => [
|
||||
'handler' => '\Filegator\Services\Tmpfs\Adapters\Tmpfs',
|
||||
'config' => [
|
||||
'path' => __DIR__.'/private/tmp/',
|
||||
'gc_probability_perc' => 10,
|
||||
'gc_older_than' => 60 * 60 * 24 * 2, // 2 days
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Security\Security' => [
|
||||
'handler' => '\Filegator\Services\Security\Security',
|
||||
'config' => [
|
||||
'csrf_protection' => true,
|
||||
'ip_whitelist' => [],
|
||||
'ip_blacklist' => [],
|
||||
],
|
||||
],
|
||||
'Filegator\Services\View\ViewInterface' => [
|
||||
'handler' => '\Filegator\Services\View\Adapters\Vuejs',
|
||||
'config' => [
|
||||
'add_to_head' => '',
|
||||
'add_to_body' => '',
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Storage\Filesystem' => [
|
||||
'handler' => '\Filegator\Services\Storage\Filesystem',
|
||||
'config' => [
|
||||
'separator' => '/',
|
||||
'config' => [],
|
||||
'filesystem_adapter' => 'localfilesystem',
|
||||
'adapters' => [
|
||||
'localfilesystem' => function () {
|
||||
return new \League\Flysystem\Adapter\Local(
|
||||
__DIR__.'/repository'
|
||||
);
|
||||
},
|
||||
'ftp' => function () {
|
||||
// see: https://flysystem.thephpleague.com/docs/adapter/ftp/
|
||||
return new \League\Flysystem\Adapter\Ftp([
|
||||
'host' => 'example.com',
|
||||
'username' => 'demo',
|
||||
'password' => 'password',
|
||||
'port' => 21,
|
||||
'timeout' => 10,
|
||||
]);
|
||||
},
|
||||
'sftp' => function () {
|
||||
// composer require league/flysystem-sftp
|
||||
// see: https://flysystem.thephpleague.com/docs/adapter/sftp/
|
||||
return new \League\Flysystem\Sftp\SftpAdapter([
|
||||
'host' => 'example.com',
|
||||
'port' => 22,
|
||||
'username' => 'demo',
|
||||
'password' => 'password',
|
||||
'timeout' => 10,
|
||||
]);
|
||||
},
|
||||
'dropbox' => function () {
|
||||
// composer require spatie/flysystem-dropbox
|
||||
// see: https://flysystem.thephpleague.com/docs/adapter/dropbox/
|
||||
$authorizationToken = '1234';
|
||||
$client = new \Spatie\Dropbox\Client($authorizationToken);
|
||||
|
||||
return new \Spatie\FlysystemDropbox\DropboxAdapter($client);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
'Filegator\Services\Archiver\ArchiverInterface' => [
|
||||
'handler' => '\Filegator\Services\Archiver\Adapters\ZipArchiver',
|
||||
'config' => [],
|
||||
],
|
||||
'Filegator\Services\Auth\AuthInterface' => [
|
||||
'handler' => '\Filegator\Services\Auth\Adapters\JsonFile',
|
||||
'config' => [
|
||||
'file' => __DIR__.'/private/users.json',
|
||||
],
|
||||
//'handler' => '\Filegator\Services\Auth\Adapters\Database',
|
||||
//'config' => [
|
||||
// 'driver' => 'mysqli',
|
||||
// 'host' => 'localhost',
|
||||
// 'username' => 'root',
|
||||
// 'password' => 'password',
|
||||
// 'database' => 'filegator',
|
||||
//],
|
||||
],
|
||||
'Filegator\Services\Router\Router' => [
|
||||
'handler' => '\Filegator\Services\Router\Router',
|
||||
'config' => [
|
||||
'query_param' => 'r',
|
||||
'routes_file' => __DIR__.'/backend/Controllers/routes.php',
|
||||
],
|
||||
],
|
||||
],
|
||||
```
|
61
docs/configuration/session.md
Normal file
61
docs/configuration/session.md
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
### Configuring Session service to use database
|
||||
|
||||
First, create a table ```sessions``` with this sql:
|
||||
```
|
||||
CREATE TABLE `sessions` (
|
||||
`sess_id` varbinary(128) NOT NULL,
|
||||
`sess_data` blob NOT NULL,
|
||||
`sess_lifetime` mediumint(9) NOT NULL,
|
||||
`sess_time` int(10) unsigned NOT NULL,
|
||||
PRIMARY KEY (`sess_id`)
|
||||
) CHARSET=utf8 COLLATE=utf8_bin;
|
||||
```
|
||||
|
||||
Then, open ```configuration.php``` and update Auth handler under section ```services``` to something like this:
|
||||
|
||||
```
|
||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||
'config' => [
|
||||
'session_handler' => 'database',
|
||||
'available' => [
|
||||
'database' => function () {
|
||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
||||
'mysql://root:password@localhost:3360/filegator'
|
||||
);
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([], $handler);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
```
|
||||
Don't forget to enter correct mysql username, password, and database.
|
||||
|
||||
|
||||
### Tweaking session options
|
||||
|
||||
The Underying Symfony session [component](https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php) constructor accepts an array options.
|
||||
For example you can pass ```cookie_lifetime``` parameter and extend session lifetime like this:
|
||||
```
|
||||
'Filegator\Services\Session\SessionStorageInterface' => [
|
||||
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
|
||||
'config' => [
|
||||
'session_handler' => 'database',
|
||||
'available' => [
|
||||
'database' => function () {
|
||||
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
|
||||
'mysql://root:password@localhost:3360/filegator'
|
||||
);
|
||||
|
||||
return new \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage([
|
||||
'cookie_lifetime' => 365 * 24 * 60 * 60, // one year
|
||||
], $handler);
|
||||
},
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
```
|
Reference in New Issue
Block a user