Skip to content
Snippets Groups Projects
Unverified Commit 38553ca1 authored by Thijs Kinkhorst's avatar Thijs Kinkhorst Committed by GitHub
Browse files

Merge pull request #658 from ghalse/patch/passiveStatistics

Skip logging statistics when we have a passive request
parents 285d5c5b d94cf006
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,9 @@ Parameters ...@@ -12,6 +12,9 @@ Parameters
`type` `type`
: The type of the statistics entry. : The type of the statistics entry.
`skipPassive`
: A boolean indicating whether passive requests should be skipped. Defaults to `FALSE`, in which case the type tag is prefixed with 'passive-'.
Example Example
------- -------
......
...@@ -16,6 +16,8 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -16,6 +16,8 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
private $typeTag = 'saml20-idp-SSO'; private $typeTag = 'saml20-idp-SSO';
private $skipPassive = false;
/** /**
* Initialize this filter. * Initialize this filter.
...@@ -41,6 +43,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -41,6 +43,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
throw new Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.'); throw new Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.');
} }
} }
if (array_key_exists('skipPassive', $config)) {
$this->skipPassive = (bool)$config['skipPassive'];
}
} }
...@@ -56,6 +62,15 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -56,6 +62,15 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
$logAttribute = 'NA'; $logAttribute = 'NA';
$source = 'NA'; $source = 'NA';
$dest = 'NA'; $dest = 'NA';
$isPassive = '';
if(array_key_exists('isPassive', $state) && $state['isPassive'] === true) {
if ($this->skipPassive === true) {
// We have a passive request. Skip logging statistics
return;
}
$isPassive = 'passive-';
}
if (array_key_exists($this->attribute, $state['Attributes'])) $logAttribute = $state['Attributes'][$this->attribute][0]; if (array_key_exists($this->attribute, $state['Attributes'])) $logAttribute = $state['Attributes'][$this->attribute][0];
if (array_key_exists('Source', $state)) { if (array_key_exists('Source', $state)) {
...@@ -76,10 +91,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P ...@@ -76,10 +91,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
if (!array_key_exists('PreviousSSOTimestamp', $state)) { if (!array_key_exists('PreviousSSOTimestamp', $state)) {
// The user hasn't authenticated with this SP earlier in this session // The user hasn't authenticated with this SP earlier in this session
SimpleSAML\Logger::stats($this->typeTag . '-first ' . $dest . ' ' . $source . ' ' . $logAttribute); SimpleSAML\Logger::stats($isPassive . $this->typeTag . '-first ' . $dest . ' ' . $source . ' ' . $logAttribute);
} }
SimpleSAML\Logger::stats($this->typeTag . ' ' . $dest . ' ' . $source . ' ' . $logAttribute); SimpleSAML\Logger::stats($isPassive . $this->typeTag . ' ' . $dest . ' ' . $source . ' ' . $logAttribute);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment