Add configuration for maximum audit log items and update ListAuditLogs handling
This commit is contained in:
parent
7fb5a6d712
commit
4785961726
3 changed files with 21 additions and 7 deletions
|
@ -26,6 +26,7 @@
|
||||||
self::$configuration->setDefault('server.api_key', Utilities::generateString());
|
self::$configuration->setDefault('server.api_key', Utilities::generateString());
|
||||||
self::$configuration->setDefault('server.max_upload_size', 52428800); // 50MB default
|
self::$configuration->setDefault('server.max_upload_size', 52428800); // 50MB default
|
||||||
self::$configuration->setDefault('server.storage_path', '/var/www/uploads');
|
self::$configuration->setDefault('server.storage_path', '/var/www/uploads');
|
||||||
|
self::$configuration->setDefault('server.list_audit_logs_max_items', 100);
|
||||||
|
|
||||||
self::$configuration->setDefault('logging.log_unauthorized_requests', true);
|
self::$configuration->setDefault('logging.log_unauthorized_requests', true);
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
private ?string $apiKey;
|
private ?string $apiKey;
|
||||||
private int $maxUploadSize;
|
private int $maxUploadSize;
|
||||||
private string $storagePath;
|
private string $storagePath;
|
||||||
|
private int $listAuditLogsMaxItems;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServerConfiguration constructor.
|
* ServerConfiguration constructor.
|
||||||
|
@ -17,11 +18,12 @@
|
||||||
*/
|
*/
|
||||||
public function __construct(array $config)
|
public function __construct(array $config)
|
||||||
{
|
{
|
||||||
$this->baseUrl = $config['server.base_url'] ?? 'http://127.0.0.1:6161';
|
$this->baseUrl = $config['base_url'] ?? 'http://127.0.0.1:6161';
|
||||||
$this->name = $config['server.name'] ?? 'Federation Server';
|
$this->name = $config['name'] ?? 'Federation Server';
|
||||||
$this->apiKey = $config['server.api_key'] ?? null;
|
$this->apiKey = $config['api_key'] ?? null;
|
||||||
$this->maxUploadSize = $config['max_upload_size'] ?? 52428800; // 50MB default
|
$this->maxUploadSize = $config['max_upload_size'] ?? 52428800; // 50MB default
|
||||||
$this->storagePath = $config['server.storage_path'] ?? '/var/www/uploads';
|
$this->storagePath = $config['storage_path'] ?? '/var/www/uploads';
|
||||||
|
$this->listAuditLogsMaxItems = $config['list_audit_logs_max_items'] ?? 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,4 +75,14 @@
|
||||||
{
|
{
|
||||||
return $this->storagePath;
|
return $this->storagePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the maximum number of items to return when listing audit logs.
|
||||||
|
*
|
||||||
|
* @return int The maximum number of audit log items to return.
|
||||||
|
*/
|
||||||
|
public function getListAuditLogsMaxItems(): int
|
||||||
|
{
|
||||||
|
return $this->listAuditLogsMaxItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace FederationServer\Methods\Audit;
|
namespace FederationServer\Methods\Audit;
|
||||||
|
|
||||||
|
use FederationServer\Classes\Configuration;
|
||||||
use FederationServer\Classes\Managers\AuditLogManager;
|
use FederationServer\Classes\Managers\AuditLogManager;
|
||||||
use FederationServer\Classes\Managers\EntitiesManager;
|
use FederationServer\Classes\Managers\EntitiesManager;
|
||||||
use FederationServer\Classes\Managers\OperatorManager;
|
use FederationServer\Classes\Managers\OperatorManager;
|
||||||
|
@ -18,12 +19,12 @@
|
||||||
*/
|
*/
|
||||||
public static function handleRequest(): void
|
public static function handleRequest(): void
|
||||||
{
|
{
|
||||||
$limit = (int) (FederationServer::getParameter('limit') ?? 100);
|
$limit = (int) (FederationServer::getParameter('limit') ?? Configuration::getServerConfiguration()->getListAuditLogsMaxItems());
|
||||||
$page = (int) (FederationServer::getParameter('page') ?? 1);
|
$page = (int) (FederationServer::getParameter('page') ?? 1);
|
||||||
|
|
||||||
if($limit < 1)
|
if($limit < 1 || $limit > Configuration::getServerConfiguration()->getListAuditLogsMaxItems())
|
||||||
{
|
{
|
||||||
$limit = 100;
|
$limit = Configuration::getServerConfiguration()->getListAuditLogsMaxItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($page < 1)
|
if($page < 1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue