Skip to content
Snippets Groups Projects
Commit d94cf006 authored by Guy Halse's avatar Guy Halse
Browse files

Differentiate passive requests from others

A more flexible version of the original patch, based on comments from
@thijskh and @jaimeperez. This version will allow you to skip logging
passive requests entirely by setting `skipPassive` in the config, or
alternatively will prefix the log tag with 'passive-'.
parent c7ea4017
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,9 @@ Parameters
`type`
: 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
-------
......
......@@ -16,6 +16,8 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
private $typeTag = 'saml20-idp-SSO';
private $skipPassive = false;
/**
* Initialize this filter.
......@@ -41,6 +43,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
throw new Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.');
}
}
if (array_key_exists('skipPassive', $config)) {
$this->skipPassive = (bool)$config['skipPassive'];
}
}
......@@ -56,10 +62,14 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
$logAttribute = 'NA';
$source = 'NA';
$dest = 'NA';
$isPassive = '';
if(array_key_exists('isPassive', $state) && $state['isPassive'] === true) {
// We have a passive request. Skip logging statistics
return;
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];
......@@ -81,10 +91,10 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
if (!array_key_exists('PreviousSSOTimestamp', $state)) {
// 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