diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 51449f95f970297a48f2fe11bfe1278ac43a04f9..8f835f366175bd76753ff00805029bc4ed4fab8b 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -267,7 +267,7 @@ class IdPDisco * * This function finds out which IdP the user has manually chosen, if any. * - * @return string The entity id of the IdP the user has chosen, or null if the user has made no choice. + * @return string|null The entity id of the IdP the user has chosen, or null if the user has made no choice. */ protected function getSelectedIdP() { diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index 0989d11735d49477bc1afa94b24844b21fa620d1..aecba0b96b13d164877e99e285513de1674ef852 100644 --- a/modules/adfs/lib/IdP/ADFS.php +++ b/modules/adfs/lib/IdP/ADFS.php @@ -9,6 +9,11 @@ use SimpleSAML\Utils\Crypto; class ADFS { + /** + * @param \SimpleSAML\IdP $idp + * @throws \Exception + * @return void + */ public static function receiveAuthnRequest(\SimpleSAML\IdP $idp) { try { @@ -41,6 +46,15 @@ class ADFS $idp->handleAuthenticationRequest($state); } + + /** + * @param string $issuer + * @param string $target + * @param string $nameid + * @param array $attributes + * @param int $assertionLifetime + * @return string + */ private static function generateResponse($issuer, $target, $nameid, $attributes, $assertionLifetime) { $issueInstant = \SimpleSAML\Utils\Time::generateTimestamp(); @@ -49,26 +63,7 @@ class ADFS $assertionID = \SimpleSAML\Utils\Random::generateID(); $nameidFormat = 'http://schemas.xmlsoap.org/claims/UPN'; $nameid = htmlspecialchars($nameid); - - $result = <<<MSG -<wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust"> - <wst:RequestedSecurityToken> - <saml:Assertion Issuer="$issuer" IssueInstant="$issueInstant" AssertionID="$assertionID" MinorVersion="1" MajorVersion="1" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"> - <saml:Conditions NotOnOrAfter="$assertionExpire" NotBefore="$notBefore"> - <saml:AudienceRestrictionCondition> - <saml:Audience>$target</saml:Audience> - </saml:AudienceRestrictionCondition> - </saml:Conditions> - <saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:unspecified" AuthenticationInstant="$issueInstant"> - <saml:Subject> - <saml:NameIdentifier Format="$nameidFormat">$nameid</saml:NameIdentifier> - </saml:Subject> - </saml:AuthenticationStatement> - <saml:AttributeStatement> - <saml:Subject> - <saml:NameIdentifier Format="$nameidFormat">$nameid</saml:NameIdentifier> - </saml:Subject> -MSG; + $parsed_attrs = []; foreach ($attributes as $name => $values) { if ((!is_array($values)) || (count($values) == 0)) { @@ -83,31 +78,37 @@ MSG; if ((!isset($value)) || ($value === '')) { continue; } - $value = htmlspecialchars($value); - - $result .= <<<MSG - <saml:Attribute AttributeNamespace="$namespace" AttributeName="$name"> - <saml:AttributeValue>$value</saml:AttributeValue> - </saml:Attribute> -MSG; + $parsed_attrs[] = ['name' => $name, 'namespace' => $namespace, 'value' => htmlspecialchars($value)]; } } - $result .= <<<MSG - </saml:AttributeStatement> - </saml:Assertion> - </wst:RequestedSecurityToken> - <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> - <wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"> - <wsa:Address>$target</wsa:Address> - </wsa:EndpointReference> - </wsp:AppliesTo> -</wst:RequestSecurityTokenResponse> -MSG; - - return $result; + $config = \SimpleSAML\Configuration::getInstance(); + $t = new \SimpleSAML\XHTML\Template($config, 'adfs:generateResponse.twig'); + $twig = $t->getTwig(); + return $twig->render( + 'adfs:generateResponse.twig', + [ + 'issueInstant' => $issueInstant, + 'notBefore' => $notBefore, + 'issuer' => $issuer, + 'nameid' => $nameid, + 'nameidFormat' => $nameidFormat, + 'target' => $target, + 'assertionID' => $assertionID, + 'assertionExpire' => $assertionExpire, + 'parsedAttributes' => $parsed_attrs, + ] + ); } + + /** + * @param string $response + * @param string $key + * @param string $cert + * @param string $algo + * @return string|bool + */ private static function signResponse($response, $key, $cert, $algo) { $objXMLSecDSig = new XMLSecurityDSig(); @@ -134,6 +135,13 @@ MSG; return $responsedom->saveXML(); } + + /** + * @param string $url + * @param string $wresult + * @param string $wctx + * @return void + */ private static function postResponse($url, $wresult, $wctx) { $config = \SimpleSAML\Configuration::getInstance(); @@ -150,8 +158,8 @@ MSG; * Get the metadata of a given hosted ADFS IdP. * * @param string $entityid The entity ID of the hosted ADFS IdP whose metadata we want to fetch. - * * @return array + * * @throws \SimpleSAML\Error\Exception * @throws \SimpleSAML\Error\MetadataNotFound */ @@ -223,7 +231,7 @@ MSG; ); if (!$config->hasValue('OrganizationURL')) { - throw new \SimpleSAMl\Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); + throw new \SimpleSAML\Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); } $metadata['OrganizationURL'] = $config->getLocalizedString('OrganizationURL'); } @@ -271,6 +279,12 @@ MSG; } + /** + * @param array $state + * @return void + * + * @throws \Exception + */ public static function sendResponse(array $state) { $spMetadata = $state["SPMetadata"]; @@ -323,6 +337,12 @@ MSG; ADFS::postResponse($wreply, $wresult, $wctx); } + + /** + * @param \SimpleSAML\IdP $idp + * @param array $state + * @return void + */ public static function sendLogoutResponse(\SimpleSAML\IdP $idp, array $state) { // NB:: we don't know from which SP the logout request came from @@ -332,6 +352,11 @@ MSG; ); } + + /** + * @param \SimpleSAML\IdP $idp + * @return void + */ public static function receiveLogoutMessage(\SimpleSAML\IdP $idp) { // if a redirect is to occur based on wreply, we will redirect to url as @@ -351,7 +376,14 @@ MSG; $idp->handleLogoutRequest($state, $assocId); } - // accepts an association array, and returns a URL that can be accessed to terminate the association + + /** + * Accepts an association array, and returns a URL that can be accessed to terminate the association + * @param \SimpleSAML\IdP $idp + * @param array $association + * @param string $relayState + * @return string + */ public static function getLogoutURL(\SimpleSAML\IdP $idp, array $association, $relayState) { $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); diff --git a/modules/adfs/lib/SAML2/XML/fed/Endpoint.php b/modules/adfs/lib/SAML2/XML/fed/Endpoint.php index d3ac56ad346d423bc21b354243dcaebae6112bb3..46b4940251b14f16e7b4615dca5fcc6e22503396 100644 --- a/modules/adfs/lib/SAML2/XML/fed/Endpoint.php +++ b/modules/adfs/lib/SAML2/XML/fed/Endpoint.php @@ -15,6 +15,8 @@ class Endpoint * * @param \DOMElement $parent The element we should append this endpoint to. * @param string $name The name of the element we should create. + * @param string $address + * @return \DOMElement */ public static function appendXML(\DOMElement $parent, $name, $address) { diff --git a/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php b/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php index de386e9f65dc932d4c112dacc3bfa8e5a5389372..e3fc90e01a78c0fba004267b98dd1af69c29bc93 100644 --- a/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php +++ b/modules/adfs/lib/SAML2/XML/fed/SecurityTokenServiceType.php @@ -20,9 +20,10 @@ class SecurityTokenServiceType extends \SAML2\XML\md\RoleDescriptor /** * The Location of Services. * - * @var string + * @var string|null */ - public $Location; + public $Location = null; + /** * Initialize a SecurityTokenServiceType element. @@ -37,6 +38,7 @@ class SecurityTokenServiceType extends \SAML2\XML\md\RoleDescriptor } } + /** * Convert this SecurityTokenServiceType RoleDescriptor to XML. * @@ -61,7 +63,7 @@ class SecurityTokenServiceType extends \SAML2\XML\md\RoleDescriptor /** * Get the location of this service. * - * @return string The full URL where this service can be reached. + * @return string|null The full URL where this service can be reached. */ public function getLocation() { @@ -73,6 +75,7 @@ class SecurityTokenServiceType extends \SAML2\XML\md\RoleDescriptor * Set the location of this service. * * @param string $location The full URL where this service can be reached. + * @return void */ public function setLocation($location) { diff --git a/modules/adfs/lib/SAML2/XML/fed/TokenTypesOffered.php b/modules/adfs/lib/SAML2/XML/fed/TokenTypesOffered.php index 5df8f3f9cccd17214333621b7800417cb4176187..659628ada5a0d3b4ea91e8ae487d436385fdc4d1 100644 --- a/modules/adfs/lib/SAML2/XML/fed/TokenTypesOffered.php +++ b/modules/adfs/lib/SAML2/XML/fed/TokenTypesOffered.php @@ -14,6 +14,7 @@ class TokenTypesOffered * Add tokentypesoffered to an XML element. * * @param \DOMElement $parent The element we should append this endpoint to. + * @return \DOMElement */ public static function appendXML(\DOMElement $parent) { diff --git a/modules/adfs/templates/generateResponse.twig b/modules/adfs/templates/generateResponse.twig new file mode 100644 index 0000000000000000000000000000000000000000..2d5f9a476b3c0572dde48f0043430c4466719099 --- /dev/null +++ b/modules/adfs/templates/generateResponse.twig @@ -0,0 +1,31 @@ +<wst:RequestSecurityTokenResponse xmlns:wst="http://schemas.xmlsoap.org/ws/2005/02/trust"> + <wst:RequestedSecurityToken> + <saml:Assertion Issuer="{{ issuer }}" IssueInstant="{{ issueInstant }}" AssertionID="{{ assertionID }}" MinorVersion="1" MajorVersion="1" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"> + <saml:Conditions NotOnOrAfter="{{ assertionExpire }}" NotBefore="{{ notBefore }}"> + <saml:AudienceRestrictionCondition> + <saml:Audience>{{ target }}</saml:Audience> + </saml:AudienceRestrictionCondition> + </saml:Conditions> + <saml:AuthenticationStatement AuthenticationMethod="urn:oasis:names:tc:SAML:1.0:am:unspecified" AuthenticationInstant="{{ issueInstant }}"> + <saml:Subject> + <saml:NameIdentifier Format="{{ nameidFormat }}">{{ nameid }}</saml:NameIdentifier> + </saml:Subject> + </saml:AuthenticationStatement> + <saml:AttributeStatement> + <saml:Subject> + <saml:NameIdentifier Format="{{ nameidFormat }}">{{ nameid }}</saml:NameIdentifier> + </saml:Subject> +{% for attr in parsedAttributes %} + <saml:Attribute AttributeNamespace="{{ attr.namespace }}" AttributeName="{{ attr.name }}"> + <saml:AttributeValue>{{ attr.value }}</saml:AttributeValue> + </saml:Attribute> +{% endfor %} + </saml:AttributeStatement> + </saml:Assertion> + </wst:RequestedSecurityToken> + <wsp:AppliesTo xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"> + <wsa:EndpointReference xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"> + <wsa:Address>{{ target }}</wsa:Address> + </wsa:EndpointReference> + </wsp:AppliesTo> +</wst:RequestSecurityTokenResponse> diff --git a/modules/admin/lib/Menu.php b/modules/admin/lib/Menu.php index e4e55250cfda2b9e43a1e5bb8ab58b87298b52a1..c1d87d9597776ca7d533b26fcf2f578072c5fbac 100644 --- a/modules/admin/lib/Menu.php +++ b/modules/admin/lib/Menu.php @@ -51,6 +51,7 @@ final class Menu * @param string $id The identifier of this option. * @param string $url The URL this option points to. * @param string $name The name of the option for display purposes. + * @return void */ public function addOption($id, $url, $name) { diff --git a/modules/admin/lib/TestController.php b/modules/admin/lib/TestController.php index c330c81489d122b8aa66c5a4aad5003b9485bf5e..be7a47033687b9992e23626a10ed78ea3a0407b0 100644 --- a/modules/admin/lib/TestController.php +++ b/modules/admin/lib/TestController.php @@ -45,6 +45,7 @@ class TestController /** * Display the list of available authsources. * + * @param string|null $as * @return \SimpleSAML\XHTML\Template */ public function main(Request $request, $as) @@ -67,7 +68,7 @@ class TestController } if (!$authsource->isAuthenticated()) { - $url = \SimpleSAML\Module::getModuleURL('admin/test/' .$as, []); + $url = \SimpleSAML\Module::getModuleURL('admin/test/'.$as, []); $params = [ 'ErrorURL' => $url, 'ReturnTo' => $url, @@ -99,6 +100,11 @@ class TestController } + /** + * @param \SimpleSAML\XHTML\Template $t + * @param \SAML2\XML\saml\NameID $nameId + * @return string + */ private function getNameIDHTML(\SimpleSAML\XHTML\Template $t, \SAML2\XML\saml\NameID $nameId) { $result = ''; @@ -126,6 +132,12 @@ class TestController } + /** + * @param \SimpleSAML\XHTML\Template $t + * @param array $attributes + * @param string $nameParent + * @return string + */ private function getAttributesHTML(\SimpleSAML\XHTML\Template $t, $attributes, $nameParent) { $alternate = ['pure-table-odd', 'pure-table-even']; @@ -197,6 +209,11 @@ class TestController return $str; } + + /** + * @param array|string $attr + * @return string + */ private function present_list($attr) { if (is_array($attr) && count($attr) > 1) { @@ -211,6 +228,11 @@ class TestController } } + + /** + * @param array|string $attr + * @return string + */ private function present_assoc($attr) { if (is_array($attr)) { @@ -225,6 +247,12 @@ class TestController } } + + /** + * @param \SimpleSAML\Locale\Translate $t + * @param \SAML2\XML\saml\NameID $nameID + * @return string + */ private function present_eptid(\SimpleSAML\Locale\Translate $t, \SAML2\XML\saml\NameID $nameID) { $eptid = [ diff --git a/modules/authX509/lib/Auth/Process/ExpiryWarning.php b/modules/authX509/lib/Auth/Process/ExpiryWarning.php index 1b9c1ca8753b5dc95ae1bb3a6830245a400e45f7..9ef69aeb976d945157b1f187a4e81ea7cd8259fd 100644 --- a/modules/authX509/lib/Auth/Process/ExpiryWarning.php +++ b/modules/authX509/lib/Auth/Process/ExpiryWarning.php @@ -19,8 +19,10 @@ namespace SimpleSAML\Module\authX509\Auth\Process; class ExpiryWarning extends \SimpleSAML\Auth\ProcessingFilter { - + /** @var int */ private $warndaysbefore = 30; + + /** @var string|null */ private $renewurl = null; /** @@ -57,6 +59,7 @@ class ExpiryWarning extends \SimpleSAML\Auth\ProcessingFilter * is informed about the expiry date of his/her certificate. * * @param array $state The state of the response. + * @return void */ public function process(&$state) { diff --git a/modules/authX509/lib/Auth/Source/X509userCert.php b/modules/authX509/lib/Auth/Source/X509userCert.php index 4605c0ee97e4b19e95909e81c2ab255ee7922254..7739cbdb76bca2b6a4e2c9de817c7d15e6b4829d 100644 --- a/modules/authX509/lib/Auth/Source/X509userCert.php +++ b/modules/authX509/lib/Auth/Source/X509userCert.php @@ -13,18 +13,21 @@ class X509userCert extends \SimpleSAML\Auth\Source { /** * x509 attributes to use from the certificate for searching the user in the LDAP directory. + * @var array */ private $x509attributes = ['UID' => 'uid']; /** * LDAP attribute containing the user certificate. + * This can be set to NULL to avoid looking up the certificate in LDAP + * @var array|null */ private $ldapusercert = ['userCertificate;binary']; /** - * LDAPConfigHelper object + * @var \SimpleSAML\Module\ldap\ConfigHelper */ private $ldapcf; @@ -56,8 +59,6 @@ class X509userCert extends \SimpleSAML\Auth\Source $config, 'Authentication source '.var_export($this->authId, true) ); - - return; } @@ -67,6 +68,7 @@ class X509userCert extends \SimpleSAML\Auth\Source * This function can be overloaded by a child authentication class that wish to perform some operations on failure. * * @param array &$state Information about the current authentication. + * @return void */ public function authFailed(&$state) { @@ -89,6 +91,7 @@ class X509userCert extends \SimpleSAML\Auth\Source * page. On failure, The authX509:X509error.php template is loaded. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -199,12 +202,12 @@ class X509userCert extends \SimpleSAML\Auth\Source * This function can be overloaded by a child authentication class that wish to perform some operations after login. * * @param array &$state Information about the current authentication. + * @return void */ public function authSuccesful(&$state) { \SimpleSAML\Auth\Source::completeAuth($state); assert(false); // should never be reached - return; } } diff --git a/modules/authX509/templates/X509error.php b/modules/authX509/templates/X509error.php index b7f8d42802a9a48e5923fd52e0d577909e409dd2..5db087b3adb7a9537add780cc47123b877f29d48 100644 --- a/modules/authX509/templates/X509error.php +++ b/modules/authX509/templates/X509error.php @@ -1,4 +1,5 @@ <?php + $this->data['header'] = $this->t('{authX509:X509error:certificate_header}'); $this->includeAtTemplateBase('includes/header.php'); diff --git a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php index 42ef300f39b3c68bdbb23e1a1ae7a89620e707ef..b6e7896715bcbe39cf21161d33ab01e6f1f28875 100644 --- a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php +++ b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php @@ -52,6 +52,7 @@ class OTP2YubiPrefix extends \SimpleSAML\Auth\ProcessingFilter * a 'yubiPrefix' attribute that leaves out the dynamic part. * * @param array &$state The state we should update. + * @return void */ public function process(&$state) { diff --git a/modules/authYubiKey/lib/Auth/Source/YubiKey.php b/modules/authYubiKey/lib/Auth/Source/YubiKey.php index 65ddf84906d3de16f15fc0f04efc73100fe2cb0e..864f595cbe658ce58ce19e81dd6d958b9c970566 100644 --- a/modules/authYubiKey/lib/Auth/Source/YubiKey.php +++ b/modules/authYubiKey/lib/Auth/Source/YubiKey.php @@ -62,10 +62,14 @@ class YubiKey extends \SimpleSAML\Auth\Source /** * The client id/key for use with the Auth_Yubico PHP module. + * @var string */ private $yubi_id; + + /** @var string */ private $yubi_key; + /** * Constructor for this authentication source. * @@ -97,6 +101,7 @@ class YubiKey extends \SimpleSAML\Auth\Source * login page. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -162,8 +167,12 @@ class YubiKey extends \SimpleSAML\Auth\Source return null; } + /** * Return the user id part of a one time passord + * + * @param string $otp + * @return string */ public static function getYubiKeyPrefix($otp) { @@ -171,6 +180,7 @@ class YubiKey extends \SimpleSAML\Auth\Source return $uid; } + /** * Attempt to log in using the given username and password. * diff --git a/modules/authYubiKey/libextinc/Yubico.php b/modules/authYubiKey/libextinc/Yubico.php index d6f4c709aafe84ea19f5ff1a6724a8b322d49c59..d222f6b67e07a18c6b045a26cef2c7623fead10d 100644 --- a/modules/authYubiKey/libextinc/Yubico.php +++ b/modules/authYubiKey/libextinc/Yubico.php @@ -125,9 +125,11 @@ class Auth_Yubico // Support https $url = "https://api.yubico.com/wsapi/verify?".$parameters; + /** @var string $responseMsg */ $responseMsg = \SimpleSAML\Utils\HTTP::fetch($url); - if (!preg_match("/status=([a-zA-Z0-9_]+)/", $responseMsg, $out)) { + $out = []; + if (preg_match("/status=([a-zA-Z0-9_]+)/", $responseMsg, $out) !== 1) { throw new Exception('Could not parse response'); } diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index aa1a23efb24e0139820037d699d1809a0d82b509..d83380497902868026295ea30860d8e153ae7a44 100644 --- a/modules/authfacebook/extlibinc/base_facebook.php +++ b/modules/authfacebook/extlibinc/base_facebook.php @@ -170,25 +170,27 @@ abstract class BaseFacebook /** * The ID of the Facebook user, or 0 if the user is logged out. * - * @var integer + * @var integer|string|null */ - protected $user; + protected $user = null; /** * The data from the signed_request token. + * @var array|null */ - protected $signedRequest; + protected $signedRequest = null; /** * A CSRF state variable to assist in the defense against CSRF attacks. + * @var string|null */ - protected $state; + protected $state = null; /** * The OAuth access token received in exchange for a valid authorization * code. null means the access token has yet to be determined. * - * @var string + * @var string|null */ protected $accessToken = null; @@ -402,7 +404,7 @@ abstract class BaseFacebook * access token if a valid user access token wasn't available. Subsequent * calls return whatever the first call returned. * - * @return string The access token + * @return string|null The access token */ public function getAccessToken() { @@ -495,7 +497,7 @@ abstract class BaseFacebook * Retrieve the signed request, either from a request parameter or, * if not present, from a cookie. * - * @return array the signed request, if available, or null otherwise. + * @return array|null the signed request, if available, or null otherwise. */ public function getSignedRequest() { @@ -517,7 +519,7 @@ abstract class BaseFacebook * Get the UID of the connected user, or 0 * if the Facebook user is not connected. * - * @return string the UID if available. + * @return string|int the UID if available. */ public function getUser() { @@ -560,7 +562,7 @@ abstract class BaseFacebook return 0; } - $user = $this->getPersistentData('user_id', $default = 0); + $user = $this->getPersistentData('user_id', $default = false); $persisted_access_token = $this->getPersistentData('access_token'); // use access_token to fetch user id if we have a user access_token, or if @@ -787,6 +789,7 @@ abstract class BaseFacebook * either logged in to Facebook or has granted an offline access permission. * * @param string $code An authorization code. + * @param string|null $redirect_uri * @return mixed An access token exchanged for the authorization code, or * false if an access token could not be generated. */ @@ -893,7 +896,7 @@ abstract class BaseFacebook * Invoke the Graph API. * * @param string $path The path (required) - * @param string $method The http method (default 'GET') + * @param array|string $method The http method (default 'GET') * @param array $params The query/post data * * @return mixed The decoded response object @@ -937,7 +940,7 @@ abstract class BaseFacebook * @param string $url The path (required) * @param array $params The query/post data * - * @return string The decoded response object + * @return string|null The decoded response object * @throws FacebookApiException */ protected function _oauthRequest($url, $params) @@ -963,13 +966,13 @@ abstract class BaseFacebook * * @param string $url The URL to make the request to * @param array $params The parameters to use for the POST body - * @param CurlHandler $ch Initialized curl handle + * @param resource|null $ch Initialized curl handle * - * @return string The response text + * @return string|true The response text */ protected function makeRequest($url, $params, $ch = null) { - if (!$ch) { + if ($ch === null) { $ch = curl_init(); } @@ -1039,7 +1042,7 @@ abstract class BaseFacebook * Parses a signed_request and validates the signature. * * @param string $signed_request A signed token - * @return array The payload inside it or null if the sig is wrong + * @return array|null The payload inside it or null if the sig is wrong */ protected function parseSignedRequest($signed_request) { @@ -1067,7 +1070,7 @@ abstract class BaseFacebook /** * Makes a signed_request blob using the given data. * - * @param $data array The data array. + * @param array $data The data array. * @return string The signed request. */ protected function makeSignedRequest($data) @@ -1089,7 +1092,7 @@ abstract class BaseFacebook /** * Build the URL for api given parameters. * - * @param $method String the method name. + * @param string $method String the method name. * @return string The URL for the given parameters */ protected function getApiUrl($method) @@ -1169,9 +1172,9 @@ abstract class BaseFacebook /** * Build the URL for given domain alias, path and parameters. * - * @param $name string The name of the domain - * @param $path string Optional path (without a leading slash) - * @param $params array Optional query parameters + * @param string $name The name of the domain + * @param string $path Optional path (without a leading slash) + * @param array $params Optional query parameters * * @return string The URL for the given parameters */ @@ -1191,6 +1194,9 @@ abstract class BaseFacebook return $url; } + /** + * @return string + */ protected function getHttpHost() { if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_HOST'])) { @@ -1199,6 +1205,9 @@ abstract class BaseFacebook return $_SERVER['HTTP_HOST']; } + /** + * @return string + */ protected function getHttpProtocol() { if ($this->trustForwarded && isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { @@ -1220,6 +1229,7 @@ abstract class BaseFacebook /** * Get the base domain used for the cookie. + * @return string */ protected function getBaseDomain() { @@ -1261,8 +1271,9 @@ abstract class BaseFacebook * because the access token is no longer valid. If that is * the case, then we destroy the session. * - * @param $result array A record storing the error message returned + * @param array $result A record storing the error message returned * by a failed API call. + * @return void */ protected function throwAPIException($result) { @@ -1292,6 +1303,7 @@ abstract class BaseFacebook * Prints to the error log if you aren't in command line mode. * * @param string $msg Log message + * @return void */ protected static function errorLog($msg) { @@ -1336,6 +1348,7 @@ abstract class BaseFacebook /** * Destroy the current session + * @return void */ public function destroySession() { @@ -1395,6 +1408,11 @@ abstract class BaseFacebook return $metadata; } + /** + * @param string $big + * @param string $small + * @return string|bool + */ protected static function isAllowedDomain($big, $small) { if ($big === $small) { @@ -1403,6 +1421,11 @@ abstract class BaseFacebook return self::endsWith($big, '.'.$small); } + /** + * @param string $big + * @param string $small + * @return string|bool + */ protected static function endsWith($big, $small) { $len = strlen($small); @@ -1427,7 +1450,7 @@ abstract class BaseFacebook * getPersistentData($key) return $value. This call may be in another request. * * @param string $key - * @param array $value + * @param mixed $value * * @return void */ diff --git a/modules/authfacebook/lib/Auth/Source/Facebook.php b/modules/authfacebook/lib/Auth/Source/Facebook.php index a2bee6a7a368d460d2998aef16d72810a834ab97..69dd4624bc908758a4fa92936a9c8c3aae5c2dcc 100644 --- a/modules/authfacebook/lib/Auth/Source/Facebook.php +++ b/modules/authfacebook/lib/Auth/Source/Facebook.php @@ -88,6 +88,7 @@ class Facebook extends \SimpleSAML\Auth\Source * Log-in using Facebook platform * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -111,6 +112,10 @@ class Facebook extends \SimpleSAML\Auth\Source } + /** + * @param array &$state + * @return void + */ public function finalStep(&$state) { assert(is_array($state)); diff --git a/modules/authfacebook/lib/Facebook.php b/modules/authfacebook/lib/Facebook.php index cf68d348a52d3530b98879a284977efc120cbf61..c39183c08e42efaae0dfd8f51d1fe715d5a888d9 100644 --- a/modules/authfacebook/lib/Facebook.php +++ b/modules/authfacebook/lib/Facebook.php @@ -17,14 +17,24 @@ class Facebook extends \BaseFacebook // expiration will trump this const FBSS_COOKIE_EXPIRE = 31556926; // 1 year - // Stores the shared session ID if one is set + /** + * Stores the shared session ID if one is set + * @var string + */ protected $sharedSessionID; - // SimpleSAMLphp state array + /** + * SimpleSAMLphp state array + * @var array + */ protected $ssp_state; - // \SimpleSAML\Auth\State - protected $state; + /** @var string|null */ + protected $state = null; + + /** @var array */ + protected static $kSupportedKeys = ['state', 'code', 'access_token', 'user_id']; + /** * Identical to the parent constructor, except that @@ -32,7 +42,8 @@ class Facebook extends \BaseFacebook * access token if during the course of execution * we discover them. * - * @param Array $config the application configuration. Additionally + * @param array $config the application configuration. Additionally + * @param array &$ssp_state * accepts "sharedSession" as a boolean to turn on a secondary * cookie for environments with a shared session (that is, your app * shares the domain with other apps). @@ -48,8 +59,10 @@ class Facebook extends \BaseFacebook } } - protected static $kSupportedKeys = ['state', 'code', 'access_token', 'user_id']; + /** + * @return void + */ protected function initSharedSession() { $cookie_name = $this->getSharedSessionCookieName(); @@ -87,11 +100,16 @@ class Facebook extends \BaseFacebook } } + /** * Provides the implementations of the inherited abstract * methods. The implementation uses PHP sessions to maintain * a store for authorization codes, user ids, CSRF states, and * access tokens. + * + * @param string $key + * @param mixed $value + * @return void */ protected function setPersistentData($key, $value) { @@ -104,6 +122,12 @@ class Facebook extends \BaseFacebook $this->ssp_state[$session_var_name] = $value; } + + /** + * @param string $key + * @param bool $default + * @return mixed + */ protected function getPersistentData($key, $default = false) { if (!in_array($key, self::$kSupportedKeys)) { @@ -115,6 +139,11 @@ class Facebook extends \BaseFacebook return isset($this->ssp_state[$session_var_name]) ? $this->ssp_state[$session_var_name] : $default; } + + /** + * @param string $key + * @return void + */ protected function clearPersistentData($key) { if (!in_array($key, self::$kSupportedKeys)) { @@ -128,6 +157,10 @@ class Facebook extends \BaseFacebook } } + + /** + * @return void + */ protected function clearAllPersistentData() { foreach (self::$kSupportedKeys as $key) { @@ -138,6 +171,10 @@ class Facebook extends \BaseFacebook } } + + /** + * @return void + */ protected function deleteSharedSessionCookie() { $cookie_name = $this->getSharedSessionCookieName(); @@ -146,11 +183,20 @@ class Facebook extends \BaseFacebook setcookie($cookie_name, '', 1, '/', '.'.$base_domain); } + + /** + * @return string + */ protected function getSharedSessionCookieName() { return self::FBSS_COOKIE_NAME.'_'.$this->getAppId(); } + + /** + * @param string $key + * @return string + */ protected function constructSessionVariableName($key) { $parts = ['authfacebook:authdata:fb', $this->getAppId(), $key]; @@ -160,6 +206,10 @@ class Facebook extends \BaseFacebook return implode('_', $parts); } + + /** + * @return void + */ protected function establishCSRFTokenState() { if ($this->state === null) { diff --git a/modules/authfacebook/www/linkback.php b/modules/authfacebook/www/linkback.php index 6a24590194e4ec6a3e390386b5f937853fec4e86..2b95301f0a1f7f5451bf9ad0d86c21cd695b9b2f 100644 --- a/modules/authfacebook/www/linkback.php +++ b/modules/authfacebook/www/linkback.php @@ -27,6 +27,7 @@ if (!array_key_exists(\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTH } $sourceId = $state[\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTHID]; +/** @var \SimpleSAML\Module\authfacebook\Auth\Source\Facebook|null $source */ $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { throw new \SimpleSAML\Error\BadRequest( diff --git a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php index 0716d8663f296366c247fb46ae22801ccab9b6cf..f270834c73b5b47e20aad2a478264c763e03d2fa 100644 --- a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php +++ b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php @@ -23,8 +23,13 @@ class LinkedIn extends \SimpleSAML\Auth\Source */ const AUTHID = 'authlinkedin:AuthId'; + /** @var string */ private $key; + + /** @var string */ private $secret; + + /** @var string */ private $attributes; @@ -33,6 +38,7 @@ class LinkedIn extends \SimpleSAML\Auth\Source * * @param array $info Information about this authentication source. * @param array $config Configuration. + * @throws \Exception */ public function __construct($info, $config) { @@ -68,6 +74,7 @@ class LinkedIn extends \SimpleSAML\Auth\Source * Documentation at: http://developer.linkedin.com/docs/DOC-1008 * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -104,6 +111,10 @@ class LinkedIn extends \SimpleSAML\Auth\Source } + /** + * @param array &$state + * @return void + */ public function finalStep(&$state) { $requestToken = $state['authlinkedin:requestToken']; diff --git a/modules/authlinkedin/www/linkback.php b/modules/authlinkedin/www/linkback.php index 157525ab29b505ada5462f70bd368fb4b74495c8..922e157fccc47364a60220ab511bf1366cae153b 100644 --- a/modules/authlinkedin/www/linkback.php +++ b/modules/authlinkedin/www/linkback.php @@ -23,6 +23,7 @@ if (array_key_exists('oauth_verifier', $_REQUEST)) { assert(array_key_exists(\SimpleSAML\Module\authlinkedin\Auth\Source\LinkedIn::AUTHID, $state)); $sourceId = $state[\SimpleSAML\Module\authlinkedin\Auth\Source\LinkedIn::AUTHID]; +/** @var \SimpleSAML\Module\authlinkedin\Auth\Source\LinkedIn|null $source */ $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { throw new \Exception('Could not find authentication source with id '.$sourceId); diff --git a/modules/authorize/lib/Auth/Process/Authorize.php b/modules/authorize/lib/Auth/Process/Authorize.php index e40cbaf36274373fc66bb2694d84bfa79cc3ea18..8185e03c0d111b5ef3667d2b5707edeb63e6c77a 100644 --- a/modules/authorize/lib/Auth/Process/Authorize.php +++ b/modules/authorize/lib/Auth/Process/Authorize.php @@ -99,6 +99,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter * Apply filter to validate attributes. * * @param array &$request The current request + * @return void */ public function process(&$request) { @@ -108,7 +109,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter $attributes = &$request['Attributes']; // Store the rejection message array in the $request - if(!empty($this->reject_msg)) { + if (!empty($this->reject_msg)) { $request['authprocAuthorize_reject_msg'] = $this->reject_msg; } @@ -149,6 +150,7 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter * permission logic. * * @param array $request + * @return void */ protected function unauthorized(&$request) { diff --git a/modules/authorize/templates/authorize_403.php b/modules/authorize/templates/authorize_403.php index d4d5b79a09c0f49916ab6af16a9def6da26e8626..0c102a1bc28d60bf2581f480328a6bd9348e998d 100644 --- a/modules/authorize/templates/authorize_403.php +++ b/modules/authorize/templates/authorize_403.php @@ -14,7 +14,7 @@ $this->data['403_header'] = $this->t('{authorize:Authorize:403_header}'); $this->data['403_text'] = $this->t('{authorize:Authorize:403_text}'); if (array_key_exists('reject_msg', $this->data)) { - if(isset($this->data['reject_msg'][$this->getLanguage()])) { + if (isset($this->data['reject_msg'][$this->getLanguage()])) { $this->data['403_text'] = $this->data['reject_msg'][$this->getLanguage()]; } } diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php index 19ff725800132cef6758cdaf9366a9b1a96f0f35..6a0a03e99d92d152a968e1897399d338f445a2e4 100644 --- a/modules/authtwitter/lib/Auth/Source/Twitter.php +++ b/modules/authtwitter/lib/Auth/Source/Twitter.php @@ -72,6 +72,7 @@ class Twitter extends \SimpleSAML\Auth\Source * Log-in using Twitter platform * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -103,6 +104,11 @@ class Twitter extends \SimpleSAML\Auth\Source $consumer->getAuthorizeRequest($url, $requestToken); } + + /** + * @param array &$state + * @return void + */ public function finalStep(&$state) { $requestToken = $state['authtwitter:authdata:requestToken']; diff --git a/modules/authtwitter/www/linkback.php b/modules/authtwitter/www/linkback.php index cbeed68a7be8028ae0e217cadb15d199948b56af..78c0382a42b9ad56acd10d12c6875eba7297993e 100644 --- a/modules/authtwitter/www/linkback.php +++ b/modules/authtwitter/www/linkback.php @@ -20,6 +20,7 @@ if (!array_key_exists(\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID } $sourceId = $state[\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID]; +/** @var \SimpleSAML\Module\authtwitter\Auth\Source\Twitter|null $source */ $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { throw new \SimpleSAML\Error\BadRequest( diff --git a/modules/authwindowslive/lib/Auth/Source/LiveID.php b/modules/authwindowslive/lib/Auth/Source/LiveID.php index 3f4dc5446d3cd64b7020d66f2fd4e821736a2d58..1b64be62f09cdfe8cf18762133a34ffaad069342 100644 --- a/modules/authwindowslive/lib/Auth/Source/LiveID.php +++ b/modules/authwindowslive/lib/Auth/Source/LiveID.php @@ -21,9 +21,13 @@ class LiveID extends \SimpleSAML\Auth\Source */ const AUTHID = 'authwindowslive:AuthId'; + /** @var string */ private $key; + + /** @var string */ private $secret; + /** * Constructor for this authentication source. * @@ -57,6 +61,7 @@ class LiveID extends \SimpleSAML\Auth\Source * Log-in using LiveID platform * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -85,8 +90,8 @@ class LiveID extends \SimpleSAML\Auth\Source } /** - * @param $state - * + * @param array &$state + * @return void * @throws \Exception */ public function finalStep(&$state) diff --git a/modules/authwindowslive/www/linkback.php b/modules/authwindowslive/www/linkback.php index 758bdd215f6b490ef11b8b554e1cf2914929595b..3800cd180b8440417cece31febaa91de31de20c3 100644 --- a/modules/authwindowslive/www/linkback.php +++ b/modules/authwindowslive/www/linkback.php @@ -39,6 +39,7 @@ if (array_key_exists('code', $_REQUEST)) { assert(array_key_exists(\SimpleSAML\Module\authwindowslive\Auth\Source\LiveID::AUTHID, $state)); $sourceId = $state[\SimpleSAML\Module\authwindowslive\Auth\Source\LiveID::AUTHID]; +/** @var \SimpleSAML\Module\authwindowslive\Auth\Source\LiveID|null $source */ $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { throw new \Exception('Could not find authentication source with id '.$sourceId); diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php index 08f153c130f4a0ae2b545ba3e950f369f06f9d64..e4a231327ae88937d0707574a61fdadde028ba9d 100644 --- a/modules/cas/lib/Auth/Source/CAS.php +++ b/modules/cas/lib/Auth/Source/CAS.php @@ -29,7 +29,7 @@ class CAS extends \SimpleSAML\Auth\Source private $ldapConfig; /** - * @var cas configuration + * @var array cas configuration */ private $casConfig; @@ -178,6 +178,7 @@ class CAS extends \SimpleSAML\Auth\Source /** * Called by linkback, to finish validate/ finish logging in. * @param array $state + * @return void */ public function finalStep(&$state) { @@ -213,6 +214,7 @@ class CAS extends \SimpleSAML\Auth\Source * Log-in using cas * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -241,6 +243,7 @@ class CAS extends \SimpleSAML\Auth\Source * showing the user a page, or redirecting, this function should return. * * @param array &$state Information about the current logout operation. + * @return void */ public function logout(&$state) { diff --git a/modules/cas/www/linkback.php b/modules/cas/www/linkback.php index 366583c8a7e572099e66cfaad716faaa084f3788..0b062a060b0a7841ce1d867dba5a0939c723e2be 100644 --- a/modules/cas/www/linkback.php +++ b/modules/cas/www/linkback.php @@ -18,6 +18,7 @@ $state['cas:ticket'] = (string) $_GET['ticket']; assert(array_key_exists(\SimpleSAML\Module\cas\Auth\Source\CAS::AUTHID, $state)); $sourceId = $state[\SimpleSAML\Module\cas\Auth\Source\CAS::AUTHID]; +/** @var \SimpleSAML\Module\cas\Auth\Source\CAS|null $source */ $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { throw new \Exception('Could not find authentication source with id '.$sourceId); diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index f5b6bfc8105732dccc4ed98a80cd2075de87afb1..6af1b63dd867f19ae8b6f6560e7896c2021f83d4 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -383,7 +383,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter * Create a hash value for the attributes that changes when attributes are added or removed. If the attribute * values are included in the hash, the hash will change if the values change. * - * @param string $attributes The attributes. + * @param array $attributes The attributes. * @param bool $includeValues Whether or not to include the attribute value in the generation of the hash. * * @return string SHA1 of the user id, source id, destination id and salt. diff --git a/modules/consent/lib/Logout.php b/modules/consent/lib/Logout.php index f82961ee3d487f34ca42225d7f400157f1f57894..0bfcf338528e36fd1ce35f66eece6493c3b99d0c 100644 --- a/modules/consent/lib/Logout.php +++ b/modules/consent/lib/Logout.php @@ -10,6 +10,11 @@ namespace SimpleSAML\Module\consent; class Logout { + /** + * @param \SimpleSAML\IdP $idp + * @param array $state + * @return void + */ public static function postLogout(\SimpleSAML\IdP $idp, array $state) { $url = \SimpleSAML\Module::getModuleURL('consent/logout_completed.php'); diff --git a/modules/consentAdmin/hooks/hook_configpage.php b/modules/consentAdmin/hooks/hook_configpage.php index 2ea75afb1108e123dbe9c064e97d75e967cc672c..fc9384f983097fe93d335834b7e9a33c8281ae60 100644 --- a/modules/consentAdmin/hooks/hook_configpage.php +++ b/modules/consentAdmin/hooks/hook_configpage.php @@ -3,8 +3,8 @@ * Hook to add the consentAdmin module to the config page. * * @param \SimpleSAML\XHTML\Template $template The template that we should alter in this hook. + * @return void */ - function consentAdmin_hook_configpage(\SimpleSAML\XHTML\Template &$template) { $template->data['links']['consentAdmin'] = [ diff --git a/modules/consentAdmin/hooks/hook_frontpage.php b/modules/consentAdmin/hooks/hook_frontpage.php index b1903a580ab08beeed8ecc3b742b09a1ea3cf67a..5059384b6e6f1c232cf9cd62df046b2175ffb184 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 0fe5d3d795cb0debeeb96ee97bba5e16a6b70453..5a00ce4e476f7fd142d6c590dadabfb5a2a0035c 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -11,9 +11,19 @@ * Author: Mads Freek <freek@ruc.dk>, Jacob Christiansen <jach@wayf.dk> */ -/* +/** * Runs the processing chain and ignores all filter which have user * interaction. + * + * @param array $idp_metadata + * @param string $source + * @param array $sp_metadata + * @param string $sp_entityid + * @param array $attributes + * @param string $userid + * @param bool $hashAttributes + * @param array $excludeAttributes + * @return array */ function driveProcessingChain( $idp_metadata, @@ -107,7 +117,6 @@ $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); * Get IdP id and metadata */ - $idp_entityid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); $idp_metadata = $metadata->getMetaData($idp_entityid, 'saml20-idp-hosted'); @@ -176,6 +185,7 @@ if ($action !== null && $sp_entityid !== null) { 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin' ); + $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 d2b6eef9c0b15aa8d0020dd8cdd29472c1cf2edf..cbb1469c03a63179cd4d405d0e637b330f90e7f7 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 ef4af3049f99106c63bac2cbcad9d7f4a9fe578b..b7701d862cc462e09cdc5adfb281465793a6b4a1 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 deb3ac310c4f1e8d6d4152080473dacaadc39814..b568998866cb160270989d141257ab1ac077fd18 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 0d181a0d7cd45700556bd4d121cf4c90da087704..c8900822a025ac632cdd7e31289a0d8a2280fda4 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 1b54da17ae14826a5c6abe82c83b87fef681c6a3..e9fab68d73790c93ca371a394787b247638f39fc 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 b90d1b0cdedad5ec6f3d34264254d30ec8128744..f0789d9a2dda31346619b1d1af532caf53a8f67c 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 7992f8b69d45163974ebc21096e7bdacec83087b..0a648dbccbfd5583545feb2cae627de0e48add48 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 f6366e9fe66abb5cd0cd219d173dae82ba3cc7fc..c708ece37927747c46f44aff2e1637aa2ecf0692 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 9979ea66f27b8d5768c89c122ec10dddbc6be795..189560f0bae0e0f2d66e8a8f6da6fc8ef6e12960 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 ac4f1aad1edca4ca87a0ab54c71b40fe28fe9902..8e66ad93a7a8af6fa23c40092fec63068af149e4 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 ac251319beef8ffe40c2e15e3da4db498bd4798b..ca758adec8c0ec7ec95b2911212eb7e4ba11df89 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 92102262b572ee8d0b0bfb07e35ef011c106c9a8..adfa3fd1e547f2e5b560cd9c8f553001c02d9be7 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 ab9d15aad0498e93e46fc9f4e2552455b9529912..0ea05f67cd36f7e29777e3af32b0a96222696370 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 771fb6357216575621aeaa067b77036e77c34e3a..952d800bdce52936922a1e02cce6dcd2a707ab2b 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 cd424c76e9a01e1b4705eb217014eab2c9ec5ed1..bf0504f52a570e2b6b6a79969f116ffd293b59ac 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 1db7d3c18a1bf3dd3f1f4cc1a3d1cc1bd090d7d7..f86058c5768a94d3321eb3ec8a6db4af75d8afcd 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 b043de9fd86a0c58ba16e8d332b730c26ded02f6..323fc0038a914083988b57a53bb05f1493615b4d 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 86db3063c575396706a4373d8ba5f8db9bc3b3d6..7d796eceec7d6e18282e8290fa02ca1fd957419a 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 710fa7f648861b7b515f5807775e19a9b5ba6699..46a6b04ff662cfe5c61b3b56722ab69b4de0065e 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 1d488b9db935886a2a2e2359ffddaf10ef3e4e56..a2cbe71e80c0f24b5f914a14c0f7e15d3a182fa7 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 8473344666aa5e02a8df33ef1cde898c586fdfb8..2730c8cb007df717d35e9a34a830437ad0d424cc 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 33168524c85c692c1f19fac1b3f08b684e3c3878..6eca0d095491f3c16d995fc0c487181a522e115a 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 cac817c83b784f5e7fca13d3a6dca81d0497ab18..fb95e42e7382d6dea8b1d2a58dc39d6dee2d80a5 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 e3eff86663cac6955df4ff620944547578e4d415..d4919c5795cc2a02efb867e7b209e9df88828f00 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 4360d5e84ad015e37438810cdc61712a85aef9ee..0650f7bf2ce9588e1905f0e11ca2f7ea9ad19d6b 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) { diff --git a/modules/cron/hooks/hook_configpage.php b/modules/cron/hooks/hook_configpage.php index dc3c8400b7169e66c4b4cd97756e1a0cbeccca4e..136888a0036582a91a086acf69179db53fa81fce 100644 --- a/modules/cron/hooks/hook_configpage.php +++ b/modules/cron/hooks/hook_configpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add the cron module to the config page. * * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + * @return void */ - function cron_hook_configpage(\SimpleSAML\XHTML\Template &$template) { $template->data['links']['cron'] = [ diff --git a/modules/cron/hooks/hook_cron.php b/modules/cron/hooks/hook_cron.php index 61812906a2e8fee62ba13e042314d827ca36f39d..eb4718275f11e04da59d7f5f8c0b4e292f0ec3ec 100644 --- a/modules/cron/hooks/hook_cron.php +++ b/modules/cron/hooks/hook_cron.php @@ -1,10 +1,11 @@ <?php + /** * Hook to run a cron job. * * @param array &$croninfo Output + * @return void */ - function cron_hook_cron(&$croninfo) { assert(is_array($croninfo)); diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php index 73fcd215b74521dfb827f505f5896ec49a47de39..9a0401a275bb7dab7987008b725f7dc6a20e730e 100644 --- a/modules/cron/hooks/hook_frontpage.php +++ b/modules/cron/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 cron_hook_frontpage(&$links) { assert(is_array($links)); diff --git a/modules/cron/lib/Cron.php b/modules/cron/lib/Cron.php index f8bda653b8b23b4dc6061668160c453e8044ba13..5396a2cfe0762221ccac7836b6c90718bb16b1cd 100644 --- a/modules/cron/lib/Cron.php +++ b/modules/cron/lib/Cron.php @@ -1,6 +1,6 @@ <?php -namespace SimpleSAML\Module\cron; +namespace SimpleSAML\Module\cron; /** * Handles interactions with SSP's cron system/hooks. @@ -27,13 +27,12 @@ class Cron /** * Invoke the cron hook for the given tag - * @param $tag string The tag to use. Must be valid in the cronConfig + * @param string $tag The tag to use. Must be valid in the cronConfig * @return array the tag, and summary information from the run. * @throws Exception If an invalid tag specified */ public function runTag($tag) { - if (!$this->isValidTag($tag)) { throw new \Exception("Invalid cron tag '$tag''"); } @@ -53,6 +52,10 @@ class Cron return $croninfo; } + /** + * @param string $tag + * @return bool + */ public function isValidTag($tag) { if (!is_null($this->cronconfig->getValue('allowed_tags'))) { diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index a0955cb32d320448ab03a89f55a7dd0252d8dfee..c5ce0a954a091ce38e9a1dbc7b75509fc96b35f0 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -11,7 +11,6 @@ namespace SimpleSAML\Module\discopower; * @author Andreas Ã…kre Solberg <andreas@uninett.no>, UNINETT AS. * @package SimpleSAMLphp */ - class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco { /** @@ -69,6 +68,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco * This is an helper function for logging messages. It will prefix the messages with our discovery service type. * * @param string $message The message which should be logged. + * @return void */ protected function log($message) { @@ -236,6 +236,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco * Handles a request to this discovery service. * * The IdP disco parameters should be set before calling this function. + * @return void */ public function handleRequest() { @@ -303,6 +304,13 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $t->show(); } + + /** + * @param \SimpleSAML\XHTML\Template $t + * @param array $metadata + * @param string $favourite + * @return array + */ private function processMetadata($t, $metadata, $favourite) { $basequerystring = '?'. @@ -394,6 +402,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco * This function overrides the corresponding function in the parent class, to add support for common domain cookie. * * @param string $idp The entityID of the IdP. + * @return void */ protected function setPreviousIdP($idp) { diff --git a/modules/exampleattributeserver/www/attributeserver.php b/modules/exampleattributeserver/www/attributeserver.php index 9bdbe415a1ff0a52d2c7fe64701b1bc08550da5b..84aad77dd1204475d4a9d1b908e7c9c32904bb01 100644 --- a/modules/exampleattributeserver/www/attributeserver.php +++ b/modules/exampleattributeserver/www/attributeserver.php @@ -10,10 +10,13 @@ if (!($query instanceof \SAML2\AttributeQuery)) { $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); - -$spEntityId = $query->getIssuer(); -if ($spEntityId === null) { +$issuer = $query->getIssuer(); +if ($issuer === null) { throw new \SimpleSAML\Error\BadRequest('Missing <saml:Issuer> in <samlp:AttributeQuery>.'); +} elseif (is_string($issuer)) { + $spEntityId = $issuer; +} else { + $spEntityId = $issuer->getValue(); } $idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-hosted'); @@ -41,6 +44,7 @@ if (count($returnAttributes) === 0) { $returnAttributes = []; } else { foreach ($returnAttributes as $name => $values) { + /** @var array $values */ if (!array_key_exists($name, $attributes)) { // We don't have this attribute unset($returnAttributes[$name]); diff --git a/modules/exampleauth/lib/Auth/Process/RedirectTest.php b/modules/exampleauth/lib/Auth/Process/RedirectTest.php index 13ff82dbd2e92a09d64943c2b2d938a09f7f3537..e72c5459e197b7c03e3ec547206f4d5a224461e8 100644 --- a/modules/exampleauth/lib/Auth/Process/RedirectTest.php +++ b/modules/exampleauth/lib/Auth/Process/RedirectTest.php @@ -6,13 +6,13 @@ namespace SimpleSAML\Module\exampleautth\Auth\Process; * A simple processing filter for testing that redirection works as it should. * */ - class RedirectTest extends \SimpleSAML\Auth\ProcessingFilter { /** * Initialize processing of the redirect test. * * @param array &$state The state we should update. + * @return void */ public function process(&$state) { diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php index fef113edb9ed6a4fe6375a8baf614ea072bb1162..409b4ea42b8f87ff02fd3023925844ef6f328249 100644 --- a/modules/exampleauth/lib/Auth/Source/External.php +++ b/modules/exampleauth/lib/Auth/Source/External.php @@ -22,7 +22,6 @@ namespace SimpleSAML\Module\exampleauth\Auth\Source; * * @package SimpleSAMLphp */ - class External extends \SimpleSAML\Auth\Source { /** @@ -47,10 +46,11 @@ class External extends \SimpleSAML\Auth\Source // Do any other configuration we need here } + /** * Retrieve attributes for the user. * - * @return array|NULL The user's attributes, or NULL if the user isn't authenticated. + * @return array|null The user's attributes, or NULL if the user isn't authenticated. */ private function getUser() { @@ -91,10 +91,12 @@ class External extends \SimpleSAML\Auth\Source return $attributes; } + /** * Log in using an external authentication helper. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -172,6 +174,7 @@ class External extends \SimpleSAML\Auth\Source assert(false); } + /** * Resume authentication process. * @@ -179,6 +182,9 @@ class External extends \SimpleSAML\Auth\Source * entered his or her credentials. * * @param array &$state The authentication state. + * @return void + * @throws \SimpleSAML\Error\BadRequest + * @throws \SimpleSAML\Error\Exception */ public static function resume() { @@ -248,11 +254,13 @@ class External extends \SimpleSAML\Auth\Source assert(false); } + /** * This function is called when the user start a logout operation, for example * by logging out of a SP that supports single logout. * * @param array &$state The logout state array. + * @return void */ public function logout(&$state) { diff --git a/modules/exampleauth/lib/Auth/Source/StaticSource.php b/modules/exampleauth/lib/Auth/Source/StaticSource.php index d81dd325638fe2c2e1f3e64d45ca329310115c54..607a2e4962c94518253d0df461372177e3d33149 100644 --- a/modules/exampleauth/lib/Auth/Source/StaticSource.php +++ b/modules/exampleauth/lib/Auth/Source/StaticSource.php @@ -11,7 +11,6 @@ namespace SimpleSAML\Module\exampleauth\Auth\Source; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ - class StaticSource extends \SimpleSAML\Auth\Source { /** @@ -42,10 +41,12 @@ class StaticSource extends \SimpleSAML\Auth\Source } } + /** * Log in using static attributes. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { diff --git a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php index ddd5befc1548c290914a389771a26f632087c33d..a0ae17053fdf604caf4002dbe5e4af8e4b013f05 100644 --- a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php +++ b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php @@ -21,22 +21,28 @@ namespace SimpleSAML\Module\expirycheck\Auth\Process; * @author Alex MihiÄinac, ARNES. <alexm@arnes.si> * @package SimpleSAMLphp */ - class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter { + /** @var int */ private $warndaysbefore = 0; + + /** @var string|null */ private $netid_attr = null; + + /** @var string|null */ private $expirydate_attr = null; + + /** @var string */ private $date_format = 'd.m.Y'; /** * 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); @@ -75,12 +81,14 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Show expirational warning if remaining days is equal or under defined $warndaysbefore - * @param integer $expireOnDate - * @param integer $warndaysbefore - * @return bool * + * @param array &$state + * @param int $expireOnDate + * @param int $warndaysbefore + * @return bool */ public function shWarning(&$state, $expireOnDate, $warndaysbefore) { @@ -97,11 +105,12 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter return false; } + /** - * Check if given date is older than today - * @param integer $expireOnDate - * @return bool + * Check if given date is older than today * + * @param int $expireOnDate + * @return bool */ public function checkDate($expireOnDate) { @@ -115,10 +124,12 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter } } + /** * Apply filter * * @param array &$state The current state. + * @return void */ public function process(&$state) { diff --git a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php index a1062376d98df4ba15fcce8c74d0b4ccb005a5a7..99ca6c0cc91a26407d977180a979f85ee54bc0e7 100644 --- a/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php +++ b/modules/ldap/lib/Auth/Process/AttributeAddFromLDAP.php @@ -34,7 +34,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process; * @author Remy Blom <remy.blom@hku.nl> * @package SimpleSAMLphp */ - class AttributeAddFromLDAP extends BaseFilter { /** @@ -60,6 +59,7 @@ class AttributeAddFromLDAP extends BaseFilter */ protected $attr_policy; + /** * Initialize this filter. * @@ -136,6 +136,7 @@ class AttributeAddFromLDAP extends BaseFilter * Add attributes from an LDAP server. * * @param array &$request The current request + * @return void */ public function process(&$request) { diff --git a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php index fc66ec57f5f8bc6307b550563ead6ec4d72edf70..ccf94067aad2bf2014a3f43ea0dee2cf027aec8c 100644 --- a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php +++ b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php @@ -10,7 +10,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process; * @author Ryan Panning <panman@traileyes.com> * @package SimpleSAMLphp */ - class AttributeAddUsersGroups extends BaseFilter { /** @@ -21,6 +20,7 @@ class AttributeAddUsersGroups extends BaseFilter * * @throws \SimpleSAML\Error\Exception * @param $request + * @return void */ public function process(&$request) { diff --git a/modules/ldap/lib/Auth/Process/BaseFilter.php b/modules/ldap/lib/Auth/Process/BaseFilter.php index f7de0656fc8da7e7b090737fc0e2f5d8ec5fb916..4c1d9d002aadb87182e69899e9983c85cd0dbc46 100644 --- a/modules/ldap/lib/Auth/Process/BaseFilter.php +++ b/modules/ldap/lib/Auth/Process/BaseFilter.php @@ -14,7 +14,6 @@ namespace SimpleSAML\Module\ldap\Auth\Process; * @author Remy Blom <remy.blom@hku.nl> * @package SimpleSAMLphp */ - abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -50,7 +49,7 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter * Instance, object of the ldap connection. Stored here to * be access later during processing. * - * @var \SimpleSAML\Auth\Ldap + * @var \SimpleSAML\Auth\LDAP */ private $ldap; @@ -90,8 +89,8 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter * instance/object and stores everything in class members. * * @throws \SimpleSAML\Error\Exception - * @param array $config - * @param $reserved + * @param array &$config + * @param mixed $reserved */ public function __construct(&$config, $reserved) { @@ -255,12 +254,12 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter * rather than setting in the constructor to avoid unnecessarily * connecting to LDAP when it might not be needed. * - * @return \SimpleSAML\Auth\Ldap + * @return \SimpleSAML\Auth\LDAP */ protected function getLdap() { // Check if already connected - if ($this->ldap) { + if (isset($this->ldap)) { return $this->ldap; } diff --git a/modules/ldap/lib/ConfigHelper.php b/modules/ldap/lib/ConfigHelper.php index d4dcff33ad5084d1f8fdd08cca9bc1734cff91bf..6d862c5a0af14256ba8bdd6aca9fbd92aac47652 100644 --- a/modules/ldap/lib/ConfigHelper.php +++ b/modules/ldap/lib/ConfigHelper.php @@ -253,7 +253,7 @@ class ConfigHelper * @param bool $allowZeroHits * Determines if the method will throw an exception if no * hits are found. Defaults to FALSE. - * @return string + * @return string|null * The DN of the matching element, if found. If no element was * found and $allowZeroHits is set to FALSE, an exception will * be thrown; otherwise NULL will be returned. @@ -295,6 +295,13 @@ class ConfigHelper ); } + + /** + * @param string $dn + * @param array|null $attributes + * @return array + * @throws \Exception + */ public function getAttributes($dn, $attributes = null) { if ($attributes == null) { diff --git a/modules/memcacheMonitor/hooks/hook_configpage.php b/modules/memcacheMonitor/hooks/hook_configpage.php index 4debe964ee90ecd9d41b781763738c0beb1f6240..497c84893aa89a811e2db53f259bad67cb6a226a 100644 --- a/modules/memcacheMonitor/hooks/hook_configpage.php +++ b/modules/memcacheMonitor/hooks/hook_configpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add the memcacheMonitor module to the config page. * * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + * @return void */ - function memcacheMonitor_hook_configpage(\SimpleSAML\XHTML\Template &$template) { $template->data['links']['memcacheMonitor'] = [ diff --git a/modules/memcacheMonitor/hooks/hook_frontpage.php b/modules/memcacheMonitor/hooks/hook_frontpage.php index d25437327aaad82653f3a517a8ecc9051d22dc38..9a1b4f07b7b4c329c0db156648a6a7d556309bb3 100644 --- a/modules/memcacheMonitor/hooks/hook_frontpage.php +++ b/modules/memcacheMonitor/hooks/hook_frontpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add the simple consenet admin module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ - function memcacheMonitor_hook_frontpage(&$links) { assert(is_array($links)); diff --git a/modules/memcacheMonitor/hooks/hook_sanitycheck.php b/modules/memcacheMonitor/hooks/hook_sanitycheck.php index a7a36c415dbdbbe7d1fec858040d650cdd5db5cd..ce95aada196521d5d94e07a27f155728f65b2202 100644 --- a/modules/memcacheMonitor/hooks/hook_sanitycheck.php +++ b/modules/memcacheMonitor/hooks/hook_sanitycheck.php @@ -6,8 +6,8 @@ * This function verifies that all memcache servers work. * * @param array &$hookinfo hookinfo + * @return void */ - function memcacheMonitor_hook_sanitycheck(&$hookinfo) { assert(is_array($hookinfo)); diff --git a/modules/memcacheMonitor/www/memcachestat.php b/modules/memcacheMonitor/www/memcachestat.php index fde791e558da79aa1ad5c266ed7b73ba1e7c2edc..0e79858b98387203181d0084e6d18ffe70e2a5fa 100644 --- a/modules/memcacheMonitor/www/memcachestat.php +++ b/modules/memcacheMonitor/www/memcachestat.php @@ -1,10 +1,19 @@ <?php +/** + * @param int $input + * @return string + */ function tdate($input) { return date(DATE_RFC822, $input); } + +/** + * @param int $input + * @return string + */ function hours($input) { if ($input < 60) { @@ -19,6 +28,11 @@ function hours($input) return number_format($input / (24 * 60 * 60), 2).' days'; } + +/** + * @param int $input + * @return string + */ function humanreadable($input) { $output = ""; diff --git a/modules/metarefresh/bin/metarefresh.php b/modules/metarefresh/bin/metarefresh.php index a7c34aeffb56f38c26404a9dc7ebc7cd3675c29f..87def0acdc4dec43060ace9914eeda8d68103376 100755 --- a/modules/metarefresh/bin/metarefresh.php +++ b/modules/metarefresh/bin/metarefresh.php @@ -157,6 +157,7 @@ if ($toStdOut) { /** * This function prints the help output. + * @return void */ function printHelp() { diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index 4ab82e2272d8eaf4fa9ed4b8f7d5016bf8bbbdad..a0bc57862cf75810ce099d1199a92b0024a809e4 100644 --- a/modules/metarefresh/hooks/hook_cron.php +++ b/modules/metarefresh/hooks/hook_cron.php @@ -6,6 +6,7 @@ use \SimpleSAML\Logger; * Hook to run a cron job. * * @param array &$croninfo Output + * @return void */ function metarefresh_hook_cron(&$croninfo) { diff --git a/modules/metarefresh/hooks/hook_frontpage.php b/modules/metarefresh/hooks/hook_frontpage.php index e66c583f29758151ea05e792c06f0809340e85e9..7c0c2ec91eb5593ebcc1f0b296317d09045cccdf 100644 --- a/modules/metarefresh/hooks/hook_frontpage.php +++ b/modules/metarefresh/hooks/hook_frontpage.php @@ -1,10 +1,11 @@ <?php + /** * Hook to add links to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ - function metarefresh_hook_frontpage(&$links) { assert(is_array($links)); diff --git a/modules/metarefresh/lib/ARP.php b/modules/metarefresh/lib/ARP.php index c64ff3463f593c0ed0565b578e069eb70e7c43be..51d7dec690a5b54ff6c265df98e87dfce85f7c88 100644 --- a/modules/metarefresh/lib/ARP.php +++ b/modules/metarefresh/lib/ARP.php @@ -6,7 +6,6 @@ namespace SimpleSAML\Module\metarefresh; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class ARP { /** @@ -17,7 +16,7 @@ class ARP /** * @var array */ - private $attributes; + private $attributes = []; /** * @var string diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php index a100aeec36e7b67b2e837d690cd901cee4465ef4..9802e665d3c3580c2ced664d83e9941f7503d60d 100644 --- a/modules/metarefresh/lib/MetaLoader.php +++ b/modules/metarefresh/lib/MetaLoader.php @@ -9,15 +9,27 @@ use SimpleSAML\Logger; * @package SimpleSAMLphp * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> */ - class MetaLoader { + /** @var int|null */ private $expire; - private $metadata; + + /** @var array */ + private $metadata = []; + + /** @var object|null */ private $oldMetadataSrc; + + /** @var string|null */ private $stateFile; - private $changed; - private $state; + + /** @var bool*/ + private $changed = false; + + /** @var array */ + private $state = []; + + /** @var array */ private $types = [ 'saml20-idp-remote', 'saml20-sp-remote', @@ -26,29 +38,27 @@ class MetaLoader 'attributeauthority-remote' ]; + /** * Constructor * - * @param integer $expire - * @param string $stateFile - * @param object $oldMetadataSrc + * @param int|null $expire + * @param string|null $stateFile + * @param object|null $oldMetadataSrc */ public function __construct($expire = null, $stateFile = null, $oldMetadataSrc = null) { $this->expire = $expire; - $this->metadata = []; $this->oldMetadataSrc = $oldMetadataSrc; $this->stateFile = $stateFile; - $this->changed = false; // Read file containing $state from disk if (is_readable($stateFile)) { include $stateFile; } - - $this->state = []; } + /** * Get the types of entities that will be loaded. * @@ -59,11 +69,13 @@ class MetaLoader return $this->types; } + /** * Set the types of entities that will be loaded. * * @param string|array $types Either a string with the name of one single type allowed, or an array with a list of * types. Pass an empty array to reset to all types of entities. + * @return void */ public function setTypes($types) { @@ -73,10 +85,12 @@ class MetaLoader $this->types = $types; } + /** * This function processes a SAML metadata file. * - * @param $source + * @param $source array + * @return void */ public function loadSource($source) { @@ -202,8 +216,12 @@ class MetaLoader $this->saveState($source, $responseHeaders); } + /** * Create HTTP context, with any available caches taken into account + * + * @param array $source + * @return array */ private function createContext($source) { @@ -231,6 +249,10 @@ class MetaLoader } + /** + * @param array $source + * @return void + */ private function addCachedMetadata($source) { if (isset($this->oldMetadataSrc)) { @@ -249,6 +271,10 @@ class MetaLoader /** * Store caching state data for a source + * + * @param array $source + * @param array $responseHeaders + * @return void */ private function saveState($source, $responseHeaders) { @@ -272,8 +298,14 @@ class MetaLoader } } + /** * Parse XML metadata and return entities + * + * @param string $data + * @param array $source + * @return \SimpleSAML\Metadata\SAMLParser[] + * @throws \Exception */ private function loadXML($data, $source) { @@ -291,6 +323,8 @@ class MetaLoader /** * This function writes the state array back to disk + * + * @return void */ public function writeState() { @@ -309,6 +343,8 @@ class MetaLoader /** * This function writes the metadata to stdout. + * + * @return void */ public function dumpMetadataStdOut() { @@ -336,8 +372,10 @@ class MetaLoader * This function will return without making any changes if $metadata is NULL. * * @param string $filename The filename the metadata comes from. - * @param array $metadata The metadata. + * @param array $metadata The metadata. * @param string $type The metadata type. + * @param array|null $template The template. + * @return void */ private function addMetadata($filename, $metadata, $type, $template = null) { @@ -374,6 +412,9 @@ class MetaLoader /** * This function writes the metadata to an ARP file + * + * @param \SimpleSAML\Configuration $config + * @return void */ public function writeARPfile($config) { @@ -408,6 +449,9 @@ class MetaLoader /** * This function writes the metadata to to separate files in the output directory. + * + * @param string $outputDir + * @return void */ public function writeMetadataFiles($outputDir) { @@ -457,6 +501,7 @@ class MetaLoader * Save metadata for loading with the 'serialize' metadata loader. * * @param string $outputDir The directory we should save the metadata to. + * @return void */ public function writeMetadataSerialize($outputDir) { @@ -503,6 +548,9 @@ class MetaLoader } + /** + * @return string + */ private function getTime() { // The current date, as a string diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index c25f85ba5d224feb17c8751648f80d56f2239588..185ccb46b2ed5d80c6b7259d080fbb0f64e5d174 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -9,7 +9,6 @@ namespace SimpleSAML\Module\multiauth\Auth\Source; * @author Lorenzo Gil, Yaco Sistemas S.L. * @package SimpleSAMLphp */ - class MultiAuth extends \SimpleSAML\Auth\Source { /** @@ -42,6 +41,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source */ private $preselect; + /** * Constructor for this authentication source. * @@ -111,6 +111,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source } } + /** * Prompt the user with a list of authentication sources. * @@ -122,6 +123,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * in the delegateAuthentication method. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -154,6 +156,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source assert(false); } + /** * Delegate authentication. * @@ -164,6 +167,8 @@ class MultiAuth extends \SimpleSAML\Auth\Source * * @param string $authId Selected authentication source * @param array $state Information about the current authentication. + * @return void + * @throws \Exception */ public static function delegateAuthentication($authId, $state) { @@ -172,6 +177,10 @@ class MultiAuth extends \SimpleSAML\Auth\Source $as = \SimpleSAML\Auth\Source::getById($authId); $valid_sources = array_map( + /** + * @param array $src + * @return string + */ function ($src) { return $src['source']; }, @@ -201,6 +210,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source \SimpleSAML\Auth\Source::completeAuth($state); } + /** * Log out from this authentication source. * @@ -208,6 +218,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * session and then call the logout method on it. * * @param array &$state Information about the current logout operation. + * @return void */ public function logout(&$state) { @@ -225,6 +236,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $source->logout($state); } + /** * Set the previous authentication source. * @@ -232,6 +244,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * by storing its name in a cookie. * * @param string $source Name of the authentication source the user selected. + * @return void */ public function setPreviousSource($source) { @@ -251,11 +264,13 @@ class MultiAuth extends \SimpleSAML\Auth\Source \SimpleSAML\Utils\HTTP::setCookie($cookieName, $source, $params, false); } + /** * Get the previous authentication source. * * This method retrieves the authentication source that the user selected * last time or NULL if this is the first time or remembering is disabled. + * @return string|null */ public function getPreviousSource() { diff --git a/modules/multiauth/www/selectsource.php b/modules/multiauth/www/selectsource.php index 287f7808eab880abd9749df3e665f90f4b836fac..f18d60fbebacd67392106f0e92251246bb060ecd 100644 --- a/modules/multiauth/www/selectsource.php +++ b/modules/multiauth/www/selectsource.php @@ -19,6 +19,7 @@ $state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\mult if (array_key_exists("\SimpleSAML\Auth\Source.id", $state)) { $authId = $state["\SimpleSAML\Auth\Source.id"]; + /** @var \SimpleSAML\Module\multiauth\Auth\Source\MultiAuth $as */ $as = \SimpleSAML\Auth\Source::getById($authId); } else { $as = null; diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php index bba08d6bbd2aff1b6fee9cbb47dfbd08e29c5b63..d70e21cbbf47984341e20d91b14535b7c1aa9fd9 100644 --- a/modules/negotiate/lib/Auth/Source/Negotiate.php +++ b/modules/negotiate/lib/Auth/Source/Negotiate.php @@ -16,20 +16,49 @@ class Negotiate extends \SimpleSAML\Auth\Source // Constants used in the module const STAGEID = '\SimpleSAML\Module\negotiate\Auth\Source\Negotiate.StageId'; + /** @var \SimpleSAML\Auth\LDAP|null */ protected $ldap = null; + + /** @var string */ protected $backend = ''; + + /** @var string*/ protected $hostname = ''; + + /** @var int */ protected $port = 389; + + /** @var bool */ protected $referrals = true; + + /** @var bool */ protected $enableTLS = false; + + /** @var bool */ protected $debugLDAP = false; + + /** @var int */ protected $timeout = 30; + + /** @var string */ protected $keytab = ''; + + /** @var array */ protected $base = []; + + /** @var array */ protected $attr = ['uid']; + + /** @var array|null */ protected $subnet = null; + + /** @var string|null */ protected $admin_user = null; + + /** @var string|null */ protected $admin_pw = null; + + /** @var array|null */ protected $attributes = null; @@ -81,6 +110,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * LDAP is used as a user metadata source. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -187,6 +217,10 @@ class Negotiate extends \SimpleSAML\Auth\Source } + /** + * @param array $spMetadata + * @return bool + */ public function spDisabledInMetadata($spMetadata) { if (array_key_exists('negotiate:disable', $spMetadata)) { @@ -209,7 +243,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * * Will return TRUE if no subnet option is configured. * - * @return boolean + * @return bool */ public function checkMask() { @@ -235,6 +269,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * wants to show the 401 message. * * @param array $params additional parameters to the URL in the URL in the body. + * @return void */ protected function sendNegotiate($params) { @@ -256,6 +291,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * Passes control of the login process to a different module. * * @param array $state Information about the current authentication. + * @return void * * @throws \SimpleSAML\Error\Error If couldn't determine the auth source. * @throws \SimpleSAML\Error\Exception @@ -290,7 +326,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * * @param string $user The Kerberos user identifier. * - * @return string The DN to the user or NULL if not found. + * @return array|null The attributes for the user or NULL if not found. */ protected function lookupUserData($user) { @@ -315,6 +351,9 @@ class Negotiate extends \SimpleSAML\Auth\Source /** * Elevates the LDAP connection to allow restricted lookups if * so configured. Does nothing if not. + * + * @return void + * @throws \SimpleSAML\Error\AuthSource */ protected function adminBind() { @@ -339,6 +378,7 @@ class Negotiate extends \SimpleSAML\Auth\Source * logout call to the fallback module. * * @param array &$state Information about the current logout operation. + * @return void */ public function logout(&$state) { diff --git a/modules/portal/hooks/hook_htmlinject.php b/modules/portal/hooks/hook_htmlinject.php index efa1984a32aa37402255535297c245325658deef..72235d7335907ae61bf0aee342e10729f768cb70 100644 --- a/modules/portal/hooks/hook_htmlinject.php +++ b/modules/portal/hooks/hook_htmlinject.php @@ -4,6 +4,7 @@ * Hook to inject HTML content into all pages... * * @param array &$hookinfo hookinfo + * @return void */ function portal_hook_htmlinject(&$hookinfo) { diff --git a/modules/portal/lib/Portal.php b/modules/portal/lib/Portal.php index 517ce2edfa4a75bf7afa0798f0d3b9c8fa0f5fbc..3df6495b583b9db2d96925bc28e4355b485716d1 100644 --- a/modules/portal/lib/Portal.php +++ b/modules/portal/lib/Portal.php @@ -4,15 +4,28 @@ namespace SimpleSAML\Module\portal; class Portal { + /** @var array */ private $pages; + + /** @var array|null */ private $config; + + /** + * @param array $pages + * @param array|null $config + */ public function __construct($pages, $config = null) { $this->pages = $pages; $this->config = $config; } + + /** + * @param string $thispage + * @return array|null + */ public function getTabset($thispage) { if (!isset($this->config)) { @@ -26,6 +39,11 @@ class Portal return null; } + + /** + * @param string $thispage + * @return bool + */ public function isPortalized($thispage) { foreach ($this->config as $set) { @@ -36,6 +54,12 @@ class Portal return false; } + + /** + * @param \SimpleSAML\Locale\Translate $translator + * @param string $thispage + * @return string + */ public function getLoginInfo($translator, $thispage) { $info = ['info' => '', 'translator' => $translator, 'thispage' => $thispage]; @@ -43,6 +67,11 @@ class Portal return $info['info']; } + + /** + * @param string + * @return string + */ public function getMenu($thispage) { $config = \SimpleSAML\Configuration::getInstance(); diff --git a/modules/preprodwarning/lib/Auth/Process/Warning.php b/modules/preprodwarning/lib/Auth/Process/Warning.php index bbc6fdadb2d20f684c75db19e17f5e7419dce5bf..6a7c7925d100c0b3393981993b8318e1fd0f5dd5 100644 --- a/modules/preprodwarning/lib/Auth/Process/Warning.php +++ b/modules/preprodwarning/lib/Auth/Process/Warning.php @@ -17,6 +17,7 @@ class Warning extends \SimpleSAML\Auth\ProcessingFilter * can authorize the release of the attributes. * * @param array $state The state of the response. + * @return void */ public function process(&$state) { diff --git a/modules/radius/lib/Auth/Source/Radius.php b/modules/radius/lib/Auth/Source/Radius.php index 70a192b4136b913ff5bbfbfc4479a4cf3602fe79..62590680aa911e9cfb5c58b564e56bda1113736b 100644 --- a/modules/radius/lib/Auth/Source/Radius.php +++ b/modules/radius/lib/Auth/Source/Radius.php @@ -9,65 +9,65 @@ namespace SimpleSAML\Module\radius\Auth\Source; * * @package SimpleSAMLphp */ - class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase { /** - * The list of radius servers to use. + * @var array The list of radius servers to use. */ private $servers; /** - * The hostname of the radius server. + * @var string The hostname of the radius server. */ private $hostname; /** - * The port of the radius server. + * @var int The port of the radius server. */ private $port; /** - * The secret used when communicating with the radius server. + * @var string The secret used when communicating with the radius server. */ private $secret; /** - * The timeout for contacting the radius server. + * @var int The timeout for contacting the radius server. */ private $timeout; /** - * The number of retries which should be attempted. + * @var int The number of retries which should be attempted. */ private $retries; /** - * The realm to be added to the entered username. + * Var string The realm to be added to the entered username. */ private $realm; /** - * The attribute name where the username should be stored. + * @var string The attribute name where the username should be stored. */ private $usernameAttribute; /** - * The vendor for the RADIUS attributes we are interrested in. + * @var string The vendor for the RADIUS attributes we are interrested in. */ private $vendor; /** - * The vendor-specific attribute for the RADIUS attributes we are - * interrested in. + * @var string The vendor-specific attribute for the RADIUS attributes we are + * interrested in. */ private $vendorType; /** - * The NAS-Identifier that should be set in Access-Request packets. + * @var string The NAS-Identifier that should be set in Access-Request packets. */ private $nasIdentifier; + /** * Constructor for this authentication source. * diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php index e1dc65c36f81892947e651fc296020ad3bfb7090..9a13aa878befa7da01edfa760b48b7bc2fe19caa 100644 --- a/modules/saml/hooks/hook_metadata_hosted.php +++ b/modules/saml/hooks/hook_metadata_hosted.php @@ -4,8 +4,8 @@ * Hook to add the metadata for hosted entities to the frontpage. * * @param array &$metadataHosted The metadata links for hosted metadata on the frontpage. + * @return void */ - function saml_hook_metadata_hosted(&$metadataHosted) { assert(is_array($metadataHosted)); @@ -13,6 +13,7 @@ function saml_hook_metadata_hosted(&$metadataHosted) $sources = \SimpleSAML\Auth\Source::getSourcesOfType('saml:SP'); foreach ($sources as $source) { + /** @var \SimpleSAML\Auth\Source $source */ $metadata = $source->getMetadata(); $name = $metadata->getValue('name', null); diff --git a/modules/saml/lib/Auth/Process/AuthnContextClassRef.php b/modules/saml/lib/Auth/Process/AuthnContextClassRef.php index 106d7b51f06f7472ece5bc013f6f38e3fa938958..f579d2c5528802ed4e65c7e3afe8b0609f8e8693 100644 --- a/modules/saml/lib/Auth/Process/AuthnContextClassRef.php +++ b/modules/saml/lib/Auth/Process/AuthnContextClassRef.php @@ -7,15 +7,14 @@ namespace SimpleSAML\Module\saml\Auth\Process; * * @package SimpleSAMLphp */ - class AuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter { /** * The URI we should set as the AuthnContextClassRef in the login response. * - * @var string + * @var string|null */ - private $authnContextClassRef; + private $authnContextClassRef = null; /** @@ -43,6 +42,7 @@ class AuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter * Set the AuthnContextClassRef in the SAML 2 response. * * @param array &$state The state array for this request. + * @return void */ public function process(&$state) { diff --git a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php index fd6277732326b7bfad1cc82bce053b7f3d217b85..b7aa14698a55f5443b104c520737dd6862850d20 100644 --- a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php +++ b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php @@ -29,9 +29,9 @@ class ExpectedAuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter /** * AuthnContextClassRef of the assertion - * @var string + * @var string|null */ - private $AuthnContextClassRef; + private $AuthnContextClassRef = null; /** @@ -62,6 +62,7 @@ class ExpectedAuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter /** * * @param array &$request The current request + * @return void */ public function process(&$request) { @@ -87,6 +88,7 @@ class ExpectedAuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter * permission logic. * * @param array $request + * @return void */ protected function unauthorized(&$request) { diff --git a/modules/saml/lib/Auth/Process/FilterScopes.php b/modules/saml/lib/Auth/Process/FilterScopes.php index 67ef886df09e4dec683df2fbced1bf02d6c1ca44..1478112be462d1a4956a16d818dbca8f61609faa 100644 --- a/modules/saml/lib/Auth/Process/FilterScopes.php +++ b/modules/saml/lib/Auth/Process/FilterScopes.php @@ -15,7 +15,7 @@ use SimpleSAML\Logger; class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter { /** - * Stores any pre-configured scoped attributes which come from the filter configuration. + * @var array Stores any pre-configured scoped attributes which come from the filter configuration. */ private $scopedAttributes = [ 'eduPersonScopedAffiliation', @@ -44,6 +44,7 @@ class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter * This method applies the filter, removing any values * * @param array &$request the current request + * @return void */ public function process(&$request) { diff --git a/modules/saml/lib/Auth/Process/NameIDAttribute.php b/modules/saml/lib/Auth/Process/NameIDAttribute.php index e8c27dba78416342ff436bb0b6e73b64b6cb33a5..1ee6e5f421cd4faaed1fe65f346e64269b117f0c 100644 --- a/modules/saml/lib/Auth/Process/NameIDAttribute.php +++ b/modules/saml/lib/Auth/Process/NameIDAttribute.php @@ -103,6 +103,7 @@ class NameIDAttribute extends \SimpleSAML\Auth\ProcessingFilter * Convert NameID to attribute. * * @param array &$state The request state. + * @return void */ public function process(&$state) { diff --git a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php index f627f164e777314b908164d3081e6510cba26a75..7bf2e2f1bbc1043da516f141ae333f38dab0dbf7 100644 --- a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php +++ b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php @@ -21,7 +21,7 @@ class PersistentNameID2TargetedID extends \SimpleSAML\Auth\ProcessingFilter /** * Whether we should insert it as an saml:NameID element. * - * @var boolean + * @var bool */ private $nameId; @@ -55,6 +55,7 @@ class PersistentNameID2TargetedID extends \SimpleSAML\Auth\ProcessingFilter * Store a NameID to attribute. * * @param array &$state The request state. + * @return void */ public function process(&$state) { diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 9187ed846df8b77813ac994018aa381b0bff957f..62cf5331e1b3cad865a1400317a54a0fd7b49f92 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -86,6 +86,7 @@ class SP extends Source } } + /** * Retrieve the URL to the metadata of this SP. * @@ -96,6 +97,7 @@ class SP extends Source return \SimpleSAML\Module::getModuleURL('saml/sp/metadata.php/'.urlencode($this->authId)); } + /** * Retrieve the entity id of this SP. * @@ -440,6 +442,7 @@ class SP extends Source * * @param \SimpleSAML\Configuration $idpMetadata The metadata of the IdP. * @param array $state The state array for the current authentication. + * @return void */ private function startSSO1(\SimpleSAML\Configuration $idpMetadata, array $state) { @@ -471,11 +474,13 @@ class SP extends Source \SimpleSAML\Utils\HTTP::redirectTrustedURL($url); } + /** * Send a SAML2 SSO request to an IdP * * @param \SimpleSAML\Configuration $idpMetadata The metadata of the IdP. * @param array $state The state array for the current authentication. + * @return void */ private function startSSO2(\SimpleSAML\Configuration $idpMetadata, array $state) { @@ -647,6 +652,7 @@ class SP extends Source assert(false); } + /** * Function to actually send the authentication request. * @@ -655,6 +661,7 @@ class SP extends Source * @param array &$state The state array. * @param \SAML2\Binding $binding The binding. * @param \SAML2\AuthnRequest $ar The authentication request. + * @return void */ public function sendSAML2AuthnRequest(array &$state, \SAML2\Binding $binding, \SAML2\AuthnRequest $ar) { @@ -662,11 +669,13 @@ class SP extends Source assert(false); } + /** * Send a SSO request to an IdP. * * @param string $idp The entity ID of the IdP. * @param array $state The state array for the current authentication. + * @return void */ public function startSSO($idp, array $state) { @@ -688,10 +697,12 @@ class SP extends Source } } + /** * Start an IdP discovery service operation. * * @param array $state The state array. + * @return void */ private function startDisco(array $state) { @@ -722,12 +733,14 @@ class SP extends Source \SimpleSAML\Utils\HTTP::redirectTrustedURL($discoURL, $params); } + /** * Start login. * * This function saves the information about the login, and redirects to the IdP. * * @param array &$state Information about the current authentication. + * @return void */ public function authenticate(&$state) { @@ -779,6 +792,7 @@ class SP extends Source assert(false); } + /** * Re-authenticate an user. * @@ -786,6 +800,7 @@ class SP extends Source * interact with the user even in the case when the user is already authenticated. * * @param array &$state Information about the current authentication. + * @return void */ public function reauthenticate(array &$state) { @@ -867,6 +882,7 @@ class SP extends Source * - 'core:IdP': the identifier of the local IdP. * - 'SPMetadata': an array with the metadata of this local SP. * + * @return void * @throws \SimpleSAML\Error\NoPassive In case the authentication request was passive. */ public static function askForIdPChange(array &$state) @@ -891,12 +907,14 @@ class SP extends Source assert(false); } + /** * Log the user out before logging in again. * * This method will never return. * * @param array $state The state array. + * @return void */ public static function reauthLogout(array $state) { @@ -912,10 +930,12 @@ class SP extends Source assert(false); } + /** * Complete login operation after re-authenticating the user on another IdP. * * @param array $state The authentication state. + * @return void */ public static function reauthPostLogin(array $state) { @@ -931,6 +951,7 @@ class SP extends Source assert(false); } + /** * Post-logout handler for re-authentication. * @@ -938,6 +959,7 @@ class SP extends Source * * @param \SimpleSAML\IdP $idp The IdP we are logging out from. * @param array &$state The state array with the state during logout. + * @return void */ public static function reauthPostLogout(\SimpleSAML\IdP $idp, array $state) { @@ -956,10 +978,12 @@ class SP extends Source assert(false); } + /** * Start a SAML 2 logout operation. * * @param array $state The logout state. + * @return void */ public function startSLO2(&$state) { @@ -1004,10 +1028,12 @@ class SP extends Source assert(false); } + /** * Start logout operation. * * @param array $state The logout state. + * @return void */ public function logout(&$state) { @@ -1028,12 +1054,14 @@ class SP extends Source } } + /** * Handle a response from a SSO operation. * * @param array $state The authentication state. * @param string $idp The entity id of the IdP. * @param array $attributes The attributes. + * @return void */ public function handleResponse(array $state, $idp, array $attributes) { @@ -1073,10 +1101,12 @@ class SP extends Source self::onProcessingCompleted($authProcState); } + /** * Handle a logout request from an IdP. * * @param string $idpEntityId The entity ID of the IdP. + * @return void */ public function handleLogout($idpEntityId) { @@ -1086,6 +1116,7 @@ class SP extends Source $this->callLogoutCallback($idpEntityId); } + /** * Handle an unsolicited login operations. * @@ -1099,6 +1130,7 @@ class SP extends Source * the session. The function will check if the URL is allowed, so there is no need to * manually check the URL on beforehand. Please refer to the 'trusted.url.domains' * configuration directive for more information about allowing (or disallowing) URLs. + * @return void */ public static function handleUnsolicitedAuth($authId, array $state, $redirectTo) { @@ -1111,10 +1143,12 @@ class SP extends Source \SimpleSAML\Utils\HTTP::redirectUntrustedURL($redirectTo); } + /** * Called when we have completed the procssing chain. * * @param array $authProcState The processing chain state. + * @return void */ public static function onProcessingCompleted(array $authProcState) { diff --git a/modules/saml/lib/BaseNameIDGenerator.php b/modules/saml/lib/BaseNameIDGenerator.php index 39a4a3f00e61969ad8a7a264806554829ca1c98b..7c7bcf2c2064927e723e1ab1efe61c865b0b73ef 100644 --- a/modules/saml/lib/BaseNameIDGenerator.php +++ b/modules/saml/lib/BaseNameIDGenerator.php @@ -7,7 +7,6 @@ namespace SimpleSAML\Module\saml; * * @package SimpleSAMLphp */ - abstract class BaseNameIDGenerator extends \SimpleSAML\Auth\ProcessingFilter { /** @@ -37,11 +36,11 @@ abstract class BaseNameIDGenerator extends \SimpleSAML\Auth\ProcessingFilter /** * The format of this NameID. * - * This property must be initialized the subclass. + * This property must be set by the subclass. * - * @var string + * @var string|null */ - protected $format; + protected $format = null; /** @@ -81,6 +80,7 @@ abstract class BaseNameIDGenerator extends \SimpleSAML\Auth\ProcessingFilter * Generate transient NameID. * * @param array &$state The request state. + * @return void */ public function process(&$state) { diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php index e158a666b590f08c8b7add6e289ce48a4cd2b324..5e78d48278a6bc7e63728120b41b60e2f88ab643 100644 --- a/modules/saml/lib/IdP/SAML1.php +++ b/modules/saml/lib/IdP/SAML1.php @@ -12,10 +12,8 @@ use SimpleSAML\Utils\HTTP; * * @package SimpleSAMLphp */ - class SAML1 { - /** * Retrieve the metadata of a hosted SAML 1.1 IdP. * @@ -73,7 +71,7 @@ class SAML1 ); if (!$config->hasValue('OrganizationURL')) { - throw new \SimpleSAMl\Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); + throw new \SimpleSAML\Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); } $metadata['OrganizationURL'] = $config->getLocalizedString('OrganizationURL'); } @@ -125,6 +123,7 @@ class SAML1 * Send a response to the SP. * * @param array $state The authentication state. + * @return void */ public static function sendResponse(array $state) { @@ -176,6 +175,7 @@ class SAML1 * Receive an authentication request. * * @param \SimpleSAML\IdP $idp The IdP we are receiving it for. + * @return void */ public static function receiveAuthnRequest(\SimpleSAML\IdP $idp) { diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 3d4d255b4dae119a92a8a9b650331ef775da7f75..aeece087423d2e99f2892b7c598f1d95ed8d3a91 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -17,13 +17,13 @@ use SimpleSAML\Utils\HTTP; * * @package SimpleSAMLphp */ - class SAML2 { /** * Send a response to the SP. * * @param array $state The authentication state. + * @return void */ public static function sendResponse(array $state) { @@ -101,6 +101,7 @@ class SAML2 * \SimpleSAML\Error\Exception $exception The exception. * * @param array $state The error state. + * @return void */ public static function handleAuthError(\SimpleSAML\Error\Exception $exception, array $state) { @@ -162,11 +163,11 @@ class SAML2 * * @param array $supportedBindings The bindings we allow for the response. * @param \SimpleSAML\Configuration $spMetadata The metadata for the SP. - * @param string|NULL $AssertionConsumerServiceURL AssertionConsumerServiceURL from request. - * @param string|NULL $ProtocolBinding ProtocolBinding from request. - * @param int|NULL $AssertionConsumerServiceIndex AssertionConsumerServiceIndex from request. + * @param string|null $AssertionConsumerServiceURL AssertionConsumerServiceURL from request. + * @param string|null $ProtocolBinding ProtocolBinding from request. + * @param int|null $AssertionConsumerServiceIndex AssertionConsumerServiceIndex from request. * - * @return array Array with the Location and Binding we should use for the response. + * @return array|null Array with the Location and Binding we should use for the response. */ private static function getAssertionConsumerService( array $supportedBindings, @@ -252,6 +253,7 @@ class SAML2 * Receive an authentication request. * * @param \SimpleSAML\IdP $idp The IdP we are receiving it for. + * @return void * @throws \SimpleSAML\Error\BadRequest In case an error occurs when trying to receive the request. */ public static function receiveAuthnRequest(\SimpleSAML\IdP $idp) @@ -463,12 +465,14 @@ class SAML2 $idp->handleAuthenticationRequest($state); } + /** * Send a logout request to a given association. * * @param \SimpleSAML\IdP $idp The IdP we are sending a logout request from. * @param array $association The association that should be terminated. - * @param string|NULL $relayState An id that should be carried across the logout. + * @param string|null $relayState An id that should be carried across the logout. + * @return void */ public static function sendLogoutRequest(\SimpleSAML\IdP $idp, array $association, $relayState) { @@ -505,6 +509,7 @@ class SAML2 * * @param \SimpleSAML\IdP $idp The IdP we are sending a logout request from. * @param array &$state The logout state array. + * @return void */ public static function sendLogoutResponse(\SimpleSAML\IdP $idp, array $state) { @@ -562,6 +567,7 @@ class SAML2 * Receive a logout message. * * @param \SimpleSAML\IdP $idp The IdP we are receiving it for. + * @return void * @throws \SimpleSAML\Error\BadRequest In case an error occurs while trying to receive the logout message. */ public static function receiveLogoutMessage(\SimpleSAML\IdP $idp) diff --git a/modules/saml/lib/IdP/SQLNameID.php b/modules/saml/lib/IdP/SQLNameID.php index 95d5712df26a64a808b072144af9e397b905acee..e62f77f0f76787b89500621397dbc74cec1b2aef 100644 --- a/modules/saml/lib/IdP/SQLNameID.php +++ b/modules/saml/lib/IdP/SQLNameID.php @@ -7,13 +7,13 @@ namespace SimpleSAML\Module\saml\IdP; * * @package SimpleSAMLphp */ - class SQLNameID { /** * Create NameID table in SQL, if it is missing. * * @param \SimpleSAML\Store\SQL $store The datastore. + * @return void */ private static function createTable(\SimpleSAML\Store\SQL $store) { @@ -68,6 +68,7 @@ class SQLNameID * @param string $spEntityId The SP entityID. * @param string $user The user's unique identificator (e.g. username). * @param string $value The NameID value. + * @return void */ public static function add($idpEntityId, $spEntityId, $user, $value) { @@ -98,7 +99,7 @@ class SQLNameID * @param string $idpEntityId The IdP entityID. * @param string $spEntityId The SP entityID. * @param string $user The user's unique identificator (e.g. username). - * @return string|NULL $value The NameID value, or NULL of no NameID value was found. + * @return string|null $value The NameID value, or NULL of no NameID value was found. */ public static function get($idpEntityId, $spEntityId, $user) { @@ -135,6 +136,7 @@ class SQLNameID * @param string $idpEntityId The IdP entityID. * @param string $spEntityId The SP entityID. * @param string $user The user's unique identificator (e.g. username). + * @return void */ public static function delete($idpEntityId, $spEntityId, $user) { diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index a0f71931047530360fb41d4168301d57d6b14393..c68a2647cb7f597db4ec2f8fa3b2ee8ac77bba7a 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -19,6 +19,7 @@ class Message * @param \SimpleSAML\Configuration $srcMetadata The metadata of the sender. * @param \SimpleSAML\Configuration $dstMetadata The metadata of the recipient. * @param \SAML2\SignedElement $element The element we should add the data to. + * @return void */ public static function addSign( \SimpleSAML\Configuration $srcMetadata, @@ -68,6 +69,7 @@ class Message * @param \SimpleSAML\Configuration $srcMetadata The metadata of the sender. * @param \SimpleSAML\Configuration $dstMetadata The metadata of the recipient. * @param \SAML2\Message $message The message we should add the data to. + * @return void */ private static function addRedirectSign( \SimpleSAML\Configuration $srcMetadata, @@ -144,7 +146,7 @@ class Message * * @param \SimpleSAML\Configuration $srcMetadata The metadata of the sender. * @param \SAML2\SignedElement $element Either a \SAML2\Response or a \SAML2\Assertion. - * @return boolean True if the signature is correct, false otherwise. + * @return bool True if the signature is correct, false otherwise. * * @throws \SimpleSAML\Error\Exception if there is not certificate in the metadata for the entity. * @throws \Exception if the signature validation fails with an exception. @@ -233,6 +235,7 @@ class Message * @param \SimpleSAML\Configuration $srcMetadata The metadata of the sender. * @param \SimpleSAML\Configuration $dstMetadata The metadata of the recipient. * @param \SAML2\Message $message The message we should check the signature on. + * @return void * * @throws \SimpleSAML\Error\Exception if message validation is enabled, but there is no signature in the message. */ @@ -396,6 +399,8 @@ class Message $lastException = $e; } } + + /** @var \Exception $lastException */ throw $lastException; } diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index 8ea35423a5c3e81bd937f1d7bcd9cff1857f547d..7d995b369a01f0a43a947e91a2b83d96d1e33806 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -14,6 +14,7 @@ class LogoutStore * Create logout table in SQL, if it is missing. * * @param \SimpleSAML\Store\SQL $store The datastore. + * @return void */ private static function createLogoutTable(\SimpleSAML\Store\SQL $store) { @@ -70,6 +71,7 @@ class LogoutStore * Clean the logout table of expired entries. * * @param \SimpleSAML\Store\SQL $store The datastore. + * @return void */ private static function cleanLogoutStore(\SimpleSAML\Store\SQL $store) { @@ -90,6 +92,9 @@ class LogoutStore * @param string $authId The authsource ID. * @param string $nameId The hash of the users NameID. * @param string $sessionIndex The SessionIndex of the user. + * @param int $expire + * @param string $sessionId + * @return void */ private static function addSessionSQL( \SimpleSAML\Store\SQL $store, @@ -102,8 +107,8 @@ class LogoutStore assert(is_string($authId)); assert(is_string($nameId)); assert(is_string($sessionIndex)); - assert(is_string($sessionId)); assert(is_int($expire)); + assert(is_string($sessionId)); self::createLogoutTable($store); @@ -202,6 +207,8 @@ class LogoutStore * @param string $authId The authsource ID. * @param \SAML2\XML\saml\NameID $nameId The NameID of the user. * @param string|null $sessionIndex The SessionIndex of the user. + * @param int $expire + * @return void */ public static function addSession($authId, $nameId, $sessionIndex, $expire) { @@ -254,7 +261,7 @@ class LogoutStore * @param string $authId The authsource ID. * @param \SAML2\XML\saml\NameID $nameId The NameID of the user. * @param array $sessionIndexes The SessionIndexes we should log out of. Logs out of all if this is empty. - * @returns int|false Number of sessions logged out, or FALSE if not supported. + * @return int|false Number of sessions logged out, or FALSE if not supported. */ public static function logoutSessions($authId, $nameId, array $sessionIndexes) { diff --git a/modules/sanitycheck/hooks/hook_configpage.php b/modules/sanitycheck/hooks/hook_configpage.php index a4db0492e7139c7cdaed3741af3bbf45b0643e55..68856b9305f72040d8c14a372ee18d1fb908a074 100644 --- a/modules/sanitycheck/hooks/hook_configpage.php +++ b/modules/sanitycheck/hooks/hook_configpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the sanitycheck link to the config page. * * @param \SimpleSAML\XHTML\Template $template The template that we should alter in this hook. + * @return void */ function sanitycheck_hook_configpage(\SimpleSAML\XHTML\Template &$template) { diff --git a/modules/sanitycheck/hooks/hook_cron.php b/modules/sanitycheck/hooks/hook_cron.php index 15e0736ddbdd7c6457dd586b210f7af6ae4295db..0ab1a6604666aaa381e6334644c1fbd40954377d 100644 --- a/modules/sanitycheck/hooks/hook_cron.php +++ b/modules/sanitycheck/hooks/hook_cron.php @@ -1,10 +1,11 @@ <?php + /** * Hook to run a cron job. * * @param array &$croninfo Output + * @return void */ - function sanitycheck_hook_cron(&$croninfo) { assert(is_array($croninfo)); @@ -35,7 +36,7 @@ function sanitycheck_hook_cron(&$croninfo) $croninfo['summary'][] = 'Sanitycheck error: '.$err; } } - } catch (Exception $e) { + } catch (\Exception $e) { $croninfo['summary'][] = 'Error executing sanity check: '.$e->getMessage(); } } diff --git a/modules/sanitycheck/hooks/hook_frontpage.php b/modules/sanitycheck/hooks/hook_frontpage.php index 1e860e6e68234e8fbca4688fda72ee8e15b216d5..e1b1a126d9c94b0df8816ac3f87d11fe6b03e268 100644 --- a/modules/sanitycheck/hooks/hook_frontpage.php +++ b/modules/sanitycheck/hooks/hook_frontpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the modinfo module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ function sanitycheck_hook_frontpage(&$links) { diff --git a/modules/sanitycheck/hooks/hook_moduleinfo.php b/modules/sanitycheck/hooks/hook_moduleinfo.php index 87d014e2ec5a2e0c2098e1fe9aab5a60062d9d26..d0eb684e1f3ab7ba9455a77dbae25a0a4a1a76ab 100644 --- a/modules/sanitycheck/hooks/hook_moduleinfo.php +++ b/modules/sanitycheck/hooks/hook_moduleinfo.php @@ -1,8 +1,10 @@ <?php + /** * This hook lets the module describe itself. * * @param array &$moduleinfo The links on the frontpage, split into sections. + * @return void */ function sanitycheck_hook_moduleinfo(&$moduleinfo) { diff --git a/modules/sanitycheck/hooks/hook_sanitycheck.php b/modules/sanitycheck/hooks/hook_sanitycheck.php index 8aec6582bff9d6e24d147d8012b4b9cb3264dda3..6288c1be69767b617bec3e5ee13dd9cbf6bade7f 100644 --- a/modules/sanitycheck/hooks/hook_sanitycheck.php +++ b/modules/sanitycheck/hooks/hook_sanitycheck.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the modinfo module to the frontpage. * * @param array &$hookinfo hookinfo + * @return void */ function sanitycheck_hook_sanitycheck(&$hookinfo) { diff --git a/modules/smartattributes/lib/Auth/Process/SmartID.php b/modules/smartattributes/lib/Auth/Process/SmartID.php index 00ca468eae4ff9ce4f4afe09e1de9949577f1ce7..7529b84fe0d33aba3582aa38644fce2f83b48d6a 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartID.php +++ b/modules/smartattributes/lib/Auth/Process/SmartID.php @@ -10,6 +10,8 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter * IMPORTANT: If you use the (default) attributemaps (twitter2name, facebook2name, * etc., be sure to comment out the entries that map xxx_targetedID to * eduPersonTargetedID, or there will be no way to see its origin any more. + * + * @var array */ private $candidates = [ 'eduPersonTargetedID', @@ -24,29 +26,36 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter ]; /** - * The name of the generated ID attribute. + * @var string The name of the generated ID attribute. */ private $id_attribute = 'smart_id'; /** * Whether to append the AuthenticatingAuthority, separated by '!' * This only works when SSP is used as a gateway. + * @var bool */ private $add_authority = true; /** * Whether to prepend the CandidateID, separated by ':' + * @var bool */ private $add_candidate = true; /** * Attributes which should be added/appended. * - * Associative array of arrays. + * @var array Associative array of arrays. */ private $attributes = []; + /** + * @param array $config + * @param mixed $reserved + * @throws \Exception + */ public function __construct($config, $reserved) { parent::__construct($config, $reserved); @@ -82,6 +91,13 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter } } + + /** + * @param array $attributes + * @param array $request + * @return string + * @throws \SimpleSAML\Error\Exception + */ private function addID($attributes, $request) { $state = $request['saml:sp:State']; @@ -104,12 +120,14 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter them, or try using another identity provider.'); } + /** * 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/smartattributes/lib/Auth/Process/SmartName.php b/modules/smartattributes/lib/Auth/Process/SmartName.php index 19a69baa6f31d66fc8a15e3bdc1c7d72d3c67bb5..420605f0884ae723326483b636e52fad95f5fbb7 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartName.php +++ b/modules/smartattributes/lib/Auth/Process/SmartName.php @@ -8,17 +8,20 @@ namespace SimpleSAML\Module\smartattributes\Auth\Process; * @author Andreas Ã…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ - class SmartName extends \SimpleSAML\Auth\ProcessingFilter { /** * Attributes which should be added/appended. * - * Assiciative array of arrays. + * @var array Associative array of arrays. */ private $attributes = []; + /** + * @param array $attributes + * @return string|null + */ private function getFullName($attributes) { if (isset($attributes['displayName'])) { @@ -57,6 +60,11 @@ class SmartName extends \SimpleSAML\Auth\ProcessingFilter return null; } + + /** + * @param string $userid + * @return string|null + */ private function getLocalUser($userid) { if (strpos($userid, '@') === false) { @@ -69,12 +77,14 @@ class SmartName extends \SimpleSAML\Auth\ProcessingFilter return null; } + /** * 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/statistics/bin/loganalyzer.php b/modules/statistics/bin/loganalyzer.php index 85ae093f3e31ab1dfdde61a1ce1ca304c4f17154..81e3d698a13114d12706d41086b83df988cc8d12 100755 --- a/modules/statistics/bin/loganalyzer.php +++ b/modules/statistics/bin/loganalyzer.php @@ -70,8 +70,8 @@ foreach ($results as $slot => $val) { /** * This function prints the help output. + * @return void */ - function printHelp() { global $progName; diff --git a/modules/statistics/bin/logcleaner.php b/modules/statistics/bin/logcleaner.php index b160cdab2780d2806831aa044a0e2655e1812bed..18432cf3852050d251fa8ba061bb6b611f2cd997 100755 --- a/modules/statistics/bin/logcleaner.php +++ b/modules/statistics/bin/logcleaner.php @@ -70,8 +70,8 @@ if (!$dryrun) { /** * This function prints the help output. + * @return void */ - function printHelp() { global $progName; diff --git a/modules/statistics/hooks/hook_configpage.php b/modules/statistics/hooks/hook_configpage.php index d9c1f1df7898b6b90d8c3f9cf6a869a47c63ff72..36853ed2d1f986e979fced5601c7f01c9c2eada3 100644 --- a/modules/statistics/hooks/hook_configpage.php +++ b/modules/statistics/hooks/hook_configpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the statistics module to the config page. * * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. + * @return void */ function statistics_hook_configpage(\SimpleSAML\XHTML\Template &$template) { diff --git a/modules/statistics/hooks/hook_cron.php b/modules/statistics/hooks/hook_cron.php index a3ee4952cc347d567d4d044f4bbd83b05b7a7b5d..f0de516faf163b78c5e35004807c743ebc5705aa 100644 --- a/modules/statistics/hooks/hook_cron.php +++ b/modules/statistics/hooks/hook_cron.php @@ -4,8 +4,8 @@ * Hook to run a cron job. * * @param array &$croninfo Output + * @return void */ - function statistics_hook_cron(&$croninfo) { assert(is_array($croninfo)); diff --git a/modules/statistics/hooks/hook_frontpage.php b/modules/statistics/hooks/hook_frontpage.php index 2dade3b2af4c7e9cbf5422819fa44ac18a9d580a..bb4e934179a781a213bd886286916190f09b0d6d 100644 --- a/modules/statistics/hooks/hook_frontpage.php +++ b/modules/statistics/hooks/hook_frontpage.php @@ -1,8 +1,10 @@ <?php + /** * Hook to add the modinfo module to the frontpage. * * @param array &$links The links on the frontpage, split into sections. + * @return void */ function statistics_hook_frontpage(&$links) { diff --git a/modules/statistics/hooks/hook_sanitycheck.php b/modules/statistics/hooks/hook_sanitycheck.php index 2a1a380be939d90ff7e870dddd9e5377a98cfe05..398266ca83659c455404a9856f6264a651971e11 100644 --- a/modules/statistics/hooks/hook_sanitycheck.php +++ b/modules/statistics/hooks/hook_sanitycheck.php @@ -1,8 +1,10 @@ <?php + /** * Hook to do sanity checks * * @param array &$hookinfo hookinfo + * @return void */ function statistics_hook_sanitycheck(&$hookinfo) { diff --git a/modules/statistics/lib/AccessCheck.php b/modules/statistics/lib/AccessCheck.php index 750a5d0526e0aa3aa494e6f0ffdba9dc70dbef6c..8750714415e647f8e7550c21e3e6ae1c477c06e8 100644 --- a/modules/statistics/lib/AccessCheck.php +++ b/modules/statistics/lib/AccessCheck.php @@ -7,13 +7,16 @@ namespace SimpleSAML\Module\statistics; * * @package SimpleSAMLphp */ - class AccessCheck { /** * Check that the user has access to the statistics. - * * If the user doesn't have access, send the user to the login page. + * + * @param \SimpleSAML\Configuration $statconfig + * @return void + * @throws \Exception + * @throws \SimpleSAML\Error\Exception */ public static function checkAccess(\SimpleSAML\Configuration $statconfig) { diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index 966012d6399329c6b5f250a3d68e53b9f22197e8..dc311d4d4d4c8eb66365261f9a62d5577f298050 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -6,21 +6,40 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Aggregator { + /** @var \SimpleSAML\Configuration */ private $statconfig; + + /** @var string */ private $statdir; + + /** @var string */ private $inputfile; + + /** @var array */ private $statrules; + + /** @var int */ private $offset; - private $metadata; + + /** @var array|null */ + private $metadata = null; + + /** @var bool */ private $fromcmdline; + + /** @var int */ private $starttime; + + /** @var array */ private $timeres; + /** * Constructor + * + * @param bool $fromcmdline */ public function __construct($fromcmdline = false) { @@ -32,11 +51,14 @@ class Aggregator $this->statrules = $this->statconfig->getValue('statrules'); $this->timeres = $this->statconfig->getValue('timeres'); $this->offset = $this->statconfig->getValue('offset', 0); - $this->metadata = null; $this->starttime = time(); } + + /** + * @return void + */ public function dumpConfig() { echo 'Statistics directory : '.$this->statdir."\n"; @@ -44,11 +66,19 @@ class Aggregator echo 'Offset : '.$this->offset."\n"; } + + /** + * @return void + */ public function debugInfo() { echo 'Memory usage : '.number_format(memory_get_usage() / 1048576, 2)." MB\n"; // 1024*1024=1048576 } + + /** + * @return void + */ public function loadMetadata() { $filename = $this->statdir.'/.stat.metadata'; @@ -59,11 +89,19 @@ class Aggregator $this->metadata = $metadata; } + + /** + * @return array|null + */ public function getMetadata() { return $this->metadata; } + + /** + * @return void + */ public function saveMetadata() { $this->metadata['time'] = time() - $this->starttime; @@ -74,6 +112,12 @@ class Aggregator file_put_contents($filename, serialize($this->metadata), LOCK_EX); } + + /** + * @param bool $debug + * @return array + * @throws \Exception + */ public function aggregate($debug = false) { $this->loadMetadata(); @@ -210,6 +254,12 @@ class Aggregator return $results; } + + /** + * @param array $content + * @param mixed $colrule + * @return string + */ private static function getDifCol($content, $colrule) { if (is_int($colrule)) { @@ -225,6 +275,12 @@ class Aggregator } } + + /** + * @param mixed $previous + * @param array $newdata + * @return array + */ private function cummulateData($previous, $newdata) { $dataset = []; @@ -244,6 +300,11 @@ class Aggregator return $dataset; } + + /** + * @param array $results + * @return void + */ public function store($results) { $datehandler = [ diff --git a/modules/statistics/lib/DateHandler.php b/modules/statistics/lib/DateHandler.php index ae9807df9ea6907992b4e25c7aad2921df49fcd2..17534e2d688b476d9b3592e969334523f38b46c0 100644 --- a/modules/statistics/lib/DateHandler.php +++ b/modules/statistics/lib/DateHandler.php @@ -2,25 +2,30 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class DateHandler { + /** @var int */ protected $offset; /** * Constructor * - * @param array $offset Date offset + * @param int $offset Date offset */ public function __construct($offset) { $this->offset = $offset; } + + /** + * @param int $timestamp + * @return int + */ protected function getDST($timestamp) { if (idate('I', $timestamp)) { @@ -29,12 +34,24 @@ class DateHandler return 0; } + + /** + * @param int $epoch + * @param int $slotsize + * @return float + */ public function toSlot($epoch, $slotsize) { $dst = $this->getDST($epoch); return floor(($epoch + $this->offset + $dst) / $slotsize); } + + /** + * @param int $slot + * @param int $slotsize + * @return int + */ public function fromSlot($slot, $slotsize) { $temp = $slot * $slotsize - $this->offset; @@ -42,16 +59,37 @@ class DateHandler return $slot * $slotsize - $this->offset - $dst; } + + /** + * @param int $epoch + * @param string $dateformat + * @return string + */ public function prettyDateEpoch($epoch, $dateformat) { return date($dateformat, $epoch); } + + /** + * @param int $slot + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyDateSlot($slot, $slotsize, $dateformat) { return $this->prettyDateEpoch($this->fromSlot($slot, $slotsize), $dateformat); } + + /** + * @param int $from + * @param int $to + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyHeader($from, $to, $slotsize, $dateformat) { $text = $this->prettyDateSlot($from, $slotsize, $dateformat); diff --git a/modules/statistics/lib/DateHandlerMonth.php b/modules/statistics/lib/DateHandlerMonth.php index 058795f57b05beb2964ef43fcda96edbac1c81c7..4404c44e14396e2d14429f7b27a516efda4b64c4 100644 --- a/modules/statistics/lib/DateHandlerMonth.php +++ b/modules/statistics/lib/DateHandlerMonth.php @@ -6,7 +6,6 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class DateHandlerMonth extends DateHandler { /** @@ -19,6 +18,12 @@ class DateHandlerMonth extends DateHandler $this->offset = $offset; } + + /** + * @param int $epoch + * @param int $slotsize + * @return int + */ public function toSlot($epoch, $slotsize) { $dsttime = $this->getDST($epoch) + $epoch; @@ -27,6 +32,12 @@ class DateHandlerMonth extends DateHandler return $slot; } + + /** + * @param int $slot + * @param int $slotsize + * @return int + */ public function fromSlot($slot, $slotsize) { $month = ($slot % 12); @@ -34,6 +45,14 @@ class DateHandlerMonth extends DateHandler return mktime(0, 0, 0, $month + 1, 1, $year); } + + /** + * @param int $from + * @param int $to + * @param int $slotsize + * @param string $dateformat + * @return string + */ public function prettyHeader($from, $to, $slotsize, $dateformat) { $month = ($from % 12) + 1; diff --git a/modules/statistics/lib/Graph/GoogleCharts.php b/modules/statistics/lib/Graph/GoogleCharts.php index 129639de50d103e4002b0504e7e3c3a117242141..22f4e9993039cbc0de09b2dbd4632a82564d1f3b 100644 --- a/modules/statistics/lib/Graph/GoogleCharts.php +++ b/modules/statistics/lib/Graph/GoogleCharts.php @@ -9,7 +9,6 @@ namespace SimpleSAML\Module\statistics\Graph; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class GoogleCharts { /** @@ -36,12 +35,21 @@ class GoogleCharts $this->y = $y; } + + /** + * @param array $axis + * @return string + */ private function encodeaxis($axis) { return join('|', $axis); } - // t:10.0,58.0,95.0 + /** + * t:10.0,58.0,95.0 + * @param array $datasets + * @return string + */ private function encodedata($datasets) { $setstr = []; @@ -51,6 +59,11 @@ class GoogleCharts return 'e:'.join(',', $setstr); } + + /** + * @param array $values + * @return string + */ public static function extEncode($values) // $max = 4095, $min = 0 { $extended_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.'; @@ -70,15 +83,17 @@ class GoogleCharts return $chardata; } + /** * Generate a Google Charts URL which points to a generated image. * More documentation on Google Charts here: * http://code.google.com/apis/chart/ * - * @param string $axis Axis - * @param string $axpis Axis positions + * @param array $axis Axis + * @param array $axispos Axis positions * @param array $datasets Datasets values - * @param integer $max Max value. Will be the topmost value on the Y-axis. + * @param array $maxes Max value. Will be the topmost value on the Y-axis. + * @return string */ public function show($axis, $axispos, $datasets, $maxes) { @@ -111,6 +126,12 @@ class GoogleCharts return $url; } + + /** + * @param array $axis + * @param array $datasets + * @return string + */ public function showPie($axis, $datasets) { $url = 'https://chart.apis.google.com/chart?'. @@ -129,6 +150,7 @@ class GoogleCharts return $url; } + /** * Takes a input value, and generates a value that suits better as a max * value on the Y-axis. In example 37.6 will not make a good max value, instead @@ -145,7 +167,8 @@ class GoogleCharts * } * </code> * - * @param integer $max Input value. + * @param int $max Input value. + * @return int */ public static function roof($max) { diff --git a/modules/statistics/lib/LogCleaner.php b/modules/statistics/lib/LogCleaner.php index eafb501904e36d7cac8883a3edb1b70da4bca12f..ee20e18bf457c8d5a37b2caa110cb8192d5b5cb5 100644 --- a/modules/statistics/lib/LogCleaner.php +++ b/modules/statistics/lib/LogCleaner.php @@ -2,21 +2,32 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class LogCleaner { + /** @var \SimpleSAML\Configuration */ private $statconfig; + + /** @var string */ private $statdir; + + /** @var string */ private $inputfile; + + /** @var array */ private $statrules; + + /** @var int */ private $offset; + /** * Constructor + * + * @param string|null $inputfile */ public function __construct($inputfile = null) { @@ -32,7 +43,8 @@ class LogCleaner } } - /* + + /** * @return void */ public function dumpConfig() @@ -43,9 +55,10 @@ class LogCleaner } - /* + /** * @param bool $debug * @return array + * @throws \Exception */ public function clean($debug = false) { @@ -125,10 +138,11 @@ class LogCleaner } - /* + /** * @param array $todelete * @param string $outputfile * @return void + * @throws \Exceeption */ public function store($todelete, $outputfile) { diff --git a/modules/statistics/lib/RatioDataset.php b/modules/statistics/lib/RatioDataset.php index 5449a3fd1797c03c08b9d04d8e530f58d8202be4..eaed4652402b2cdd884943847cbc37527d09c1a1 100644 --- a/modules/statistics/lib/RatioDataset.php +++ b/modules/statistics/lib/RatioDataset.php @@ -2,13 +2,15 @@ namespace SimpleSAML\Module\statistics; -/* +/** * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class RatioDataset extends StatDataset { + /** + * @return void + */ public function aggregateSummary() { /** @@ -42,6 +44,12 @@ class RatioDataset extends StatDataset $this->summary = array_reverse($this->summary, true); } + + /** + * @param string $k + * @param array $a + * @return int + */ private function ag($k, $a) { if (array_key_exists($k, $a)) { @@ -50,6 +58,12 @@ class RatioDataset extends StatDataset return 0; } + + /** + * @param int $v1 + * @param int $v2 + * @return int|float + */ private function divide($v1, $v2) { if ($v2 == 0) { @@ -58,6 +72,12 @@ class RatioDataset extends StatDataset return ($v1 / $v2); } + + /** + * @param array $result1 + * @param array $result2 + * @return array + */ public function combine($result1, $result2) { $combined = []; @@ -74,6 +94,10 @@ class RatioDataset extends StatDataset return $combined; } + + /** + * @return null + */ public function getPieData() { return null; diff --git a/modules/statistics/lib/Ruleset.php b/modules/statistics/lib/Ruleset.php index 755295c6cad3582c15531543310fc6ad242fdb5e..361ba994062bdbe4eb744609cd127b85aba73728 100644 --- a/modules/statistics/lib/Ruleset.php +++ b/modules/statistics/lib/Ruleset.php @@ -6,16 +6,25 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Ruleset { + /** \SimpleSAML\Configuration */ private $statconfig; + + /** @var array */ private $availrulenames; + + /** @var array */ private $availrules; + + /** @var array */ private $available; + /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig */ public function __construct($statconfig) { @@ -23,6 +32,10 @@ class Ruleset $this->init(); } + + /** + * @return void + */ private function init() { $statdir = $this->statconfig->getValue('statdir'); @@ -61,18 +74,30 @@ class Ruleset $this->availrulenames = $available_rules; } + + /** + * @return array + */ public function availableRules() { return $this->availrules; } + + /** + * @return array + */ public function availableRulesNames() { return $this->availrulenames; } + /** * Resolve which rule is selected. Taking user preference and checks if it exists. + * + * @param array|null $preferRule + * @return array|null */ private function resolveSelectedRule($preferRule = null) { @@ -85,6 +110,11 @@ class Ruleset return $rule; } + + /** + * @param array|null $preferRule + * @return \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule + */ public function getRule($preferRule) { $rule = $this->resolveSelectedRule($preferRule); diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php index 6868d023775dd2126b2532a83434403d9a6bf4c1..5183f12db4b19d3c1a192a992b6edaba835cd326 100644 --- a/modules/statistics/lib/StatDataset.php +++ b/modules/statistics/lib/StatDataset.php @@ -6,28 +6,53 @@ namespace SimpleSAML\Module\statistics; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class StatDataset { + /** @var \SimpleSAML\Configuration */ protected $statconfig; + + /** @var \SimpleSAML\Configuration */ protected $ruleconfig; + + /** @var \SimpleSAML\Configuration */ protected $timeresconfig; + + /** @var string */ protected $ruleid; + /** @var int */ protected $fileslot; + + /** @var string */ protected $timeres; + /** @var string */ protected $delimiter; + + /** @var array */ protected $results; + + /** @var array */ protected $summary; + + /** @var int */ protected $max; + /** @var \SimpleSAML\Module\statistics\DateHandler */ protected $datehandlerFile; + + /** @var \SimpleSAML\Module\statistics\DateHandler */ protected $datehandlerTick; /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param string $timeres + * @param int $fileslot */ public function __construct($statconfig, $ruleconfig, $ruleid, $timeres, $fileslot) { @@ -56,16 +81,29 @@ class StatDataset $this->loadData(); } + + /** + * @return int + */ public function getFileSlot() { return $this->fileslot; } + + /** + * @return string + */ public function getTimeRes() { return $this->timeres; } + + /** + * @param string $delimiter + * @return void + */ public function setDelimiter($delimiter = '_') { if (empty($delimiter)) { @@ -74,6 +112,10 @@ class StatDataset $this->delimiter = $delimiter; } + + /** + * @return string|null + */ public function getDelimiter() { if ($this->delimiter === '_') { @@ -82,6 +124,10 @@ class StatDataset return $this->delimiter; } + + /** + * @return void + */ public function calculateMax() { $maxvalue = 0; @@ -94,6 +140,10 @@ class StatDataset $this->max = Graph\GoogleCharts::roof($maxvalue); } + + /** + * @return array + */ public function getDebugData() { $debugdata = []; @@ -110,6 +160,10 @@ class StatDataset return $debugdata; } + + /** + * @return void + */ public function aggregateSummary() { // aggregate summary table from dataset. To be used in the table view @@ -127,6 +181,10 @@ class StatDataset $this->summary = array_reverse($this->summary, true); } + + /** + * @return array + */ public function getTopDelimiters() { // create a list of delimiter keys that has the highest total summary in this period @@ -144,6 +202,10 @@ class StatDataset return $topdelimiters; } + + /** + * @return array + */ public function availDelimiters() { $availDelimiters = []; @@ -153,6 +215,10 @@ class StatDataset return array_keys($availDelimiters); } + + /** + * @return array + */ public function getPieData() { $piedata = []; @@ -167,21 +233,37 @@ class StatDataset return $piedata; } + + /** + * @return int + */ public function getMax() { return $this->max; } + + /** + * @return array + */ public function getSummary() { return $this->summary; } + + /** + * @return array + */ public function getResults() { return $this->results; } + + /** + * @return array + */ public function getAxis() { $slotsize = $this->timeresconfig->getValue('slot'); @@ -209,8 +291,10 @@ class StatDataset return ['axis' => $axis, 'axispos' => $axispos]; } - /* + + /** * Walk through dataset to get percent values from max into dataset[]. + * @return array */ public function getPercentValues() { @@ -232,6 +316,11 @@ class StatDataset return $dataset; } + + /** + * @return array + * @throws \Exception + */ public function getDelimiterPresentation() { $config = \SimpleSAML\Configuration::getInstance(); @@ -257,6 +346,10 @@ class StatDataset return []; } + + /** + * @return array + */ public function getDelimiterPresentationPie() { $topdelimiters = $this->getTopDelimiters(); @@ -274,6 +367,10 @@ class StatDataset return $pieaxis; } + + /** + * @return void + */ public function loadData() { $statdir = $this->statconfig->getValue('statdir'); diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Base.php b/modules/statistics/lib/Statistics/FieldPresentation/Base.php index bb2568f1d6c8814acf4da00021d22ab7fb0ed8cb..8f0bd99c0086446922df494cace9df608e0151ca 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Base.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Base.php @@ -4,10 +4,21 @@ namespace SimpleSAML\Module\statistics\Statistics\FieldPresentation; class Base { + /** @var array */ protected $fields; + + /** @var \SimpleSAML\XHTML\Template */ protected $template; + + /** @var string */ protected $config; + + /** + * @param array $fields + * @param string $config + * @param \SimpleSAML\XHTML\Template $template + */ public function __construct($fields, $config, $template) { $this->fields = $fields; @@ -15,6 +26,10 @@ class Base $this->config = $config; } + + /** + * @return array + */ public function getPresentation() { return ['_' => 'Total']; diff --git a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php index 624d215b7936cf16c4ce7fa5327742e08c71557a..df88c8e4f710e6d97958cd2c41a2f5e71d99bdab 100644 --- a/modules/statistics/lib/Statistics/FieldPresentation/Entity.php +++ b/modules/statistics/lib/Statistics/FieldPresentation/Entity.php @@ -4,6 +4,9 @@ namespace SimpleSAML\Module\statistics\Statistics\FieldPresentation; class Entity extends Base { + /** + * @return array + */ public function getPresentation() { $mh = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); diff --git a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php index 875557bc8dab7c8a0896fe196208d9d57abf1e5b..77c3a20513b1bdff5eeb3c70732b2a165e25b4a8 100644 --- a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php +++ b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php @@ -6,16 +6,27 @@ namespace SimpleSAML\Module\statistics\Statistics\Rulesets; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class BaseRule { + /** @var \SimpleSAML\Configuration */ protected $statconfig; + + /** @var \SimpleSAML\Configuration */ protected $ruleconfig; + + /** @var string */ protected $ruleid; - protected $available; + + /** @var array|null */ + protected $available = null; /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param array $available */ public function __construct($statconfig, $ruleconfig, $ruleid, $available) { @@ -25,17 +36,24 @@ class BaseRule $this->ruleconfig = $ruleconfig; $this->ruleid = $ruleid; - $this->available = null; if (array_key_exists($ruleid, $available)) { $this->available = $available[$ruleid]; } } + + /** + * @return string + */ public function getRuleID() { return $this->ruleid; } + + /** + * @return array + */ public function availableTimeRes() { $timeresConfigs = $this->statconfig->getValue('timeres'); @@ -48,6 +66,11 @@ class BaseRule return $available_times; } + + /** + * @param string $timeres + * @return array + */ public function availableFileSlots($timeres) { $timeresConfigs = $this->statconfig->getValue('timeres'); @@ -74,6 +97,11 @@ class BaseRule return $available_times; } + + /** + * @param string $preferTimeRes + * @return string + */ protected function resolveTimeRes($preferTimeRes) { $timeresavailable = array_keys($this->available); @@ -86,6 +114,12 @@ class BaseRule return $timeres; } + + /** + * @param string $timeres + * @param string $preferTime + * @return int + */ protected function resolveFileSlot($timeres, $preferTime) { // Get which time (fileslot) to use.. First get a default, which is the most recent one. @@ -97,6 +131,12 @@ class BaseRule return $fileslot; } + + /** + * @param string $timeres + * @param string $preferTime + * @return array + */ public function getTimeNavigation($timeres, $preferTime) { $fileslot = $this->resolveFileSlot($timeres, $preferTime); @@ -118,6 +158,12 @@ class BaseRule return ['prev' => $available_times_prev, 'next' => $available_times_next]; } + + /** + * @param string $preferTimeRes + * @param string $preferTime + * @return \SimpleSAML\Module\statistics\StatDataset + */ public function getDataSet($preferTimeRes, $preferTime) { $timeres = $this->resolveTimeRes($preferTimeRes); diff --git a/modules/statistics/lib/Statistics/Rulesets/Ratio.php b/modules/statistics/lib/Statistics/Rulesets/Ratio.php index 1f76f6b4709791447db69970aafcf7d666e02175..ed3a6eb9936ae85fa5e72fbc1a92ef7f8474fda2 100644 --- a/modules/statistics/lib/Statistics/Rulesets/Ratio.php +++ b/modules/statistics/lib/Statistics/Rulesets/Ratio.php @@ -6,14 +6,22 @@ namespace SimpleSAML\Module\statistics\Statistics\Rulesets; * @author Andreas Ã…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ - class Ratio extends BaseRule { + /** @var \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule $refrule1 */ protected $refrule1; + + /** @var \SimpleSAML\Module\statistics\Statistics\Rulesets\BaseRule $refrule2 */ protected $refrule2; + /** * Constructor + * + * @param \SimpleSAML\Configuration $statconfig + * @param \SimpleSAML\Configuration $ruleconfig + * @param string $ruleid + * @param array $available */ public function __construct($statconfig, $ruleconfig, $ruleid, $available) { @@ -33,31 +41,63 @@ class Ratio extends BaseRule $this->refrule2 = new BaseRule($this->statconfig, $statruleConfig2, $refNames[1], $available); } + + /** + * @return array + */ public function availableTimeRes() { return $this->refrule1->availableTimeRes(); } + + /** + * @param string $timeres + * @return array + */ public function availableFileSlots($timeres) { return $this->refrule1->availableFileSlots($timeres); } + + /** + * @param string $preferTimeRes + * @return string + */ protected function resolveTimeRes($preferTimeRes) { return $this->refrule1->resolveTimeRes($preferTimeRes); } + + /** + * @param string $timeres + * @param string $preferTime + * @return int + */ protected function resolveFileSlot($timeres, $preferTime) { return $this->refrule1->resolveFileSlot($timeres, $preferTime); } + + /** + * @param string $timeres + * @param string $preferTime + * @return array + */ public function getTimeNavigation($timeres, $preferTime) { return $this->refrule1->getTimeNavigation($timeres, $preferTime); } + + /** + * @param string $preferTimeRes + * @param string $preferTime + * @return \SimpleSAML\Module\statistics\RatioDataset + */ public function getDataSet($preferTimeRes, $preferTime) { $timeres = $this->resolveTimeRes($preferTimeRes); diff --git a/modules/statistics/lib/StatisticsController.php b/modules/statistics/lib/StatisticsController.php index 2da8806a74faeb4c47325ac7e31ebbe473960489..5110307931100cd267eaef95f91fb1163459a42f 100644 --- a/modules/statistics/lib/StatisticsController.php +++ b/modules/statistics/lib/StatisticsController.php @@ -203,6 +203,14 @@ class StatisticsController return $t; } + + /** + * @param \SimpleSAML\XHTML\Template $t + * @param string $type + * @param string|null $key + * @param string|null $value + * @return string|array + */ private function getBaseURL($t, $type = 'get', $key = null, $value = null) { $vars = [ diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php index 7011126ea54ccd23085772ace12510fb5f47a6c1..544a9c4f7a851a15b223db6fa099bc5446e0418d 100644 --- a/modules/statistics/www/showstats.php +++ b/modules/statistics/www/showstats.php @@ -151,6 +151,14 @@ $t->data['jquery'] = ['core' => false, 'ui' => true, 'css' => true]; $t->show(); + +/** + * @param \SimpleSAML\XHTML\Template $t + * @param string $type + * @param string|null $key + * @param string|null $value + * @return string|array + */ function getBaseURL($t, $type = 'get', $key = null, $value = null) { $vars = [ diff --git a/psalm.xml b/psalm.xml index d7cb185f722a581a51df87e941ce87aaf4ff385d..31f0f3b8e2640072ba3627b2945cd7dbb66e5c84 100644 --- a/psalm.xml +++ b/psalm.xml @@ -27,4 +27,9 @@ <UnusedClass errorLevel="info" /> <PossiblyUnusedMethod errorLevel="info" /> </issueHandlers> + + <stubs> + <file name="tests/Utils/Stubs/krb5.php" /> + <file name="tests/Utils/Stubs/radius.php" /> + </stubs> </psalm> diff --git a/tests/Utils/Stubs/krb5.php b/tests/Utils/Stubs/krb5.php new file mode 100644 index 0000000000000000000000000000000000000000..14e86b309e0e0ce6b3bb282b8700bba10968a9fb --- /dev/null +++ b/tests/Utils/Stubs/krb5.php @@ -0,0 +1,173 @@ +<?php + +class KRB5NegotiateAuth +{ + /** + * @param string $keytab + * @param string $spn + */ + public function __construct($keytab, $spn) + { + } + + + /** + * @return bool + */ + public function doAuthentication() + { + } + + + /** + * @return string + */ + public function getAuthenticatedUser() + { + } + + + /** + * @param KRB5CCache $ccache + * @return void + */ + public function getDelegatedCredentials(KRB5CCache $ccache) + { + } +} + + +class KRB5CCache +{ + /** + * + */ + public function __construct() + { + } + + + /** + * @return string + */ + public function getName() + { + } + + + /** + * @param string $src + * @return bool + */ + public function open($src) + { + } + + + /** + * @param string $dest + * @return bool + */ + public function save($dest) + { + } + + + /** + * @param string $principal + * @param string $pass + * @param array|null $options + * @return bool + */ + public function initPassword($principal, $pass, $options = null) + { + } + + + /** + * @param string $principal + * @param string $keytab_file + * @param array|null $options + * @return bool + */ + public function initKeytab($principal, $keytab_file, $options = null) + { + } + + + /** + * @return string + */ + public function getPrincipal() + { + } + + + /** + * @return string + */ + public function getRealm() + { + } + + + /** + * @return array + */ + public function getLifetime() + { + } + + + /** + * @return array + */ + public function getEntries() + { + } + + + /** + * @param int $timeRemain + * @return bool + */ + public function isValid($timeRemain = 0) + { + } + + + /** + * @param string|null $prefix + * @return array + */ + public function getTktAttrs($prefix = null) + { + } + + + /** + * @return bool + */ + public function renew() + { + } + + + /** + * @param string $principal + * @param string $oldpass + * @param string $newpass + * @return bool + */ + public function changePassword($principal, $oldpass, $newpass) + { + } + + + /** + * @return array + */ + public function getExpirationTime() + { + } +} diff --git a/tests/Utils/Stubs/radius.php b/tests/Utils/Stubs/radius.php new file mode 100644 index 0000000000000000000000000000000000000000..6b886beac28f1c2cc2c5a01f3bb530f65e1b7a24 --- /dev/null +++ b/tests/Utils/Stubs/radius.php @@ -0,0 +1,397 @@ +<?php +/** + * Radius constants + * @link https://secure.php.net/manual/en/radius.constants.php + */ +/** The maximum length of MPPE keys. */ +define('RADIUS_MPPE_KEY_LEN ', 16); + +/** + * RADIUS Options + * @link https://secure.php.net/manual/en/radius.constants.options.php + */ + +/** When set, this option will result in the attribute value being salt-encrypted. */ +define('RAD_OPTION_TAG', 1); +/** When set, this option will result in the attribute value being tagged with the value of the tag parameter. */ +define('RADIUS_OPTION_SALT', 2); + +/** + * RADIUS Packet Types + * @link https://secure.php.net/manual/en/radius.constants.packets.php + */ + +/** An Access-Request, used to authenticate a user against a RADIUS server. Access request packets must include a <b>RADIUS_NAS_IP_ADDRESS</b> or a <b>RADIUS_NAS_IDENTIFIER</b> attribute, must also include a <b>RADIUS_USER_PASSWORD</b>, <b>RADIUS_CHAP_PASSWORD</b> or a <b>RADIUS_STATE</b> attribute, and should include a <b>RADIUS_USER_NAME</b> attribute. */ +define('RADIUS_ACCESS_REQUEST', 1); + +/** An Access-Accept response to an Access-Request indicating that the RADIUS server authenticated the user successfully. */ +define('RADIUS_ACCESS_ACCEPT', 2); + +/** An Access-Reject response to an Access-Request indicating that the RADIUS server could not authenticate the user. */ +define('RADIUS_ACCESS_REJECT', 3); + +/** An Accounting-Request, used to convey accounting information for a service to the RADIUS server. */ +define('RADIUS_ACCOUNTING_REQUEST', 4); + +/** An Accounting-Response response to an Accounting-Request. */ +define('RADIUS_ACCOUNTING_RESPONSE', 5); + +/** An Access-Challenge response to an Access-Request indicating that the RADIUS server requires further information in another Access-Request before authenticating the user. */ +define('RADIUS_ACCESS_CHALLENGE', 11); + +/** + * A Disconnect-Request, sent from the RADIUS server to indicate that the user session must be terminated. + * @since 1.3.0 + */ +define('RADIUS_DISCONNECT_REQUEST', 40); + +/** + * A Disconnect-ACK, sent to the RADIUS server to indicate that the user session has been terminated. + * @since 1.3.0 + */ +define('RADIUS_DISCONNECT_ACK', 41); + +/** + * A Disconnect-NAK, sent to the RADIUS server to indicate that the user session could not be terminated. + * @since 1.3.0 + */ +define('RADIUS_DISCONNECT_NAK', 42); + +/** + * A CoA-Request, sent from the RADIUS server to indicate that the authorisations within the user session have changed. A response must be sent in the form of a CoA-ACK or a CoA-NAK. + * @since 1.3.0 + */ +define('RADIUS_COA_REQUEST', 43); + +/** + * A CoA-ACK, sent to the RADIUS server to indicate that the user authorisations have been updated. + * @since 1.3.0 + */ +define('RADIUS_COA_ACK', 44); + +/** + * A CoA-NAK, sent to the RADIUS server to indicate that the user authorisations could not be updated. + * @since 1.3.0 + */ +define('RADIUS_COA_NAK', 45); + +/** + * RADIUS Attribute Types + * @link https://secure.php.net/manual/en/radius.constants.attributes.php + */ + +/** The User-Name attribute. The attribute value is expected to be a string containing the name of the user being authenticated, and can be set using {@see radius_put_attr()}. */ +define('RADIUS_USER_NAME', 1); + +/** + * The User-Password attribute. The attribute value is expected to be a string containing the user's password, and can be set using {@see radius_put_attr()}. This value will be obfuscated on transmission as described in section 5.2 of RFC 2865. + * @link https://secure.php.net/manual/de/radius.constants.attributes.php */ +define('RADIUS_USER_PASSWORD', 2); + +/** The Chap-Password attribute. The attribute value is expected to be a string with the first byte containing the CHAP identifier, and the subsequent 16 bytes containing the MD5 hash of the CHAP identifier, the plaintext password and the CHAP challenge value concatenated together. Note that the CHAP challenge value should also be sent separately in a <b>{@see RADIUS_CHAP_CHALLENGE}</b> attribute. */ +define('RADIUS_CHAP_PASSWORD', 3); + +/** The NAS-IP-Address attribute. The attribute value is expected to the IP address of the RADIUS client encoded as an integer, which can be set using {@see radius_put_addr()}. */ +define('RADIUS_NAS_IP_ADDRESS', 4); + +/** The NAS-Port attribute. The attribute value is expected to be the physical port of the user on the RADIUS client encoded as an integer, which can be set using {@see radius_put_int()}. */ +define('RADIUS_NAS_PORT', 5); + +/** + * The Service-Type attribute. The attribute value indicates the service type the user is requesting, and is expected to be an integer, which can be set using {@see radius_put_int()}. + * A number of constants are provided to represent the possible values of this attribute. They include: + * - RADIUS_LOGIN + * - RADIUS_FRAMED + * - RADIUS_CALLBACK_LOGIN + * - RADIUS_CALLBACK_FRAMED + * - RADIUS_OUTBOUND + * - RADIUS_ADMINISTRATIVE + * - RADIUS_NAS_PROMPT + * - RADIUS_AUTHENTICATE_ONLY + * - RADIUS_CALLBACK_NAS_PROMPT + */ +define('RADIUS_SERVICE_TYPE', 6); +define('RADIUS_LOGIN', 1); +define('RADIUS_FRAMED', 2); +define('RADIUS_CALLBACK_LOGIN', 3); +define('RADIUS_CALLBACK_FRAMED', 4); +define('RADIUS_OUTBOUND', 5); +define('RADIUS_ADMINISTRATIVE', 6); +define('RADIUS_NAS_PROMPT', 7); +define('RADIUS_AUTHENTICATE_ONLY', 8); +define('RADIUS_CALLBACK_NAS_PROMPT', 9); + +/** + * The Framed-Protocol attribute. The attribute value is expected to be an integer indicating the framing to be used for framed access, and can be set using {@see radius_put_int()}. The possible attribute values include these constants: + * - RADIUS_PPP + * - RADIUS_SLIP + * - RADIUS_ARAP + * - RADIUS_GANDALF + * - RADIUS_XYLOGICS + */ +define('RADIUS_FRAMED_PROTOCOL', 7); +define('RADIUS_PPP', 1); +define('RADIUS_SLIP', 2); +define('RADIUS_ARAP', 3); +define('RADIUS_GANDALF', 4); +define('RADIUS_XYLOGICS', 5); + +/** The Framed-IP-Address attribute. The attribute value is expected to be the address of the user's network encoded as an integer, which can be set using {@see radius_put_addr()} and retrieved using {@see radius_cvt_addr()}. */ +define('RADIUS_FRAMED_IP_ADDRESS', 8); + +/** The Framed-IP-Netmask attribute. The attribute value is expected to be the netmask of the user's network encoded as an integer, which can be set using {@see radius_put_addr()} and retrieved using {@see radius_cvt_addr()}. */ +define('RADIUS_FRAMED_IP_NETMASK', 9); + +/** + * The Framed-Routing attribute. The attribute value is expected to be an integer indicating the routing method for the user, which can be set using {@see radius_put_int()}.<br> + * <br> + * Possible values include: + * - 0: No routing + * - 1: Send routing packets + * - 2: Listen for routing packets + * - 3: Send and listen + */ +define('RADIUS_FRAMED_ROUTING', 10); + +/** The Filter-ID attribute. The attribute value is expected to be an implementation-specific, human-readable string of filters, which can be set using {@see radius_put_attr()}.*/ +define('RADIUS_FILTER_ID', 11); + +/** The Framed-MTU attribute. The attribute value is expected to be an integer indicating the MTU to be configured for the user, and can be set using {@see radius_put_int()}.*/ +define('RADIUS_FRAMED_MTU', 12); + +/** The Framed-Compression attribute. The attribute value is expected to be an integer indicating the compression protocol to be used, and can be set using radius_put_int(). Possible values include these constants: + * - <b>RADIUS_COMP_NONE</b>: No compression + * - <b>RADIUS_COMP_VJ</b>: VJ TCP/IP header compression + * - <b>RADIUS_COMP_IPXHDR</b>: IPX header compression + * - <b>RADIUS_COMP_STAC_LZS</b>: Stac-LZS compression (added in PECL radius 1.3.0b2) + */ +define('RADIUS_FRAMED_COMPRESSION', 13); +define('RADIUS_COMP_NONE', 0); +define('RADIUS_COMP_VJ', 1); +define('RADIUS_COMP_IPXHDR', 2); + +/** The Login-IP-Host attribute. The attribute value is expected to the IP address to connect the user to, encoded as an integer, which can be set using {@see radius_put_addr()}. */ +define('RADIUS_LOGIN_IP_HOST', 14); + +/** The Login-Service attribute. The attribute value is an integer indicating the service to connect the user to on the login host. The value can be converted to a PHP integer via {@see radius_cvt_int()}.*/ +define('RADIUS_LOGIN_SERVICE', 15); +define('RADIUS_LOGIN_TCP_PORT', 16); +define('RADIUS_REPLY_MESSAGE', 18); +define('RADIUS_CALLBACK_NUMBER', 19); +define('RADIUS_CALLBACK_ID', 20); +define('RADIUS_FRAMED_ROUTE', 22); +define('RADIUS_FRAMED_IPX_NETWORK', 23); +define('RADIUS_STATE', 24); +define('RADIUS_CLASS', 25); +define('RADIUS_VENDOR_SPECIFIC', 26); +define('RADIUS_SESSION_TIMEOUT', 27); +define('RADIUS_IDLE_TIMEOUT', 28); +define('RADIUS_TERMINATION_ACTION', 29); +define('RADIUS_CALLED_STATION_ID', 30); +define('RADIUS_CALLING_STATION_ID', 31); +define('RADIUS_NAS_IDENTIFIER', 32); +define('RADIUS_PROXY_STATE', 33); +define('RADIUS_LOGIN_LAT_SERVICE', 34); +define('RADIUS_LOGIN_LAT_NODE', 35); +define('RADIUS_LOGIN_LAT_GROUP', 36); +define('RADIUS_FRAMED_APPLETALK_LINK', 37); +define('RADIUS_FRAMED_APPLETALK_NETWORK', 38); +define('RADIUS_FRAMED_APPLETALK_ZONE', 39); +define('RADIUS_CHAP_CHALLENGE', 60); +define('RADIUS_NAS_PORT_TYPE', 61); +define('RADIUS_ASYNC', 0); +define('RADIUS_SYNC', 1); +define('RADIUS_ISDN_SYNC', 2); +define('RADIUS_ISDN_ASYNC_V120', 3); +define('RADIUS_ISDN_ASYNC_V110', 4); +define('RADIUS_VIRTUAL', 5); +define('RADIUS_PIAFS', 6); +define('RADIUS_HDLC_CLEAR_CHANNEL', 7); +define('RADIUS_X_25', 8); +define('RADIUS_X_75', 9); +define('RADIUS_G_3_FAX', 10); +define('RADIUS_SDSL', 11); +define('RADIUS_ADSL_CAP', 12); +define('RADIUS_ADSL_DMT', 13); +define('RADIUS_IDSL', 14); +define('RADIUS_ETHERNET', 15); +define('RADIUS_XDSL', 16); +define('RADIUS_CABLE', 17); +define('RADIUS_WIRELESS_OTHER', 18); +define('RADIUS_WIRELESS_IEEE_802_11', 19); +define('RADIUS_PORT_LIMIT', 62); +define('RADIUS_LOGIN_LAT_PORT', 63); +define('RADIUS_CONNECT_INFO', 77); +define('RADIUS_NAS_IPV6_ADDRESS', 95); +define('RADIUS_FRAMED_INTERFACE_ID', 96); +define('RADIUS_FRAMED_IPV6_PREFIX', 97); +define('RADIUS_LOGIN_IPV6_HOST', 98); +define('RADIUS_FRAMED_IPV6_ROUTE', 99); +define('RADIUS_FRAMED_IPV6_POOL', 100); +define('RADIUS_ERROR_CAUSE', 101); +define('RADIUS_ERROR_CAUSE_RESIDUAL_SESSION_CONTEXT_REMOVED', 201); +define('RADIUS_ERROR_CAUSE_INVALID_EAP_PACKET', 202); +define('RADIUS_ERROR_CAUSE_UNSUPPORTED_ATTRIBUTE', 401); +define('RADIUS_ERROR_CAUSE_MISSING_ATTRIBUTE', 402); +define('RADIUS_ERROR_CAUSE_NAS_IDENTIFICATION_MISMATCH', 403); +define('RADIUS_ERROR_CAUSE_INVALID_REQUEST', 404); +define('RADIUS_ERROR_CAUSE_UNSUPPORTED_SERVICE', 405); +define('RADIUS_ERROR_CAUSE_UNSUPPORTED_EXCEPTION', 406); +define('RADIUS_ERROR_CAUSE_ADMINISTRATIVELY_PROHIBITED', 501); +define('RADIUS_ERROR_CAUSE_REQUEST_NOT_ROUTABLE', 502); +define('RADIUS_ERROR_CAUSE_SESSION_CONTEXT_NOT_FOUND', 503); +define('RADIUS_ERROR_CAUSE_SESSION_CONTEXT_NOT_REMOVABLE', 504); +define('RADIUS_ERROR_CAUSE_OTHER_PROXY_PROCESSING_ERROR', 505); +define('RADIUS_ERROR_CAUSE_RESOURCES_UNAVAILABLE', 506); +define('RADIUS_ERROR_CAUSE_REQUEST_INITIATED', 507); +define('RADIUS_ACCT_STATUS_TYPE', 40); +define('RADIUS_START', 1); +define('RADIUS_STOP', 2); +define('RADIUS_ACCOUNTING_ON', 7); +define('RADIUS_ACCOUNTING_OFF', 8); +define('RADIUS_ACCT_DELAY_TIME', 41); +define('RADIUS_ACCT_INPUT_OCTETS', 42); +define('RADIUS_ACCT_OUTPUT_OCTETS', 43); +define('RADIUS_ACCT_SESSION_ID', 44); +define('RADIUS_ACCT_AUTHENTIC', 45); +define('RADIUS_AUTH_RADIUS', 1); +define('RADIUS_AUTH_LOCAL', 2); +define('RADIUS_AUTH_REMOTE', 3); +define('RADIUS_ACCT_SESSION_TIME', 46); +define('RADIUS_ACCT_INPUT_PACKETS', 47); +define('RADIUS_ACCT_OUTPUT_PACKETS', 48); +define('RADIUS_ACCT_TERMINATE_CAUSE', 49); +define('RADIUS_TERM_USER_REQUEST', 1); +define('RADIUS_TERM_LOST_CARRIER', 2); +define('RADIUS_TERM_LOST_SERVICE', 3); +define('RADIUS_TERM_IDLE_TIMEOUT', 4); +define('RADIUS_TERM_SESSION_TIMEOUT', 5); +define('RADIUS_TERM_ADMIN_RESET', 6); +define('RADIUS_TERM_ADMIN_REBOOT', 7); +define('RADIUS_TERM_PORT_ERROR', 8); +define('RADIUS_TERM_NAS_ERROR', 9); +define('RADIUS_TERM_NAS_REQUEST', 10); +define('RADIUS_TERM_NAS_REBOOT', 11); +define('RADIUS_TERM_PORT_UNNEEDED', 12); +define('RADIUS_TERM_PORT_PREEMPTED', 13); +define('RADIUS_TERM_PORT_SUSPENDED', 14); +define('RADIUS_TERM_SERVICE_UNAVAILABLE', 15); +define('RADIUS_TERM_CALLBACK', 16); +define('RADIUS_TERM_USER_ERROR', 17); +define('RADIUS_TERM_HOST_REQUEST', 18); +define('RADIUS_ACCT_MULTI_SESSION_ID', 50); +define('RADIUS_ACCT_LINK_COUNT', 51); +define('RADIUS_VENDOR_MICROSOFT', 311); +define('RADIUS_MICROSOFT_MS_CHAP_RESPONSE', 1); +define('RADIUS_MICROSOFT_MS_CHAP_ERROR', 2); +define('RADIUS_MICROSOFT_MS_CHAP_PW_1', 3); +define('RADIUS_MICROSOFT_MS_CHAP_PW_2', 4); +define('RADIUS_MICROSOFT_MS_CHAP_LM_ENC_PW', 5); +define('RADIUS_MICROSOFT_MS_CHAP_NT_ENC_PW', 6); +define('RADIUS_MICROSOFT_MS_MPPE_ENCRYPTION_POLICY', 7); +define('RADIUS_MICROSOFT_MS_MPPE_ENCRYPTION_TYPES', 8); +define('RADIUS_MICROSOFT_MS_RAS_VENDOR', 9); +define('RADIUS_MICROSOFT_MS_CHAP_DOMAIN', 10); +define('RADIUS_MICROSOFT_MS_CHAP_CHALLENGE', 11); +define('RADIUS_MICROSOFT_MS_CHAP_MPPE_KEYS', 12); +define('RADIUS_MICROSOFT_MS_BAP_USAGE', 13); +define('RADIUS_MICROSOFT_MS_LINK_UTILIZATION_THRESHOLD', 14); +define('RADIUS_MICROSOFT_MS_LINK_DROP_TIME_LIMIT', 15); +define('RADIUS_MICROSOFT_MS_MPPE_SEND_KEY', 16); +define('RADIUS_MICROSOFT_MS_MPPE_RECV_KEY', 17); +define('RADIUS_MICROSOFT_MS_RAS_VERSION', 18); +define('RADIUS_MICROSOFT_MS_OLD_ARAP_PASSWORD', 19); +define('RADIUS_MICROSOFT_MS_NEW_ARAP_PASSWORD', 20); +define('RADIUS_MICROSOFT_MS_ARAP_PASSWORD_CHANGE_REASON', 21); +define('RADIUS_MICROSOFT_MS_FILTER', 22); +define('RADIUS_MICROSOFT_MS_ACCT_AUTH_TYPE', 23); +define('RADIUS_MICROSOFT_MS_ACCT_EAP_TYPE', 24); +define('RADIUS_MICROSOFT_MS_CHAP2_RESPONSE', 25); +define('RADIUS_MICROSOFT_MS_CHAP2_SUCCESS', 26); +define('RADIUS_MICROSOFT_MS_CHAP2_PW', 27); +define('RADIUS_MICROSOFT_MS_PRIMARY_DNS_SERVER', 28); +define('RADIUS_MICROSOFT_MS_SECONDARY_DNS_SERVER', 29); +define('RADIUS_MICROSOFT_MS_PRIMARY_NBNS_SERVER', 30); +define('RADIUS_MICROSOFT_MS_SECONDARY_NBNS_SERVER', 31); +define('RADIUS_MICROSOFT_MS_ARAP_CHALLENGE', 33); +define('RADIUS_OPTION_NONE', RADIUS_OPTION_NONE); +define('RADIUS_OPTION_TAGGED', RADIUS_OPTION_TAGGED); +define('RADIUS_OPTION_SALT', RADIUS_OPTION_SALT); + +/** + * Creates a Radius handle for accounting + * @link https://secure.php.net/manual/en/function.radius-acct-open.php + * @return resource|bool Returns a handle on success, <b>FALSE</b> on error. This function only fails if insufficient memory is available. + * @since 1.1.0 + */ +function radius_acct_open() +{ +} + +/** + * <b>radius_add_server()</b> may be called multiple times, and it may be used together with {@see radius_config()}. At most 10 servers may be specified. When multiple servers are given, they are tried in round-robin fashion until a valid response is received, or until each server's max_tries limit has been reached. + * @link https://secure.php.net/manual/en/function.radius-add-server.php + * @param resource $radius_handle + * @param string $hostname The <b>hostname</b> parameter specifies the server host, either as a fully qualified domain name or as a dotted-quad IP address in text form. + * @param int $port The <b>port</b> specifies the UDP port to contact on the server.<br> + * If port is given as 0, the library looks up the radius/udp or radacct/udp service in the network services database, and uses the port found there.<br> + * If no entry is found, the library uses the standard Radius ports, 1812 for authentication and 1813 for accounting. + * @param string $secret The shared secret for the server host is passed to the <b>secret</b> parameter. The Radius protocol ignores all but the leading 128 bytes of the shared secret. + * @param int $timeout The timeout for receiving replies from the server is passed to the <b>timeout</b> parameter, in units of seconds. + * @param int $max_tries The maximum number of repeated requests to make before giving up is passed into the <b>max_tries</b>. + * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + * @see radius_config() + * @since 1.1.0 + */ +function radius_add_server($radius_handle, $hostname, $port, $secret, $timeout, $max_tries) +{ +} + +/** + * Creates a Radius handle for authentication + * @link https://secure.php.net/manual/en/function.radius-auth-open.php + * @return resource|bool Returns a handle on success, <b>FALSE</b> on error. This function only fails if insufficient memory is available. + * @since 1.1.0 + */ +function radius_auth_open() +{ +} + +/** + * Free all ressources. It is not needed to call this function because php frees all resources at the end of each request. + * @link https://secure.php.net/manual/en/function.radius-close.php + * @param resource $radius_handle + * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + * @since 1.1.0 + */ +function radius_close($radius_handle) +{ +} + +/** + * Before issuing any Radius requests, the library must be made aware of the servers it can contact. The easiest way to configure the library is to call <b>radius_config()</b>. <b>radius_config()</b> causes the library to read a configuration file whose format is described in radius.conf. + * @link https://secure.php.net/manual/en/function.radius-config.php + * @link https://www.freebsd.org/cgi/man.cgi?query=radius.conf + * @param resource $radius_handle + * @param string $file The pathname of the configuration file is passed as the file argument to {@see radius_config()}. The library can also be configured programmatically by calls to <b>{@see radius_add_server()}</b>. + * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + * @see radius_add_server() + * @since 1.1.0 + */ +function radius_config($radius_handle, $file) +{ +} + +/** + * A Radius request consists of a code specifying the kind of request, and zero or more attributes which provide additional information. To begin constructing a new request, call <b>radius_create_request()</b>.<br /> + * <b>Note:</b> Attention: You must call this function, before you can put any attribute! + * @link https://secure.php.net/manual/en/function.radius-create-request.php + * @param resource $radius_handle + * @param int $type Type is <b>RADIUS_ACCESS_REQUEST</b> or <b>RADIUS_ACCOUNTING_REQUEST</b>. + * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + * @see radius_send_request() + * @since 1.1.0 + */ +function radius_create_request($radius_handle, $type) +{ +}