Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • perun/perun-proxyidp/v1/simplesamlphp-module-proxystatistics
1 result
Show changes
Commits on Source (3)
# [8.4.0](https://gitlab.ics.muni.cz/perun-proxy-aai/simplesamlphp/simplesamlphp-module-proxystatistics/compare/v8.3.0...v8.4.0) (2023-12-28)
### Features
* 🎸 Cron enable/disable flag ([0df119c](https://gitlab.ics.muni.cz/perun-proxy-aai/simplesamlphp/simplesamlphp-module-proxystatistics/commit/0df119c2c62512ab54f8de88dd816b781ae4a0f4))
# [8.3.0](https://gitlab.ics.muni.cz/perun-proxy-aai/simplesamlphp/simplesamlphp-module-proxystatistics/compare/v8.2.0...v8.3.0) (2023-11-27)
......
......@@ -104,9 +104,17 @@ $config = [
*/
//'apiWritePasswordHash' => password_hash('ap1Wr1T3rP@S$'),
'ignoredIds' => [
'IDP' => ['spentityid1', 'spentityid2', 'spentityid3',],
'SP' => ['idpentityid1', 'idpentityid2', 'idpentityid3',],
],
/*
* List of IDP and/or SP EntityIDs for which the login statistic will be ignored even
* when requested to be instered into the storage. By default lists are empty
*/
//'ignoredIds' => [
// 'IDP' => ['spentityid1', 'spentityid2', 'spentityid3',],
// 'SP' => ['idpentityid1', 'idpentityid2', 'idpentityid3',],
//],
/*
* Enabled or disables CRON hook (aggregating the stats). By default is enabled.
*/
//'cronEnabled' => false,
];
......@@ -3,6 +3,7 @@
declare(strict_types=1);
use SimpleSAML\Logger;
use SimpleSAML\Module\proxystatistics\Config;
use SimpleSAML\Module\proxystatistics\DatabaseCommand;
/**
......@@ -18,8 +19,13 @@ function proxystatistics_hook_cron(&$croninfo)
return;
}
Logger::info('cron [proxystatistics]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
$config = Config::getInstance();
if (!$config->isCronEnabled()) {
Logger::debug('cron [proxystatistics]: Skipping cron - disabled by configuration');
return;
}
Logger::info('cron [proxystatistics]: Running cron in cron tag [' . $croninfo['tag'] . '] ');
try {
$dbCmd = new DatabaseCommand();
$dbCmd->aggregate();
......
......@@ -43,6 +43,8 @@ class Config
private const IGNORED_IDS = 'ignoredIds';
private const CRON_ENABLED = 'cronEnabled';
private $config;
private $store;
......@@ -67,6 +69,8 @@ class Config
private $ignoredIds;
private $cronEnabled;
private static $instance;
private function __construct()
......@@ -79,6 +83,7 @@ class Config
$this->keepPerUser = $this->config->getIntegerRange(self::KEEP_PER_USER, 31, 1827, 31);
$this->requiredAuthSource = $this->config->getString(self::REQUIRE_AUTH_SOURCE, '');
$this->idAttribute = $this->config->getString(self::USER_ID_ATTRIBUTE, 'uid');
$this->cronEnabled = $this->config->getBoolean(self::CRON_ENABLED, true);
$this->apiWriteEnabled = $this->config->getBoolean(self::API_WRITE_ENABLED, false);
$this->ignoredIds = $this->config->getArray(self::IGNORED_IDS, []);
if ($this->apiWriteEnabled) {
......@@ -172,4 +177,9 @@ class Config
{
return $this->ignoredIds;
}
public function isCronEnabled()
{
return $this->cronEnabled;
}
}