Add configuration for maximum operators list items and update ListOperators handling
This commit is contained in:
parent
f6ed7314e3
commit
49171cabb1
3 changed files with 17 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
|||
self::$configuration->setDefault('server.storage_path', '/var/www/uploads');
|
||||
self::$configuration->setDefault('server.list_audit_logs_max_items', 100);
|
||||
self::$configuration->setDefault('server.list_entities_max_items', 100);
|
||||
self::$configuration->setDefault('server.list_operators_max_items', 100);
|
||||
|
||||
self::$configuration->setDefault('logging.log_unauthorized_requests', true);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
private string $storagePath;
|
||||
private int $listAuditLogsMaxItems;
|
||||
private int $listEntitiesMaxItems;
|
||||
private int $listOperatorsMaxItems = 100;
|
||||
|
||||
/**
|
||||
* ServerConfiguration constructor.
|
||||
|
@ -26,6 +27,7 @@
|
|||
$this->storagePath = $config['storage_path'] ?? '/var/www/uploads';
|
||||
$this->listAuditLogsMaxItems = $config['list_audit_logs_max_items'] ?? 100;
|
||||
$this->listEntitiesMaxItems = $config['list_entities_max_items'] ?? 100;
|
||||
$this->listOperatorsMaxItems = $config['list_operators_max_items'] ?? 100;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,4 +99,14 @@
|
|||
{
|
||||
return $this->listEntitiesMaxItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum number of items to return when listing operators.
|
||||
*
|
||||
* @return int The maximum number of operator items to return.
|
||||
*/
|
||||
public function getListOperatorsMaxItems(): int
|
||||
{
|
||||
return $this->listOperatorsMaxItems;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace FederationServer\Methods\Operators;
|
||||
|
||||
use FederationServer\Classes\Configuration;
|
||||
use FederationServer\Classes\Managers\OperatorManager;
|
||||
use FederationServer\Classes\RequestHandler;
|
||||
use FederationServer\Exceptions\DatabaseOperationException;
|
||||
|
@ -21,12 +22,12 @@
|
|||
throw new RequestException('Unauthorized: Insufficient permissions to list operators', 403);
|
||||
}
|
||||
|
||||
$limit = (int) (FederationServer::getParameter('limit') ?? 100);
|
||||
$limit = (int) (FederationServer::getParameter('limit') ?? Configuration::getServerConfiguration()->getListOperatorsMaxItems());
|
||||
$page = (int) (FederationServer::getParameter('page') ?? 1);
|
||||
|
||||
if($limit < 1)
|
||||
if($limit < 1 || $limit > Configuration::getServerConfiguration()->getListOperatorsMaxItems())
|
||||
{
|
||||
$limit = 100;
|
||||
$limit = Configuration::getServerConfiguration()->getListOperatorsMaxItems();
|
||||
}
|
||||
|
||||
if($page < 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue