From ef7925f1d14adf205002c561bdb2001177b6dcc4 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sun, 3 Feb 2019 22:54:56 +0100 Subject: [PATCH] Fixes for modules/core --- modules/consentAdmin/hooks/hook_frontpage.php | 3 +- modules/consentAdmin/www/consentAdmin.php | 4 +- modules/core/hooks/hook_frontpage.php | 3 +- modules/core/hooks/hook_sanitycheck.php | 3 +- .../core/lib/Auth/Process/AttributeAdd.php | 6 +- .../core/lib/Auth/Process/AttributeAlter.php | 6 +- .../core/lib/Auth/Process/AttributeCopy.php | 7 +- .../core/lib/Auth/Process/AttributeLimit.php | 9 +- .../core/lib/Auth/Process/AttributeMap.php | 7 +- .../core/lib/Auth/Process/AttributeRealm.php | 6 +- .../lib/Auth/Process/AttributeValueMap.php | 12 ++- modules/core/lib/Auth/Process/Cardinality.php | 6 +- .../lib/Auth/Process/CardinalitySingle.php | 7 +- .../lib/Auth/Process/ExtendIdPSession.php | 5 +- .../core/lib/Auth/Process/GenerateGroups.php | 14 ++- .../core/lib/Auth/Process/LanguageAdaptor.php | 8 +- modules/core/lib/Auth/Process/PHP.php | 10 ++- .../core/lib/Auth/Process/ScopeAttribute.php | 17 ++-- .../lib/Auth/Process/ScopeFromAttribute.php | 14 +-- .../Auth/Process/StatisticsWithAttribute.php | 6 +- modules/core/lib/Auth/Process/TargetedID.php | 9 +- .../lib/Auth/Process/WarnShortSSOInterval.php | 2 +- modules/core/lib/Auth/UserPassBase.php | 16 +++- modules/core/lib/Auth/UserPassOrgBase.php | 11 ++- modules/core/lib/Stats/Output/File.php | 8 +- modules/core/lib/Stats/Output/Log.php | 9 +- .../core/lib/Storage/SQLPermanentStorage.php | 86 ++++++++++++++++++- 27 files changed, 222 insertions(+), 72 deletions(-) diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php index b1903a580..5059384b6 100644 --- a/modules/consentAdmin/hooks/hook_frontpage.php +++ b/modules/consentAdmin/hooks/hook_frontpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add the consentAdmin module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ - function consentAdmin_hook_frontpage(&$links) { assert(is_array($links)); diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index 00716e1e3..51b15b6e9 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -11,7 +11,7 @@ * Author: Mads Freek <freek@ruc.dk>, Jacob Christiansen <jach@wayf.dk> */ -/* +/** * Runs the processing chain and ignores all filter which have user * interaction. * @@ -185,7 +185,7 @@ if ($action !== null && $sp_entityid !== null) { 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin' ); - $translator = $t->getTranslator(); + $translator = $template->getTranslator(); // Get SP metadata $sp_metadata = $metadata->getMetaData($sp_entityid, 'saml20-sp-remote'); diff --git a/modules/core/hooks/hook_frontpage.php b/modules/core/hooks/hook_frontpage.php index d2b6eef9c..cbb1469c0 100644 --- a/modules/core/hooks/hook_frontpage.php +++ b/modules/core/hooks/hook_frontpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add the modinfo module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ - function core_hook_frontpage(&$links) { assert(is_array($links)); diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index ef4af3049..b7701d862 100644 --- a/modules/core/hooks/hook_sanitycheck.php +++ b/modules/core/hooks/hook_sanitycheck.php @@ -1,10 +1,11 @@ <?php + /** * Hook to do sanitycheck * * @param array &$hookinfo hookinfo + * @return void */ - function core_hook_sanitycheck(&$hookinfo) { assert(is_array($hookinfo)); diff --git a/modules/core/lib/Auth/Process/AttributeAdd.php b/modules/core/lib/Auth/Process/AttributeAdd.php index deb3ac310..b56899886 100644 --- a/modules/core/lib/Auth/Process/AttributeAdd.php +++ b/modules/core/lib/Auth/Process/AttributeAdd.php @@ -10,7 +10,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -28,10 +27,10 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -66,6 +65,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter * Add or replace existing attributes with the configured values. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index 0d181a0d7..c8900822a 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -10,7 +10,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Jacob Christiansen, WAYF * @package SimpleSAMLphp */ - class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -46,11 +45,11 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * @throws \SimpleSAML\Error\Exception In case of invalid configuration. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -91,6 +90,7 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter * * @param array &$request The current request. * @throws \SimpleSAML\Error\Exception In case of invalid configuration. + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeCopy.php b/modules/core/lib/Auth/Process/AttributeCopy.php index 1b54da17a..e9fab68d7 100644 --- a/modules/core/lib/Auth/Process/AttributeCopy.php +++ b/modules/core/lib/Auth/Process/AttributeCopy.php @@ -17,7 +17,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * ), * */ - class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -25,13 +24,14 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter */ private $map = []; + /** * Initialize this filter, parse configuration * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -54,6 +54,7 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter * Apply filter to rename attributes. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeLimit.php b/modules/core/lib/Auth/Process/AttributeLimit.php index b90d1b0cd..f0789d9a2 100644 --- a/modules/core/lib/Auth/Process/AttributeLimit.php +++ b/modules/core/lib/Auth/Process/AttributeLimit.php @@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -23,14 +22,15 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter */ private $isDefault = false; + /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use * @throws \SimpleSAML\Error\Exception If invalid configuration is found. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -61,7 +61,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter * Get list of allowed from the SP/IdP config. * * @param array &$request The current request. - * @return array|NULL Array with attribute names, or NULL if no limit is placed. + * @return array|null Array with attribute names, or NULL if no limit is placed. */ private static function getSPIdPAllowed(array &$request) { @@ -83,6 +83,7 @@ class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter * * @param array &$request The current request * @throws \SimpleSAML\Error\Exception If invalid configuration is found. + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php index 7992f8b69..0a648dbcc 100644 --- a/modules/core/lib/Auth/Process/AttributeMap.php +++ b/modules/core/lib/Auth/Process/AttributeMap.php @@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -25,12 +24,12 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter, parse configuration * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * * @throws Exception If the configuration of the filter is wrong. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -73,6 +72,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter * of the SimpleSAMLphp installation, or in the root of a module. * * @throws Exception If the filter could not load the requested attribute map file. + * @return void */ private function loadMapFile($fileName) { @@ -111,6 +111,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter * Apply filter to rename attributes. * * @param array &$request The current request. + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeRealm.php b/modules/core/lib/Auth/Process/AttributeRealm.php index f6366e9fe..c708ece37 100644 --- a/modules/core/lib/Auth/Process/AttributeRealm.php +++ b/modules/core/lib/Auth/Process/AttributeRealm.php @@ -13,15 +13,16 @@ namespace SimpleSAML\Module\core\Auth\Process; class AttributeRealm extends \SimpleSAML\Auth\ProcessingFilter { + /** @var string */ private $attributename = 'realm'; /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); assert(is_array($config)); @@ -37,6 +38,7 @@ class AttributeRealm extends \SimpleSAML\Auth\ProcessingFilter * Add or replace existing attributes with the configured values. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/AttributeValueMap.php b/modules/core/lib/Auth/Process/AttributeValueMap.php index 9979ea66f..189560f0b 100644 --- a/modules/core/lib/Auth/Process/AttributeValueMap.php +++ b/modules/core/lib/Auth/Process/AttributeValueMap.php @@ -8,42 +8,47 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Martin van Es, m7 * @package SimpleSAMLphp */ - class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter { /** * The name of the attribute we should assign values to (ie: the target attribute). + * @var string */ private $targetattribute; /** * The name of the attribute we should create values from. + * @var string */ private $sourceattribute; /** * The required $sourceattribute values and target affiliations. + * @var array */ private $values = []; /** * Whether $sourceattribute should be kept or not. + * @var bool */ private $keep = false; /** * Whether $target attribute values should be replaced by new values or not. + * @var bool */ private $replace = false; + /** * Initialize the filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * @throws \SimpleSAML\Error\Exception If the configuration is not valid. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -99,6 +104,7 @@ class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter * Apply filter. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/Cardinality.php b/modules/core/lib/Auth/Process/Cardinality.php index ac4f1aad1..8e66ad93a 100644 --- a/modules/core/lib/Auth/Process/Cardinality.php +++ b/modules/core/lib/Auth/Process/Cardinality.php @@ -10,7 +10,6 @@ use SimpleSAML\Utils\HttpAdapter; * @author Guy Halse, http://orcid.org/0000-0002-9388-8592 * @package SimpleSAMLphp */ - class Cardinality extends \SimpleSAML\Auth\ProcessingFilter { /** @var array Associative array with the mappings of attribute names. */ @@ -25,12 +24,12 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter, parse configuration. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * @param HTTPAdapter $http HTTP utility service (handles redirects). * @throws \SimpleSAML\Error\Exception */ - public function __construct($config, $reserved, HttpAdapter $http = null) + public function __construct(&$config, $reserved, HttpAdapter $http = null) { parent::__construct($config, $reserved); assert(is_array($config)); @@ -98,6 +97,7 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter * Process this filter * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/CardinalitySingle.php b/modules/core/lib/Auth/Process/CardinalitySingle.php index ac251319b..ca758adec 100644 --- a/modules/core/lib/Auth/Process/CardinalitySingle.php +++ b/modules/core/lib/Auth/Process/CardinalitySingle.php @@ -13,7 +13,6 @@ use SimpleSAML\Utils\HttpAdapter; * @author Guy Halse, http://orcid.org/0000-0002-9388-8592 * @package SimpleSAMLphp */ - class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter { /** @var array Attributes that should be single-valued or we generate an error */ @@ -37,11 +36,11 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter, parse configuration. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * @param HTTPAdapter $http HTTP utility service (handles redirects). */ - public function __construct($config, $reserved, HttpAdapter $http = null) + public function __construct(&$config, $reserved, HttpAdapter $http = null) { parent::__construct($config, $reserved); assert(is_array($config)); @@ -73,10 +72,12 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Process this filter * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php index 92102262b..adfa3fd1e 100644 --- a/modules/core/lib/Auth/Process/ExtendIdPSession.php +++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php @@ -5,9 +5,12 @@ namespace SimpleSAML\Module\core\Auth\Process; /** * Extend IdP session and cookies. */ - class ExtendIdPSession extends \SimpleSAML\Auth\ProcessingFilter { + /** + * @param array &$state + * @return void + */ public function process(&$state) { assert(is_array($state)); diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php index ab9d15aad..0ea05f67c 100644 --- a/modules/core/lib/Auth/Process/GenerateGroups.php +++ b/modules/core/lib/Auth/Process/GenerateGroups.php @@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -19,10 +18,10 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -51,6 +50,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter * Apply filter to add groups attribute. * * @param array &$request The current request + * @return void */ public function process(&$request) { @@ -86,6 +86,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Determine which realm the user belongs to. * @@ -94,7 +95,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter * a realm, NULL will be returned. * * @param array $attributes The attributes of the user. - * @return string|NULL The realm of the user, or NULL if we are unable to determine the realm. + * @return string|null The realm of the user, or NULL if we are unable to determine the realm. */ private static function getRealm($attributes) { @@ -119,6 +120,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter return self::escapeIllegalChars($realm); } + /** * Escape special characters in a string. * @@ -135,6 +137,10 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter return preg_replace_callback( '/([^a-zA-Z0-9_@=.])/', + /** + * @param array $m + * @return string + */ function ($m) { return sprintf("%%%02x", ord($m[1])); }, diff --git a/modules/core/lib/Auth/Process/LanguageAdaptor.php b/modules/core/lib/Auth/Process/LanguageAdaptor.php index 771fb6357..952d800bd 100644 --- a/modules/core/lib/Auth/Process/LanguageAdaptor.php +++ b/modules/core/lib/Auth/Process/LanguageAdaptor.php @@ -8,18 +8,18 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Andreas Ã…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ - class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter { + /** @var string */ private $langattr = 'preferredLanguage'; /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); assert(is_array($config)); @@ -29,12 +29,14 @@ class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Apply filter to add or replace attributes. * * Add or replace existing attributes with the configured values. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php index cd424c76e..bf0504f52 100644 --- a/modules/core/lib/Auth/Process/PHP.php +++ b/modules/core/lib/Auth/Process/PHP.php @@ -21,12 +21,12 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter, parse configuration * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. * * @throws \SimpleSAML\Error\Exception if the 'code' option is not defined. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -43,12 +43,18 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter * Apply the PHP code to the attributes. * * @param array &$request The current request + * @return void */ public function process(&$request) { assert(is_array($request)); assert(array_key_exists('Attributes', $request)); + /** + * @param array &$attributes + * @param array &$state + * @return void + */ $function = function ( /** @scrutinizer ignore-unused */ &$attributes, /** @scrutinizer ignore-unused */ &$state diff --git a/modules/core/lib/Auth/Process/ScopeAttribute.php b/modules/core/lib/Auth/Process/ScopeAttribute.php index 1db7d3c18..f86058c57 100644 --- a/modules/core/lib/Auth/Process/ScopeAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeAttribute.php @@ -38,29 +38,32 @@ class ScopeAttribute extends \SimpleSAML\Auth\ProcessingFilter */ private $onlyIfEmpty = false; + /** * Initialize this filter, parse configuration * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); assert(is_array($config)); - $config = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeAttribute'); + $cfg = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeAttribute'); - $this->scopeAttribute = $config->getString('scopeAttribute'); - $this->sourceAttribute = $config->getString('sourceAttribute'); - $this->targetAttribute = $config->getString('targetAttribute'); - $this->onlyIfEmpty = $config->getBoolean('onlyIfEmpty', false); + $this->scopeAttribute = $cfg->getString('scopeAttribute'); + $this->sourceAttribute = $cfg->getString('sourceAttribute'); + $this->targetAttribute = $cfg->getString('targetAttribute'); + $this->onlyIfEmpty = $cfg->getBoolean('onlyIfEmpty', false); } + /** * Apply this filter to the request. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/ScopeFromAttribute.php b/modules/core/lib/Auth/Process/ScopeFromAttribute.php index b043de9fd..323fc0038 100644 --- a/modules/core/lib/Auth/Process/ScopeFromAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeFromAttribute.php @@ -18,7 +18,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * to add a virtual 'scope' attribute from the eduPersonPrincipalName * attribute. */ - class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -35,26 +34,29 @@ class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter */ private $targetAttribute; + /** * Initialize this filter, parse configuration * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); assert(is_array($config)); - $config = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeFromAttribute'); - $this->targetAttribute = $config->getString('targetAttribute'); - $this->sourceAttribute = $config->getString('sourceAttribute'); + $cfg = \SimpleSAML\Configuration::loadFromArray($config, 'ScopeFromAttribute'); + $this->targetAttribute = $cfg->getString('targetAttribute'); + $this->sourceAttribute = $cfg->getString('sourceAttribute'); } // end constructor + /** * Apply this filter. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php index 86db3063c..7d796ecee 100644 --- a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php +++ b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php @@ -8,7 +8,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Andreas Ã…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ - class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -31,10 +30,10 @@ class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -64,6 +63,7 @@ class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter * Log line. * * @param array &$state The current state. + * @return void */ public function process(&$state) { diff --git a/modules/core/lib/Auth/Process/TargetedID.php b/modules/core/lib/Auth/Process/TargetedID.php index 710fa7f64..46a6b04ff 100644 --- a/modules/core/lib/Auth/Process/TargetedID.php +++ b/modules/core/lib/Auth/Process/TargetedID.php @@ -30,7 +30,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class TargetedID extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -46,13 +45,14 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter */ private $generateNameId = false; + /** * Initialize this filter. * - * @param array $config Configuration information about this filter. + * @param array &$config Configuration information about this filter. * @param mixed $reserved For future use. */ - public function __construct($config, $reserved) + public function __construct(&$config, $reserved) { parent::__construct($config, $reserved); @@ -73,10 +73,12 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Apply filter to add the targeted ID. * * @param array &$state The current state. + * @return void */ public function process(&$state) { @@ -142,6 +144,7 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter $state['Attributes']['eduPersonTargetedID'] = [$nameId]; } + /** * Generate ID from entity metadata. * diff --git a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php index 1d488b9db..a2cbe71e8 100644 --- a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php +++ b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php @@ -7,7 +7,6 @@ namespace SimpleSAML\Module\core\Auth\Process; * * @package SimpleSAMLphp */ - class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -17,6 +16,7 @@ class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter * If it is to short a while since, we will show a warning to the user. * * @param array $state The state of the response. + * @return void */ public function process(&$state) { diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php index 847334466..2730c8cb0 100644 --- a/modules/core/lib/Auth/UserPassBase.php +++ b/modules/core/lib/Auth/UserPassBase.php @@ -11,7 +11,6 @@ namespace SimpleSAML\Module\core\Auth; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - abstract class UserPassBase extends \SimpleSAML\Auth\Source { /** @@ -72,6 +71,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source */ protected $rememberMeChecked = false; + /** * Constructor for this authentication source. * @@ -109,10 +109,12 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source $this->rememberMeChecked = $sspcnf->getBoolean('session.rememberme.checked', false); } + /** * Set forced username. * - * @param string|NULL $forcedUsername The forced username. + * @param string|null $forcedUsername The forced username. + * @return void */ public function setForcedUsername($forcedUsername) { @@ -122,12 +124,14 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source /** * Return login links from configuration + * @return array */ public function getLoginLinks() { return $this->loginLinks; } + /** * Getter for the authsource config option remember.username.enabled * @return bool @@ -137,6 +141,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source return $this->rememberUsernameEnabled; } + /** * Getter for the authsource config option remember.username.checked * @return bool @@ -146,6 +151,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source return $this->rememberUsernameChecked; } + /** * Check if the "remember me" feature is enabled. * @return bool TRUE if enabled, FALSE otherwise. @@ -155,6 +161,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source return $this->rememberMeEnabled; } + /** * Check if the "remember me" checkbox should be checked. * @return bool TRUE if enabled, FALSE otherwise. @@ -164,6 +171,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source return $this->rememberMeChecked; } + /** * Initialize login. * @@ -171,6 +179,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source * login page. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -233,6 +242,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source assert(false); } + /** * Attempt to log in using the given username and password. * @@ -248,6 +258,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source */ abstract protected function login($username, $password); + /** * Handle login request. * @@ -258,6 +269,7 @@ abstract class UserPassBase extends \SimpleSAML\Auth\Source * @param string $authStateId The identifier of the authentication state. * @param string $username The username the user wrote. * @param string $password The password the user wrote. + * @return void */ public static function handleLogin($authStateId, $username, $password) { diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php index 33168524c..6eca0d095 100644 --- a/modules/core/lib/Auth/UserPassOrgBase.php +++ b/modules/core/lib/Auth/UserPassOrgBase.php @@ -13,7 +13,6 @@ namespace SimpleSAML\Module\core\Auth; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source { /** @@ -127,6 +126,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source * If unconfigured, the default is 'none'. * * @param string $usernameOrgMethod The method which should be used. + * @return void */ protected function setUsernameOrgMethod($usernameOrgMethod) { @@ -151,6 +151,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source return $this->usernameOrgMethod; } + /** * Getter for the authsource config option remember.username.enabled * @return bool @@ -160,6 +161,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source return $this->rememberUsernameEnabled; } + /** * Getter for the authsource config option remember.username.checked * @return bool @@ -169,6 +171,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source return $this->rememberUsernameChecked; } + /** * Getter for the authsource config option remember.organization.enabled * @return bool @@ -178,6 +181,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source return $this->rememberOrganizationEnabled; } + /** * Getter for the authsource config option remember.organization.checked * @return bool @@ -187,6 +191,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source return $this->rememberOrganizationChecked; } + /** * Initialize login. * @@ -194,6 +199,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source * login page. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -251,6 +257,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source * @param string $username The username the user wrote. * @param string $password The password the user wrote. * @param string $organization The id of the organization the user chose. + * @return void */ public static function handleLogin($authStateId, $username, $password, $organization) { @@ -301,7 +308,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source * This function is used by the login form to get the available organizations. * * @param string $authStateId The identifier of the authentication state. - * @return array|NULL Array of organizations. NULL if the user must enter the + * @return array|null Array of organizations. NULL if the user must enter the * organization as part of the username. */ public static function listOrganizations($authStateId) diff --git a/modules/core/lib/Stats/Output/File.php b/modules/core/lib/Stats/Output/File.php index cac817c83..fb95e42e7 100644 --- a/modules/core/lib/Stats/Output/File.php +++ b/modules/core/lib/Stats/Output/File.php @@ -7,7 +7,6 @@ namespace SimpleSAML\Module\core\Stats\Output; * * @package SimpleSAMLphp */ - class File extends \SimpleSAML\Stats\Output { /** @@ -24,10 +23,11 @@ class File extends \SimpleSAML\Stats\Output /** * The current file date. - * @var string + * @var string|null */ private $fileDate = null; + /** * Initialize the output. * @@ -44,10 +44,12 @@ class File extends \SimpleSAML\Stats\Output } } + /** * Open a log file. * * @param string $date The date for the log file. + * @return void */ private function openLog($date) { @@ -70,10 +72,12 @@ class File extends \SimpleSAML\Stats\Output $this->fileDate = $date; } + /** * Write a stats event. * * @param array $data The event. + * @return void */ public function emit(array $data) { diff --git a/modules/core/lib/Stats/Output/Log.php b/modules/core/lib/Stats/Output/Log.php index e3eff8666..d4919c579 100644 --- a/modules/core/lib/Stats/Output/Log.php +++ b/modules/core/lib/Stats/Output/Log.php @@ -7,19 +7,20 @@ namespace SimpleSAML\Module\core\Stats\Output; * * @package SimpleSAMLphp */ - class Log extends \SimpleSAML\Stats\Output { /** * The logging function we should call. - * @var callback + * @var callable */ private $logger; + /** * Initialize the output. * * @param \SimpleSAML\Configuration $config The configuration for this output. + * @throws \Exception */ public function __construct(\SimpleSAML\Configuration $config) { @@ -30,10 +31,12 @@ class Log extends \SimpleSAML\Stats\Output } } + /** * Write a stats event. * - * @param string $data The event (as a JSON string). + * @param array $data The event + * @return void */ public function emit(array $data) { diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php index 4360d5e84..0650f7bf2 100644 --- a/modules/core/lib/Storage/SQLPermanentStorage.php +++ b/modules/core/lib/Storage/SQLPermanentStorage.php @@ -14,8 +14,15 @@ namespace SimpleSAML\Module\core\Storage; class SQLPermanentStorage { + /** @var \PDO */ private $db; + + /** + * @param string $name + * @param \SimpleSAML\Configuration|null $config + * @throws \Exception + */ public function __construct($name, $config = null) { if (is_null($config)) { @@ -57,6 +64,15 @@ class SQLPermanentStorage } } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @param mixed $value + * @param int|null $duration + * @return void + */ public function set($type, $key1, $key2, $value, $duration = null) { if ($this->exists($type, $key1, $key2)) { @@ -66,6 +82,15 @@ class SQLPermanentStorage } } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @param mixed $value + * @param int|null $duration + * @return array + */ private function insert($type, $key1, $key2, $value, $duration = null) { $expire = is_null($duration) ? null : (time() + $duration); @@ -82,6 +107,15 @@ class SQLPermanentStorage return $results; } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @param mixed $value + * @param int|null $duration + * @return array + */ private function update($type, $key1, $key2, $value, $duration = null) { $expire = is_null($duration) ? null : (time() + $duration); @@ -97,6 +131,13 @@ class SQLPermanentStorage return $results; } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return array|null + */ public function get($type = null, $key1 = null, $key2 = null) { $conditions = $this->getCondition($type, $key1, $key2); @@ -114,8 +155,13 @@ class SQLPermanentStorage return $res; } - /* + /** * Return the value directly (not in a container) + * + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return array|null */ public function getValue($type = null, $key1 = null, $key2 = null) { @@ -126,6 +172,13 @@ class SQLPermanentStorage return $res['value']; } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return bool + */ public function exists($type, $key1, $key2) { $query = 'SELECT * FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2 LIMIT 1'; @@ -136,6 +189,13 @@ class SQLPermanentStorage return (count($results) == 1); } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return array|false|null + */ public function getList($type = null, $key1 = null, $key2 = null) { $conditions = $this->getCondition($type, $key1, $key2); @@ -154,6 +214,15 @@ class SQLPermanentStorage return $results; } + + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @param string $whichKey + * @throws \Exception + * @return array|null + */ public function getKeys($type = null, $key1 = null, $key2 = null, $whichKey = 'type') { if (!in_array($whichKey, ['key1', 'key2', 'type'], true)) { @@ -178,6 +247,12 @@ class SQLPermanentStorage return $resarray; } + /** + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return bool + */ public function remove($type, $key1, $key2) { $query = 'DELETE FROM data WHERE type = :type AND key1 = :key1 AND key2 = :key2'; @@ -188,6 +263,10 @@ class SQLPermanentStorage return (count($results) == 1); } + + /** + * @return int + */ public function removeExpired() { $query = "DELETE FROM data WHERE expire IS NOT NULL AND expire < :expire"; @@ -199,6 +278,11 @@ class SQLPermanentStorage /** * Create a SQL condition statement based on parameters + * + * @param string $type + * @param mixed $key1 + * @param mixed $key2 + * @return string */ private function getCondition($type = null, $key1 = null, $key2 = null) { -- GitLab