diff options
author | Jaime Pérez <jaime.perez@uninett.no> | 2016-08-10 16:05:00 +0200 |
---|---|---|
committer | Jaime Pérez <jaime.perez@uninett.no> | 2016-08-10 16:05:00 +0200 |
commit | 6c3d49f97b97ca9d7c182fecfd6e4d5d73e9b7d1 (patch) | |
tree | 8caf757e691c70611e996d36c4a3add0e239a7e9 /lib/SimpleSAML | |
parent | 0858c10c8724c5e434fe949b2c9f96719a9de246 (diff) | |
download | simplesamlphp-6c3d49f97b97ca9d7c182fecfd6e4d5d73e9b7d1.zip simplesamlphp-6c3d49f97b97ca9d7c182fecfd6e4d5d73e9b7d1.tar.gz simplesamlphp-6c3d49f97b97ca9d7c182fecfd6e4d5d73e9b7d1.tar.bz2 |
Make the 'debug' configuration option more fine-grained.
Some things, like logging of SAML messages or backtraces, are controlled with the 'debug' configuration option. However, it might be possible that we don't want one while we want the other, but that's impossible with just one option.
This commit allows us to configure debugging options independently, but groupping all of them together. This is particularly useful if we want to log backtraces to debug errors, for example, but we don't want to log SAML messages to keep the privacy of the users. This also allows us to get rid of the 'debug.validatexml' configuration option, and group it with other debug options.
This changes are backwards-compatible. Old and new configurations will work at the same time.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r-- | lib/SimpleSAML/Error/Exception.php | 9 | ||||
-rw-r--r-- | lib/SimpleSAML/Utils/XML.php | 26 |
2 files changed, 28 insertions, 7 deletions
diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index 75ee11f..2227d52 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -198,7 +198,14 @@ class SimpleSAML_Error_Exception extends Exception */ protected function logBacktrace($level = \SimpleSAML\Logger::DEBUG) { - if (!SimpleSAML_Configuration::getInstance()->getBoolean('debug', false)) { + // see if debugging is enabled for backtraces + $debug = SimpleSAML_Configuration::getInstance()->getArrayize('debug', array('backtraces' => false)); + + if (!(in_array('backtraces', $debug, true) // implicitly enabled + || (array_key_exists('backtraces', $debug) && $debug['backtraces'] === true) // explicitly set + // TODO: deprecate the old style and remove it in 2.0 + || (array_key_exists(0, $debug) && $debug[0] === true) // old style 'debug' configuration option + )) { return; } diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 05206ec..abaa005 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -14,7 +14,7 @@ class XML /** * This function performs some sanity checks on XML documents, and optionally validates them against their schema - * if the 'debug.validatexml' option is enabled. A warning will be printed to the log if validation fails. + * if the 'validatexml' debugging option is enabled. A warning will be printed to the log if validation fails. * * @param string $message The SAML document we want to check. * @param string $type The type of document. Can be one of: @@ -41,8 +41,16 @@ class XML throw new \SimpleSAML_Error_Exception('XML contained a doctype declaration.'); } - $enabled = \SimpleSAML_Configuration::getInstance()->getBoolean('debug.validatexml', null); - if (!$enabled) { + // see if debugging is enabled for XML validation + $debug = \SimpleSAML_Configuration::getInstance()->getArrayize('debug', array('validatexml' => false)); + $enabled = \SimpleSAML_Configuration::getInstance()->getBoolean('debug.validatexml', false); + + if (!(in_array('validatexml', $debug, true) // implicitly enabled + || (array_key_exists('validatexml', $debug) && $debug['validatexml'] === true) // explicitly enabled + // TODO: deprecate this option and remove it in 2.0 + || $enabled // old 'debug.validatexml' configuration option + )) { + // XML validation is disabled return; } @@ -84,9 +92,15 @@ class XML throw new \InvalidArgumentException('Invalid input parameters.'); } - $globalConfig = \SimpleSAML_Configuration::getInstance(); - if (!$globalConfig->getBoolean('debug', false)) { - // message debug disabled + // see if debugging is enabled for SAML messages + $debug = \SimpleSAML_Configuration::getInstance()->getArrayize('debug', array('saml' => false)); + + if (!(in_array('saml', $debug, true) // implicitly enabled + || (array_key_exists('saml', $debug) && $debug['saml'] === true) // explicitly enabled + // TODO: deprecate the old style and remove it in 2.0 + || (array_key_exists(0, $debug) && $debug[0] === true) // old style 'debug' + )) { + // debugging messages is disabled return; } |