From f5b94bdd6cb3ead7aa8e2ed97ed45f37f9e04009 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sun, 26 Aug 2018 02:11:56 +0200 Subject: [PATCH] modules: PSR-2 --- modules/adfs/lib/IdP/ADFS.php | 34 ++- modules/adfs/www/idp/metadata.php | 10 +- modules/adfs/www/idp/prp.php | 2 +- .../lib/Auth/Process/ExpiryWarning.php | 1 - modules/authX509/templates/X509error.php | 25 +- modules/authX509/templates/X509warning.php | 8 +- .../lib/Auth/Process/OTP2YubiPrefix.php | 6 +- .../authYubiKey/lib/Auth/Source/YubiKey.php | 20 +- modules/authYubiKey/libextinc/Yubico.php | 24 +- .../authYubiKey/templates/yubikeylogin.php | 36 +-- .../authfacebook/extlibinc/base_facebook.php | 52 ++-- .../authfacebook/lib/Auth/Source/Facebook.php | 25 +- modules/authfacebook/www/linkback.php | 23 +- .../authlinkedin/lib/Auth/Source/LinkedIn.php | 9 +- modules/authlinkedin/www/linkback.php | 6 +- .../authorize/lib/Auth/Process/Authorize.php | 15 +- modules/authorize/templates/authorize_403.php | 14 +- modules/authorize/www/authorize_403.php | 5 +- .../authtwitter/lib/Auth/Source/Twitter.php | 31 ++- modules/authtwitter/www/linkback.php | 18 +- modules/authwindowslive/www/linkback.php | 5 +- modules/cas/lib/Auth/Source/CAS.php | 47 ++-- modules/cas/www/linkback.php | 2 - modules/cdc/lib/Server.php | 4 +- modules/consent/lib/Auth/Process/Consent.php | 54 ++-- modules/consent/lib/Consent/Store/Cookie.php | 26 +- .../consent/lib/Consent/Store/Database.php | 124 ++++----- modules/consent/www/getconsent.php | 15 +- .../consentAdmin/templates/consentadmin.php | 31 ++- .../templates/consentadminajax.php | 2 +- .../www/assets/js/consentAdmin.js | 2 +- modules/consentAdmin/www/consentAdmin.php | 39 ++- modules/core/hooks/hook_sanitycheck.php | 3 +- modules/core/lib/ACL.php | 4 +- .../core/lib/Auth/Process/AttributeAlter.php | 3 +- .../core/lib/Auth/Process/AttributeCopy.php | 1 - modules/core/lib/Auth/Process/Cardinality.php | 45 +++- .../lib/Auth/Process/CardinalitySingle.php | 6 +- .../lib/Auth/Process/ExtendIdPSession.php | 4 +- .../core/lib/Auth/Process/GenerateGroups.php | 2 +- modules/core/lib/Auth/Process/PHP.php | 4 +- .../core/lib/Storage/SQLPermanentStorage.php | 10 +- .../core/templates/authsource_list.tpl.php | 3 +- .../core/templates/cardinality_error.tpl.php | 21 +- modules/core/templates/frontpage_auth.tpl.php | 30 +-- .../core/templates/frontpage_config.tpl.php | 105 ++++---- .../templates/frontpage_federation.tpl.php | 33 ++- .../core/templates/frontpage_welcome.tpl.php | 31 +-- modules/core/templates/loginuserpass.php | 110 ++++---- modules/core/templates/logout-iframe.php | 55 ++-- modules/core/templates/no_metadata.tpl.php | 11 +- modules/core/templates/no_state.tpl.php | 23 +- modules/core/templates/short_sso_interval.php | 14 +- modules/core/www/cardinality_error.php | 5 +- modules/core/www/cleardiscochoices.php | 1 - modules/core/www/frontpage_auth.php | 2 - modules/core/www/frontpage_config.php | 6 +- modules/core/www/frontpage_federation.php | 1 - modules/core/www/idp/logout-iframe.js | 16 +- modules/core/www/login-admin.php | 1 - modules/core/www/loginuserpass.php | 17 +- modules/core/www/loginuserpassorg.php | 47 +++- modules/cron/config-templates/module_cron.php | 2 +- modules/cron/templates/croninfo-result.php | 3 +- modules/cron/templates/croninfo.tpl.php | 4 +- .../config-templates/module_discopower.php | 6 +- modules/discopower/lib/PowerIdPDisco.php | 12 +- modules/discopower/templates/disco.tpl.php | 242 ++++++++---------- modules/discopower/www/assets/css/disco.css | 10 +- .../www/assets/js/jquery.livesearch.js | 72 +++--- .../discopower/www/assets/js/quicksilver.js | 113 ++++---- modules/discopower/www/assets/js/suggest.js | 38 +-- modules/discopower/www/disco.php | 5 +- .../exampleauth/lib/Auth/Source/UserPass.php | 8 +- modules/exampleauth/www/authpage.php | 5 +- .../lib/Auth/Process/ExpiryDate.php | 8 +- .../expirycheck/templates/about2expire.php | 25 +- modules/expirycheck/templates/expired.php | 14 +- .../Auth/Process/AttributeAddUsersGroups.php | 17 +- modules/ldap/lib/Auth/Process/BaseFilter.php | 1 - modules/ldap/lib/Auth/Source/LDAP.php | 6 +- modules/ldap/lib/Auth/Source/LDAPMulti.php | 21 +- modules/ldap/lib/ConfigHelper.php | 51 +++- modules/memcacheMonitor/www/memcachestat.php | 66 ++--- .../config-templates/config-metarefresh.php | 2 +- modules/metarefresh/hooks/hook_cron.php | 10 +- modules/metarefresh/lib/ARP.php | 2 +- modules/metarefresh/lib/MetaLoader.php | 73 +++--- modules/metarefresh/templates/fetch.tpl.php | 19 +- modules/metarefresh/www/fetch.php | 3 +- .../multiauth/lib/Auth/Source/MultiAuth.php | 23 +- modules/multiauth/www/selectsource.php | 13 +- .../negotiate/lib/Auth/Source/Negotiate.php | 51 ++-- modules/negotiate/www/backend.php | 5 +- modules/negotiate/www/retry.php | 5 +- .../oauth/config-template/module_oauth.php | 6 +- modules/oauth/lib/Consumer.php | 8 +- modules/oauth/lib/OAuthServer.php | 1 - modules/oauth/lib/OAuthStore.php | 22 +- modules/oauth/lib/Registry.php | 11 +- modules/oauth/libextinc/OAuth.php | 70 ++--- modules/oauth/templates/registry.edit.tpl.php | 10 +- modules/oauth/templates/registry.list.php | 11 +- modules/oauth/www/assets/css/oauth.css | 37 ++- modules/oauth/www/getUserInfo.php | 4 +- modules/oauth/www/registry.edit.php | 4 +- modules/oauth/www/registry.php | 8 +- .../portal/config-templates/module_portal.php | 2 +- modules/portal/hooks/hook_htmlinject.php | 4 +- modules/portal/lib/Portal.php | 6 +- modules/preprodwarning/templates/warning.php | 29 +-- modules/radius/lib/Auth/Source/Radius.php | 42 +-- modules/riak/hooks/hook_cron.php | 8 +- modules/saml/lib/Auth/Source/SP.php | 43 ++-- modules/saml/lib/BaseNameIDGenerator.php | 1 - modules/saml/lib/Error.php | 12 +- modules/saml/lib/IdP/SAML1.php | 29 ++- modules/saml/lib/IdP/SAML2.php | 9 +- modules/saml/lib/IdP/SQLNameID.php | 19 +- modules/saml/lib/SP/LogoutStore.php | 45 +++- modules/saml/www/sp/metadata.php | 8 +- modules/saml/www/sp/saml1-acs.php | 12 +- modules/saml/www/sp/saml2-acs.php | 1 - modules/saml/www/sp/saml2-logout.php | 16 +- .../config-templates/config-sanitycheck.php | 2 +- modules/sanitycheck/hooks/hook_cron.php | 1 - modules/sanitycheck/templates/check.tpl.php | 54 ++-- modules/sanitycheck/www/index.php | 1 - .../lib/Auth/Process/SmartID.php | 37 +-- .../lib/Auth/Process/SmartName.php | 2 +- modules/sqlauth/lib/Auth/Source/SQL.php | 1 - modules/statistics/bin/loganalyzer.php | 2 - modules/statistics/bin/logcleaner.php | 1 - .../config-templates/module_statistics.php | 42 +-- modules/statistics/hooks/hook_cron.php | 6 +- modules/statistics/hooks/hook_sanitycheck.php | 3 +- modules/statistics/lib/AccessCheck.php | 8 +- modules/statistics/lib/Aggregator.php | 15 +- modules/statistics/lib/DateHandler.php | 2 +- modules/statistics/lib/DateHandlerMonth.php | 2 +- modules/statistics/lib/Graph/GoogleCharts.php | 22 +- modules/statistics/lib/LogCleaner.php | 11 +- modules/statistics/lib/RatioDataset.php | 5 +- modules/statistics/lib/Ruleset.php | 6 +- modules/statistics/lib/StatDataset.php | 1 - .../lib/Statistics/Rulesets/BaseRule.php | 22 +- .../lib/Statistics/Rulesets/Ratio.php | 9 +- .../statistics/templates/statistics.tpl.php | 84 +++--- modules/statistics/templates/statmeta.tpl.php | 22 +- .../statistics/www/assets/js/statistics.js | 4 +- modules/statistics/www/assets/statistics.js | 4 +- modules/statistics/www/showstats.php | 3 +- modules/statistics/www/statmeta.php | 1 - .../consent/lib/Auth/Process/ConsentTest.php | 16 +- 154 files changed, 1723 insertions(+), 1408 deletions(-) diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index 5ed65c328..6e79f3e36 100644 --- a/modules/adfs/lib/IdP/ADFS.php +++ b/modules/adfs/lib/IdP/ADFS.php @@ -36,7 +36,7 @@ class ADFS $state['adfs:wreply'] = \SimpleSAML\Utils\HTTP::checkURLAllowed($query['wreply']); } - $idp->handleAuthenticationRequest($state); + $idp->handleAuthenticationRequest($state); } private static function generateResponse($issuer, $target, $nameid, $attributes, $assertionLifetime) @@ -73,7 +73,10 @@ MSG; continue; } - list($namespace, $name) = \SimpleSAML\Utils\Attributes::getAttributeNamespace($name, 'http://schemas.xmlsoap.org/claims'); + list($namespace, $name) = \SimpleSAML\Utils\Attributes::getAttributeNamespace( + $name, + 'http://schemas.xmlsoap.org/claims' + ); foreach ($values as $value) { if ((!isset($value)) || ($value === '')) { continue; @@ -85,7 +88,6 @@ MSG; <saml:AttributeValue>$value</saml:AttributeValue> </saml:Attribute> MSG; - } } @@ -107,12 +109,13 @@ MSG; private static function signResponse($response, $key, $cert, $algo) { $objXMLSecDSig = new XMLSecurityDSig(); - $objXMLSecDSig->idKeys = array('AssertionID'); - $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); + $objXMLSecDSig->idKeys = array('AssertionID'); + $objXMLSecDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); $responsedom = \SAML2\DOMDocumentFactory::fromString(str_replace("\r", "", $response)); $firstassertionroot = $responsedom->getElementsByTagName('Assertion')->item(0); $objXMLSecDSig->addReferenceList( - array($firstassertionroot), XMLSecurityDSig::SHA256, + array($firstassertionroot), + XMLSecurityDSig::SHA256, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature', XMLSecurityDSig::EXC_C14N), array('id_name' => 'AssertionID') ); @@ -125,7 +128,7 @@ MSG; $objXMLSecDSig->add509Cert($public_cert, true); } $newSig = $responsedom->importNode($objXMLSecDSig->sigNode, true); - $firstassertionroot->appendChild($newSig); + $firstassertionroot->appendChild($newSig); return $responsedom->saveXML(); } @@ -144,7 +147,10 @@ MSG; { $spMetadata = $state["SPMetadata"]; $spEntityId = $spMetadata['entityid']; - $spMetadata = \SimpleSAML\Configuration::loadFromArray($spMetadata, '$metadata['.var_export($spEntityId, true).']'); + $spMetadata = \SimpleSAML\Configuration::loadFromArray( + $spMetadata, + '$metadata['.var_export($spEntityId, true).']' + ); $attributes = $state['Attributes']; @@ -158,7 +164,7 @@ MSG; $nameid = \SimpleSAML\Utils\Random::generateID(); } - $idp = \SimpleSAML\IdP::getByState($state); + $idp = \SimpleSAML\IdP::getByState($state); $idpMetadata = $idp->getConfig(); $idpEntityId = $idpMetadata->getString('entityid'); @@ -193,7 +199,9 @@ MSG; { // NB:: we don't know from which SP the logout request came from $idpMetadata = $idp->getConfig(); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL())); + \SimpleSAML\Utils\HTTP::redirectTrustedURL( + $idpMetadata->getValue('redirect-after-logout', \SimpleSAML\Utils\HTTP::getBaseURL()) + ); } public static function receiveLogoutMessage(\SimpleSAML\IdP $idp) @@ -209,7 +217,7 @@ MSG; 'Responder' => array('\SimpleSAML\Module\adfs\IdP\ADFS', 'sendLogoutResponse'), ); $assocId = null; - // TODO: verify that this is really no problem for: + // TODO: verify that this is really no problem for: // a) SSP, because there's no caller SP. // b) ADFS SP because caller will be called back.. $idp->handleLogoutRequest($state, $assocId); @@ -220,7 +228,9 @@ MSG; { $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $spMetadata = $metadata->getMetaDataConfig($association['adfs:entityID'], 'adfs-sp-remote'); - $returnTo = \SimpleSAML\Module::getModuleURL('adfs/idp/prp.php?assocId='.urlencode($association["id"]).'&relayState='.urlencode($relayState)); + $returnTo = \SimpleSAML\Module::getModuleURL( + 'adfs/idp/prp.php?assocId='.urlencode($association["id"]).'&relayState='.urlencode($relayState) + ); return $spMetadata->getValue('prp').'?wa=wsignoutcleanup1.0&wreply='.urlencode($returnTo); } } diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index 652da7e2f..b7a0f9721 100644 --- a/modules/adfs/www/idp/metadata.php +++ b/modules/adfs/www/idp/metadata.php @@ -150,8 +150,14 @@ try { $certdata = array(); foreach (array_keys($availableCerts) as $availableCert) { $certdata[$availableCert]['name'] = $availableCert; - $certdata[$availableCert]['url'] = \SimpleSAML\Module::getModuleURL('saml/idp/certs.php').'/'.$availableCert; - $certdata[$availableCert]['comment'] = ($availableCerts[$availableCert]['certFingerprint'][0] === 'afe71c28ef740bc87425be13a2263d37971da1f9' ? 'This is the default certificate. Generate a new certificate if this is a production system.' : ''); + $certdata[$availableCert]['url'] = \SimpleSAML\Module::getModuleURL('saml/idp/certs.php'). + '/'.$availableCert; + + $certdata[$availableCert]['comment'] = ''; + if ($availableCerts[$availableCert]['certFingerprint'][0] === 'afe71c28ef740bc87425be13a2263d37971da1f9') { + $certdata[$availableCert]['comment'] = 'This is the default certificate.'. + ' Generate a new certificate if this is a production system.'; + } } $t->data['certdata'] = $certdata; $t->data['header'] = 'adfs-idp'; // TODO: Replace with headerString in 2.0 diff --git a/modules/adfs/www/idp/prp.php b/modules/adfs/www/idp/prp.php index da86ec88f..03a973b11 100644 --- a/modules/adfs/www/idp/prp.php +++ b/modules/adfs/www/idp/prp.php @@ -16,7 +16,7 @@ $idp = \SimpleSAML\IdP::getById('adfs:'.$idpEntityId); if (isset($_GET['wa'])) { if ($_GET['wa'] === 'wsignout1.0') { \SimpleSAML\Module\adfs\IdP\ADFS::receiveLogoutMessage($idp); - } else if ($_GET['wa'] === 'wsignin1.0') { + } elseif ($_GET['wa'] === 'wsignin1.0') { \SimpleSAML\Module\adfs\IdP\ADFS::receiveAuthnRequest($idp); } assert(false); diff --git a/modules/authX509/lib/Auth/Process/ExpiryWarning.php b/modules/authX509/lib/Auth/Process/ExpiryWarning.php index a5286c7bf..6943e6dfd 100644 --- a/modules/authX509/lib/Auth/Process/ExpiryWarning.php +++ b/modules/authX509/lib/Auth/Process/ExpiryWarning.php @@ -95,5 +95,4 @@ class ExpiryWarning extends \SimpleSAML\Auth\ProcessingFilter $url = \SimpleSAML\Module::getModuleURL('authX509/expirywarning.php'); \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); } - } diff --git a/modules/authX509/templates/X509error.php b/modules/authX509/templates/X509error.php index 3eb08fd13..b7f8d4280 100644 --- a/modules/authX509/templates/X509error.php +++ b/modules/authX509/templates/X509error.php @@ -3,27 +3,24 @@ $this->data['header'] = $this->t('{authX509:X509error:certificate_header}'); $this->includeAtTemplateBase('includes/header.php'); -?> - -<?php if ($this->data['errorcode'] !== null) { ?> - <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px" alt="" /> - <h2><?php echo $this->t('{login:error_header}'); ?></h2> - <p><b><?php echo $this->t($this->data['errorcodes']['title'][$this->data['errorcode']]); ?></b></p> - <p><?php echo $this->t($this->data['errorcodes']['descr'][$this->data['errorcode']]); ?></p> - </div> + <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px" alt="" /> + <h2><?php echo $this->t('{login:error_header}'); ?></h2> + <p><b><?php echo $this->t($this->data['errorcodes']['title'][$this->data['errorcode']]); ?></b></p> + <p><?php echo $this->t($this->data['errorcodes']['descr'][$this->data['errorcode']]); ?></p> + </div> <?php } ?> - <h2 style="break: both"><?php echo $this->t('{authX509:X509error:certificate_header}'); ?></h2> + <h2 style="break: both"><?php echo $this->t('{authX509:X509error:certificate_header}'); ?></h2> - <p><?php echo $this->t('{authX509:X509error:certificate_text}'); ?></p> + <p><?php echo $this->t('{authX509:X509error:certificate_text}'); ?></p> - <a href="<?php echo htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURL()); ?>"> - <?php echo $this->t('{login:login_button}'); ?> - </a> + <a href="<?php echo htmlspecialchars(\SimpleSAML\Utils\HTTP::getSelfURL()); ?>"> + <?php echo $this->t('{login:login_button}'); ?> + </a> <?php if (!empty($this->data['links'])) { diff --git a/modules/authX509/templates/X509warning.php b/modules/authX509/templates/X509warning.php index dfe69cbbe..a3daa8064 100644 --- a/modules/authX509/templates/X509warning.php +++ b/modules/authX509/templates/X509warning.php @@ -32,10 +32,10 @@ $this->includeAtTemplateBase('includes/header.php'); <form style="display: inline; margin: 0px; padding: 0px" action="<?php echo htmlspecialchars($this->data['target']); ?>"> <?php - // Embed hidden fields... - foreach ($this->data['data'] as $name => $value) { - echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; - } + // Embed hidden fields... + foreach ($this->data['data'] as $name => $value) { + echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; + } ?> <p><?php echo $warning; ?></p> diff --git a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php index 3a1c3175b..98391a72e 100644 --- a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php +++ b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php @@ -37,7 +37,7 @@ namespace SimpleSAML\Module\authYubiKey\Auth\Process; * * You use it by adding it as an authentication filter in config.php: * - * 'authproc.idp' => array( + * 'authproc.idp' => array( * ... * 90 => 'authYubiKey:OTP2YubiPrefix', * ... @@ -69,7 +69,9 @@ class OTP2YubiPrefix extends \SimpleSAML\Auth\ProcessingFilter $attributes['yubiPrefix'] = array($identity); - \SimpleSAML\Logger::info('OTP2YubiPrefix: otp: '.$otp.' identity: '.$identity.' (otp keys: '.implode(',', array_keys($otps)).')'); + \SimpleSAML\Logger::info( + 'OTP2YubiPrefix: otp: '.$otp.' identity: '.$identity.' (otp keys: '.implode(',', array_keys($otps)).')' + ); unset($attributes['otp']); diff --git a/modules/authYubiKey/lib/Auth/Source/YubiKey.php b/modules/authYubiKey/lib/Auth/Source/YubiKey.php index b43778473..23ace3a39 100644 --- a/modules/authYubiKey/lib/Auth/Source/YubiKey.php +++ b/modules/authYubiKey/lib/Auth/Source/YubiKey.php @@ -27,14 +27,14 @@ namespace SimpleSAML\Module\authYubiKey\Auth\Source; /** * YubiKey authentication module, see http://www.yubico.com/developers/intro/ - * * + * * Configure it by adding an entry to config/authsources.php such as this: * - * 'yubikey' => array( - * 'authYubiKey:YubiKey', - * 'id' => 997, - * 'key' => 'b64hmackey', - * ), + * 'yubikey' => array( + * 'authYubiKey:YubiKey', + * 'id' => 997, + * 'key' => 'b64hmackey', + * ), * * To generate your own client id/key you will need one YubiKey, and then * go to http://yubico.com/developers/api/ @@ -193,11 +193,15 @@ class YubiKey extends \SimpleSAML\Auth\Source $uid = self::getYubiKeyPrefix($otp); $attributes = array('uid' => array($uid)); } catch (\Exception $e) { - \SimpleSAML\Logger::info('YubiKey:'.$this->authId.': Validation error (otp '.$otp.'), debug output: '.$yubi->getLastResponse()); + \SimpleSAML\Logger::info( + 'YubiKey:'.$this->authId.': Validation error (otp '.$otp.'), debug output: '.$yubi->getLastResponse() + ); throw new \SimpleSAML\Error\Error('WRONGUSERPASS', $e); } - \SimpleSAML\Logger::info('YubiKey:'.$this->authId.': YubiKey otp '.$otp.' validated successfully: '.$yubi->getLastResponse()); + \SimpleSAML\Logger::info( + 'YubiKey:'.$this->authId.': YubiKey otp '.$otp.' validated successfully: '.$yubi->getLastResponse() + ); return $attributes; } } diff --git a/modules/authYubiKey/libextinc/Yubico.php b/modules/authYubiKey/libextinc/Yubico.php index 12d2d8b4d..e9af36322 100644 --- a/modules/authYubiKey/libextinc/Yubico.php +++ b/modules/authYubiKey/libextinc/Yubico.php @@ -66,19 +66,19 @@ class Auth_Yubico * Yubico client ID * @var string */ - private $_id; + private $id; /** * Yubico client key * @var string */ - private $_key; + private $key; /** * Response from server * @var string */ - private $_response; + private $response; /** * Constructor @@ -90,19 +90,19 @@ class Auth_Yubico */ public function __construct($id, $key = '') { - $this->_id = $id; - $this->_key = base64_decode($key); + $this->id = $id; + $this->key = base64_decode($key); } /** * Return the last data received from the server, if any. * - * @return string Output from server. + * @return string Output from server. * @access public */ public function getLastResponse() { - return $this->_response; + return $this->response; } // TODO? Add functions to get parsed parts of server response? @@ -116,10 +116,10 @@ class Auth_Yubico */ public function verify($token) { - $parameters = "id=".$this->_id."&otp=".$token; + $parameters = "id=".$this->id."&otp=".$token; // Generate signature - if ($this->_key <> "") { - $signature = base64_encode(hash_hmac('sha1', $parameters, $this->_key, true)); + if ($this->key <> "") { + $signature = base64_encode(hash_hmac('sha1', $parameters, $this->key, true)); $parameters .= '&h='.$signature; } // Support https @@ -134,7 +134,7 @@ class Auth_Yubico $status = $out[1]; // Verify signature - if ($this->_key <> "") { + if ($this->key <> "") { $rows = explode("\r\n", $responseMsg); $response = array(); foreach ($rows as $val) { @@ -145,7 +145,7 @@ class Auth_Yubico } $check = 'status='.$response['status'].'&t='.$response['t']; - $checksignature = base64_encode(hash_hmac('sha1', $check, $this->_key, true)); + $checksignature = base64_encode(hash_hmac('sha1', $check, $this->key, true)); if ($response['h'] != $checksignature) { throw new Exception('Checked Signature failed'); diff --git a/modules/authYubiKey/templates/yubikeylogin.php b/modules/authYubiKey/templates/yubikeylogin.php index 104941b79..693e4c374 100644 --- a/modules/authYubiKey/templates/yubikeylogin.php +++ b/modules/authYubiKey/templates/yubikeylogin.php @@ -2,44 +2,34 @@ $this->includeAtTemplateBase('includes/header.php'); -?> - -<?php if ($this->data['errorCode'] !== null) { ?> - <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> - <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px" alt="" /> - <h2><?php echo $this->t('{login:error_header}'); ?></h2> - <p><b><?php echo $this->t($this->data['errorcodes']['title'][$this->data['errorcode']]); ?></b></p> - <p><?php echo $this->t($this->data['errorcodes']['descr'][$this->data['errorcode']]); ?></p> - </div> + <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> + <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l" style="margin: 15px" alt="" /> + <h2><?php echo $this->t('{login:error_header}'); ?></h2> + <p><b><?php echo $this->t($this->data['errorcodes']['title'][$this->data['errorcode']]); ?></b></p> + <p><?php echo $this->t($this->data['errorcodes']['descr'][$this->data['errorcode']]); ?></p> + </div> <?php } ?> + <img style="float: right" src="<?php echo($this->data['logoUrl']); ?>" alt="" /> + <img style="clear: right; float: right" src="<?php echo($this->data['devicepicUrl']); ?>" alt="YubiKey" /> - <img style="float: right" src="<?php echo($this->data['logoUrl']); ?>" alt="" /> - <img style="clear: right; float: right" src="<?php echo($this->data['devicepicUrl']); ?>" alt="YubiKey" /> - - - <h2 style=""><?php echo $this->data['header']; ?></h2> - - <form action="?" method="post" name="f"> - - <p><?php echo $this->t('{authYubiKey:yubikey:intro}'); ?></p> - - <p><input id="otp" style="border: 1px solid #ccc; background: #eee; padding: .5em; font-size: medium; width: 70%; color: #aaa" type="text" tabindex="2" name="otp" /></p> + <h2 style=""><?php echo $this->data['header']; ?></h2> + <form action="?" method="post" name="f"> + <p><?php echo $this->t('{authYubiKey:yubikey:intro}'); ?></p> + <p><input id="otp" style="border: 1px solid #ccc; background: #eee; padding: .5em; font-size: medium; width: 70%; color: #aaa" type="text" tabindex="2" name="otp" /></p> <?php foreach ($this->data['stateParams'] as $name => $value) { echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; } ?> - - </form> - + </form> <?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index f5c14326b..adb16c205 100644 --- a/modules/authfacebook/extlibinc/base_facebook.php +++ b/modules/authfacebook/extlibinc/base_facebook.php @@ -48,10 +48,10 @@ class FacebookApiException extends Exception if (isset($result['error_description'])) { // OAuth 2.0 Draft 10 style $msg = $result['error_description']; - } else if (isset($result['error']) && is_array($result['error'])) { + } elseif (isset($result['error']) && is_array($result['error'])) { // OAuth 2.0 Draft 00 style $msg = $result['error']['message']; - } else if (isset($result['error_msg'])) { + } elseif (isset($result['error_msg'])) { // Rest server style $msg = $result['error_msg']; } else { @@ -84,7 +84,7 @@ class FacebookApiException extends Exception if (is_string($error)) { // OAuth 2.0 Draft 10 style return $error; - } else if (is_array($error)) { + } elseif (is_array($error)) { // OAuth 2.0 Draft 00 style if (isset($error['type'])) { return $error['type']; @@ -369,7 +369,7 @@ abstract class BaseFacebook // need to circumvent json_decode by calling _oauthRequest // directly, since response isn't JSON format $access_token_response = $this->_oauthRequest( - $this->getUrl('graph', '/oauth/access_token'), + $this->getUrl('graph', '/oauth/access_token'), $params = array( 'client_id' => $this->getAppId(), 'client_secret' => $this->getAppSecret(), @@ -397,7 +397,8 @@ abstract class BaseFacebook $this->destroySession(); $this->setPersistentData( - 'access_token', $response_params['access_token'] + 'access_token', + $response_params['access_token'] ); } @@ -508,10 +509,12 @@ abstract class BaseFacebook if (!$this->signedRequest) { if (!empty($_REQUEST['signed_request'])) { $this->signedRequest = $this->parseSignedRequest( - $_REQUEST['signed_request']); - } else if (!empty($_COOKIE[$this->getSignedRequestCookieName()])) { + $_REQUEST['signed_request'] + ); + } elseif (!empty($_COOKIE[$this->getSignedRequestCookieName()])) { $this->signedRequest = $this->parseSignedRequest( - $_COOKIE[$this->getSignedRequestCookieName()]); + $_COOKIE[$this->getSignedRequestCookieName()] + ); } } return $this->signedRequest; @@ -610,11 +613,15 @@ abstract class BaseFacebook return $this->getUrl( 'www', 'dialog/oauth', - array_merge(array( + array_merge( + array( 'client_id' => $this->getAppId(), 'redirect_uri' => $currentUrl, // possibly overwritten - 'state' => $this->state), - $params)); + 'state' => $this->state + ), + $params + ) + ); } /** @@ -718,8 +725,8 @@ abstract class BaseFacebook if (isset($_REQUEST['code'])) { if ($this->state !== null && isset($_REQUEST['state']) && - $this->state === $_REQUEST['state']) { - + $this->state === $_REQUEST['state'] + ) { // CSRF state has done its job, so clear it $this->state = null; $this->clearPersistentData('state'); @@ -806,10 +813,13 @@ abstract class BaseFacebook $access_token_response = $this->_oauthRequest( $this->getUrl('graph', '/oauth/access_token'), - $params = array('client_id' => $this->getAppId(), - 'client_secret' => $this->getAppSecret(), - 'redirect_uri' => $redirect_uri, - 'code' => $code)); + $params = array( + 'client_id' => $this->getAppId(), + 'client_secret' => $this->getAppSecret(), + 'redirect_uri' => $redirect_uri, + 'code' => $code + ) + ); } catch (FacebookApiException $e) { // most likely that user very recently revoked authorization. // In any event, we don't have an access token, so say so. @@ -1042,8 +1052,7 @@ abstract class BaseFacebook } // check sig - $expected_sig = hash_hmac('sha256', $payload, - $this->getAppSecret(), $raw = true); + $expected_sig = hash_hmac('sha256', $payload, $this->getAppSecret(), $raw = true); if ($sig !== $expected_sig) { self::errorLog('Bad Signed JSON signature!'); return null; @@ -1062,7 +1071,8 @@ abstract class BaseFacebook { if (!is_array($data)) { throw new InvalidArgumentException( - 'makeSignedRequest expects an array. Got: '.print_r($data, true)); + 'makeSignedRequest expects an array. Got: '.print_r($data, true) + ); } $data['algorithm'] = self::SIGNED_REQUEST_ALGORITHM; $data['issued_at'] = time(); @@ -1147,7 +1157,7 @@ abstract class BaseFacebook $name = 'api'; if (isset($READ_ONLY_CALLS[strtolower($method)])) { $name = 'api_read'; - } else if (strtolower($method) == 'video.upload') { + } elseif (strtolower($method) == 'video.upload') { $name = 'api_video'; } return $this->getUrl($name, 'restserver.php'); diff --git a/modules/authfacebook/lib/Auth/Source/Facebook.php b/modules/authfacebook/lib/Auth/Source/Facebook.php index 40d543856..86d592458 100644 --- a/modules/authfacebook/lib/Auth/Source/Facebook.php +++ b/modules/authfacebook/lib/Auth/Source/Facebook.php @@ -72,8 +72,11 @@ class Facebook extends \SimpleSAML\Auth\Source // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $cfgParse = \SimpleSAML\Configuration::loadFromArray($config, 'authsources['.var_export($this->authId, true).']'); - + $cfgParse = \SimpleSAML\Configuration::loadFromArray( + $config, + 'authsources['.var_export($this->authId, true).']' + ); + $this->api_key = $cfgParse->getString('api_key'); $this->secret = $cfgParse->getString('secret'); $this->req_perms = $cfgParse->getString('req_perms', null); @@ -93,8 +96,11 @@ class Facebook extends \SimpleSAML\Auth\Source // We are going to need the authId in order to retrieve this authentication source later $state[self::AUTHID] = $this->authId; \SimpleSAML\Auth\State::saveState($state, self::STAGE_INIT); - - $facebook = new Module\authfacebook\Facebook(array('appId' => $this->api_key, 'secret' => $this->secret), $state); + + $facebook = new Module\authfacebook\Facebook( + array('appId' => $this->api_key, 'secret' => $this->secret), + $state + ); $facebook->destroySession(); $linkback = Module::getModuleURL('authfacebook/linkback.php'); @@ -103,13 +109,16 @@ class Facebook extends \SimpleSAML\Auth\Source \SimpleSAML\Utils\HTTP::redirectTrustedURL($url); } - + public function finalStep(&$state) { assert(is_array($state)); - $facebook = new Module\authfacebook\Facebook(array('appId' => $this->api_key, 'secret' => $this->secret), $state); + $facebook = new Module\authfacebook\Facebook( + array('appId' => $this->api_key, 'secret' => $this->secret), + $state + ); $uid = $facebook->getUser(); if (isset($uid) && $uid) { @@ -123,7 +132,7 @@ class Facebook extends \SimpleSAML\Auth\Source if (!isset($info)) { throw new \SimpleSAML\Error\AuthSource($this->authId, 'Error getting user profile.'); } - + $attributes = array(); foreach ($info as $key => $value) { if (is_string($value) && !empty($value)) { @@ -143,7 +152,7 @@ class Facebook extends \SimpleSAML\Auth\Source \SimpleSAML\Logger::debug('Facebook Returned Attributes: '.implode(", ", array_keys($attributes))); $state['Attributes'] = $attributes; - + $facebook->destroySession(); } } diff --git a/modules/authfacebook/www/linkback.php b/modules/authfacebook/www/linkback.php index 904b33ba2..6a2459019 100644 --- a/modules/authfacebook/www/linkback.php +++ b/modules/authfacebook/www/linkback.php @@ -6,22 +6,32 @@ // For backwards compatability look for AuthState first if (array_key_exists('AuthState', $_REQUEST) && !empty($_REQUEST['AuthState'])) { - $state = \SimpleSAML\Auth\State::loadState($_REQUEST['AuthState'], \SimpleSAML\Module\authfacebook\Auth\Source\Facebook::STAGE_INIT); + $state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['AuthState'], + \SimpleSAML\Module\authfacebook\Auth\Source\Facebook::STAGE_INIT + ); } elseif (array_key_exists('state', $_REQUEST) && !empty($_REQUEST['state'])) { - $state = \SimpleSAML\Auth\State::loadState($_REQUEST['state'], \SimpleSAML\Module\authfacebook\Auth\Source\Facebook::STAGE_INIT); + $state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['state'], + \SimpleSAML\Module\authfacebook\Auth\Source\Facebook::STAGE_INIT + ); } else { throw new \SimpleSAML\Error\BadRequest('Missing state parameter on facebook linkback endpoint.'); } // Find authentication source if (!array_key_exists(\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTHID, $state)) { - throw new \SimpleSAML\Error\BadRequest('No data in state for '.\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTHID); + throw new \SimpleSAML\Error\BadRequest( + 'No data in state for '.\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTHID + ); } $sourceId = $state[\SimpleSAML\Module\authfacebook\Auth\Source\Facebook::AUTHID]; $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { - throw new \SimpleSAML\Error\BadRequest('Could not find authentication source with id '.var_export($sourceId, true)); + throw new \SimpleSAML\Error\BadRequest( + 'Could not find authentication source with id '.var_export($sourceId, true) + ); } try { @@ -33,7 +43,10 @@ try { } catch (\SimpleSAML\Error\Exception $e) { \SimpleSAML\Auth\State::throwException($state, $e); } catch (\Exception $e) { - \SimpleSAML\Auth\State::throwException($state, new \SimpleSAML\Error\AuthSource($sourceId, 'Error on facebook linkback endpoint.', $e)); + \SimpleSAML\Auth\State::throwException( + $state, + new \SimpleSAML\Error\AuthSource($sourceId, 'Error on facebook linkback endpoint.', $e) + ); } \SimpleSAML\Auth\Source::completeAuth($state); diff --git a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php index 91b0003de..672ef7f15 100644 --- a/modules/authlinkedin/lib/Auth/Source/LinkedIn.php +++ b/modules/authlinkedin/lib/Auth/Source/LinkedIn.php @@ -84,7 +84,9 @@ class LinkedIn extends \SimpleSAML\Auth\Source // Get the request token $requestToken = $consumer->getRequestToken( 'https://api.linkedin.com/uas/oauth/requestToken', - array('oauth_callback' => \SimpleSAML\Module::getModuleUrl('authlinkedin').'/linkback.php?stateid='.$stateID) + array( + 'oauth_callback' => \SimpleSAML\Module::getModuleUrl('authlinkedin').'/linkback.php?stateid='.$stateID + ) ); \SimpleSAML\Logger::debug( @@ -115,7 +117,8 @@ class LinkedIn extends \SimpleSAML\Auth\Source // Replace the request token with an access token (via GET method) $accessToken = $consumer->getAccessToken( - 'https://api.linkedin.com/uas/oauth/accessToken', $requestToken, + 'https://api.linkedin.com/uas/oauth/accessToken', + $requestToken, array('oauth_verifier' => $state['authlinkedin:oauth_verifier']) ); @@ -126,7 +129,7 @@ class LinkedIn extends \SimpleSAML\Auth\Source $userdata = $consumer->getUserInfo( 'https://api.linkedin.com/v1/people/~:('.$this->attributes.')', - $accessToken, + $accessToken, array('http' => array('header' => 'x-li-format: json')) ); diff --git a/modules/authlinkedin/www/linkback.php b/modules/authlinkedin/www/linkback.php index bc2abdca4..157525ab2 100644 --- a/modules/authlinkedin/www/linkback.php +++ b/modules/authlinkedin/www/linkback.php @@ -7,7 +7,10 @@ if (!array_key_exists('stateid', $_REQUEST)) { throw new \Exception('Lost OAuth Client State'); } -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['stateid'], \SimpleSAML\Module\authlinkedin\Auth\Source\LinkedIn::STAGE_INIT); +$state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['stateid'], + \SimpleSAML\Module\authlinkedin\Auth\Source\LinkedIn::STAGE_INIT +); // http://developer.linkedin.com/docs/DOC-1008#2_Redirect_the_User_to_our_Authorization_Server if (array_key_exists('oauth_verifier', $_REQUEST)) { @@ -28,4 +31,3 @@ if ($source === null) { $source->finalStep($state); \SimpleSAML\Auth\Source::completeAuth($state); - diff --git a/modules/authorize/lib/Auth/Process/Authorize.php b/modules/authorize/lib/Auth/Process/Authorize.php index 63b577012..e546f3417 100644 --- a/modules/authorize/lib/Auth/Process/Authorize.php +++ b/modules/authorize/lib/Auth/Process/Authorize.php @@ -65,11 +65,16 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter $values = array($values); } if (!is_array($values)) { - throw new \Exception('Filter Authorize: Attribute values is neither string nor array: '.var_export($attribute, true)); + throw new \Exception( + 'Filter Authorize: Attribute values is neither string nor array: '.var_export($attribute, true) + ); } foreach ($values as $value) { if (!is_string($value)) { - throw new \Exception('Filter Authorize: Each value should be a string for attribute: '.var_export($attribute, true).' value: '.var_export($value, true).' Config is: '.var_export($config, true)); + throw new \Exception( + 'Filter Authorize: Each value should be a string for attribute: '.var_export($attribute, true). + ' value: '.var_export($value, true).' Config is: '.var_export($config, true) + ); } } $this->valid_attribute_values[$attribute] = $values; @@ -130,10 +135,8 @@ class Authorize extends \SimpleSAML\Auth\ProcessingFilter protected function unauthorized(&$request) { // Save state and redirect to 403 page - $id = \SimpleSAML\Auth\State::saveState($request, - 'authorize:Authorize'); - $url = \SimpleSAML\Module::getModuleURL( - 'authorize/authorize_403.php'); + $id = \SimpleSAML\Auth\State::saveState($request, 'authorize:Authorize'); + $url = \SimpleSAML\Module::getModuleURL('authorize/authorize_403.php'); \SimpleSAML\Utils\HTTP::redirectTrustedURL($url, array('StateId' => $id)); } } diff --git a/modules/authorize/templates/authorize_403.php b/modules/authorize/templates/authorize_403.php index a3162d0a1..43ab32033 100644 --- a/modules/authorize/templates/authorize_403.php +++ b/modules/authorize/templates/authorize_403.php @@ -14,15 +14,11 @@ $this->data['403_header'] = $this->t('{authorize:Authorize:403_header}'); $this->data['403_text'] = $this->t('{authorize:Authorize:403_text}'); $this->includeAtTemplateBase('includes/header.php'); -?> -<h1><?php echo $this->data['403_header']; ?></h1> -<p><?php echo $this->data['403_text']; ?></p> -<?php + +echo '<h1>'.$this->data['403_header'].'</h1>'; +echo '<p>'.$this->data['403_text'].'</p>'; if (isset($this->data['logoutURL'])) { -?> -<p><a href="<?php echo htmlspecialchars($this->data['logoutURL']); ?>"><?php echo $this->t('{status:logout}'); ?></a></p> -<?php + echo '<p><a href="'.htmlspecialchars($this->data['logoutURL']).'">'.$this->t('{status:logout}').'</a></p>'; } -?> -<?php + $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/authorize/www/authorize_403.php b/modules/authorize/www/authorize_403.php index 42f504f9f..4fe73632e 100644 --- a/modules/authorize/www/authorize_403.php +++ b/modules/authorize/www/authorize_403.php @@ -13,7 +13,10 @@ $state = \SimpleSAML\Auth\State::loadState($_REQUEST['StateId'], 'authorize:Auth $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'authorize:authorize_403.php'); if (isset($state['Source']['auth'])) { - $t->data['logoutURL'] = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $state['Source']['auth']))."&logout"; + $t->data['logoutURL'] = \SimpleSAML\Module::getModuleURL( + 'core/authenticate.php', + array('as' => $state['Source']['auth']) + )."&logout"; } header('HTTP/1.0 403 Forbidden'); $t->show(); diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php index 3079d20eb..6b004b6fb 100644 --- a/modules/authtwitter/lib/Auth/Source/Twitter.php +++ b/modules/authtwitter/lib/Auth/Source/Twitter.php @@ -57,7 +57,10 @@ class Twitter extends \SimpleSAML\Auth\Source // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $configObject = \SimpleSAML\Configuration::loadFromArray($config, 'authsources['.var_export($this->authId, true).']'); + $configObject = \SimpleSAML\Configuration::loadFromArray( + $config, + 'authsources['.var_export($this->authId, true).']' + ); $this->key = $configObject->getString('key'); $this->secret = $configObject->getString('secret'); @@ -82,7 +85,10 @@ class Twitter extends \SimpleSAML\Auth\Source $consumer = new \SimpleSAML\Module\oauth\Consumer($this->key, $this->secret); // Get the request token $linkback = \SimpleSAML\Module::getModuleURL('authtwitter/linkback.php', array('AuthState' => $stateID)); - $requestToken = $consumer->getRequestToken('https://api.twitter.com/oauth/request_token', array('oauth_callback' => $linkback)); + $requestToken = $consumer->getRequestToken( + 'https://api.twitter.com/oauth/request_token', + array('oauth_callback' => $linkback) + ); \SimpleSAML\Logger::debug("Got a request token from the OAuth service provider [". $requestToken->key."] with the secret [".$requestToken->secret."]"); @@ -120,7 +126,11 @@ class Twitter extends \SimpleSAML\Auth\Source $requestToken->key."] with the secret [".$requestToken->secret."]"); // Replace the request token with an access token - $accessToken = $consumer->getAccessToken('https://api.twitter.com/oauth/access_token', $requestToken, $parameters); + $accessToken = $consumer->getAccessToken( + 'https://api.twitter.com/oauth/access_token', + $requestToken, + $parameters + ); \SimpleSAML\Logger::debug("Got an access token from the OAuth service provider [". $accessToken->key."] with the secret [".$accessToken->secret."]"); @@ -131,20 +141,23 @@ class Twitter extends \SimpleSAML\Auth\Source $userdata = $consumer->getUserInfo($verify_credentials_url, $accessToken); if (!isset($userdata['id_str']) || !isset($userdata['screen_name'])) { - throw new \SimpleSAML\Error\AuthSource($this->authId, 'Authentication error: id_str and screen_name not set.'); + throw new \SimpleSAML\Error\AuthSource( + $this->authId, + 'Authentication error: id_str and screen_name not set.' + ); } $attributes = array(); foreach ($userdata as $key => $value) { if (is_string($value)) { $attributes['twitter.'.$key] = array((string) $value); + } } - } - $attributes['twitter_at_screen_name'] = array('@'.$userdata['screen_name']); - $attributes['twitter_screen_n_realm'] = array($userdata['screen_name'].'@twitter.com'); - $attributes['twitter_targetedID'] = array('http://twitter.com!'.$userdata['id_str']); + $attributes['twitter_at_screen_name'] = array('@'.$userdata['screen_name']); + $attributes['twitter_screen_n_realm'] = array($userdata['screen_name'].'@twitter.com'); + $attributes['twitter_targetedID'] = array('http://twitter.com!'.$userdata['id_str']); - $state['Attributes'] = $attributes; + $state['Attributes'] = $attributes; } } diff --git a/modules/authtwitter/www/linkback.php b/modules/authtwitter/www/linkback.php index ebba693a4..cbeed68a7 100644 --- a/modules/authtwitter/www/linkback.php +++ b/modules/authtwitter/www/linkback.php @@ -7,17 +7,24 @@ if (!array_key_exists('AuthState', $_REQUEST) || empty($_REQUEST['AuthState'])) { throw new \SimpleSAML\Error\BadRequest('Missing state parameter on twitter linkback endpoint.'); } -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['AuthState'], \SimpleSAML\Module\authtwitter\Auth\Source\Twitter::STAGE_INIT); +$state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['AuthState'], + \SimpleSAML\Module\authtwitter\Auth\Source\Twitter::STAGE_INIT +); // Find authentication source if (!array_key_exists(\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID, $state)) { - throw new \SimpleSAML\Error\BadRequest('No data in state for '.\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID); + throw new \SimpleSAML\Error\BadRequest( + 'No data in state for '.\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID + ); } $sourceId = $state[\SimpleSAML\Module\authtwitter\Auth\Source\Twitter::AUTHID]; $source = \SimpleSAML\Auth\Source::getById($sourceId); if ($source === null) { - throw new \SimpleSAML\Error\BadRequest('Could not find authentication source with id '.var_export($sourceId, true)); + throw new \SimpleSAML\Error\BadRequest( + 'Could not find authentication source with id '.var_export($sourceId, true) + ); } try { @@ -28,7 +35,10 @@ try { } catch (\SimpleSAML\Error\Exception $e) { \SimpleSAML\Auth\State::throwException($state, $e); } catch (\Exception $e) { - \SimpleSAML\Auth\State::throwException($state, new \SimpleSAML\Error\AuthSource($sourceId, 'Error on authtwitter linkback endpoint.', $e)); + \SimpleSAML\Auth\State::throwException( + $state, + new \SimpleSAML\Error\AuthSource($sourceId, 'Error on authtwitter linkback endpoint.', $e) + ); } \SimpleSAML\Auth\Source::completeAuth($state); diff --git a/modules/authwindowslive/www/linkback.php b/modules/authwindowslive/www/linkback.php index 31637deb7..758bdd215 100644 --- a/modules/authwindowslive/www/linkback.php +++ b/modules/authwindowslive/www/linkback.php @@ -7,7 +7,10 @@ if (!array_key_exists('state', $_REQUEST)) { throw new \Exception('Lost OAuth Client State'); } -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['state'], \SimpleSAML\Module\authwindowslive\Auth\Source\LiveID::STAGE_INIT); +$state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['state'], + \SimpleSAML\Module\authwindowslive\Auth\Source\LiveID::STAGE_INIT +); // http://msdn.microsoft.com/en-us/library/ff749771.aspx if (array_key_exists('code', $_REQUEST)) { diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php index 9ae671a76..3ab8cfd7a 100644 --- a/modules/cas/lib/Auth/Source/CAS.php +++ b/modules/cas/lib/Auth/Source/CAS.php @@ -26,22 +26,23 @@ class CAS extends \SimpleSAML\Auth\Source /** * @var array with ldap configuration */ - private $_ldapConfig; + private $ldapConfig; /** * @var cas configuration */ - private $_casConfig; + private $casConfig; /** * @var string cas chosen validation method */ - private $_validationMethod; + private $validationMethod; + /** * @var string cas login method */ - private $_loginMethod; + private $loginMethod; /** * Constructor for this authentication source. @@ -65,19 +66,19 @@ class CAS extends \SimpleSAML\Auth\Source throw new \Exception('ldap authentication source is not properly configured: missing [ldap]'); } - $this->_casConfig = $config['cas']; - $this->_ldapConfig = $config['ldap']; + $this->casConfig = $config['cas']; + $this->ldapConfig = $config['ldap']; - if (isset($this->_casConfig['serviceValidate'])) { - $this->_validationMethod = 'serviceValidate'; - } elseif (isset($this->_casConfig['validate'])) { - $this->_validationMethod = 'validate'; + if (isset($this->casConfig['serviceValidate'])) { + $this->validationMethod = 'serviceValidate'; + } elseif (isset($this->casConfig['validate'])) { + $this->validationMethod = 'validate'; } else { throw new \Exception("validate or serviceValidate not specified"); } - if (isset($this->_casConfig['login'])) { - $this->_loginMethod = $this->_casConfig['login']; + if (isset($this->casConfig['login'])) { + $this->loginMethod = $this->casConfig['login']; } else { throw new \Exception("cas login URL not specified"); } @@ -94,7 +95,7 @@ class CAS extends \SimpleSAML\Auth\Source */ private function casValidate($ticket, $service) { - $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->_casConfig['validate'], array( + $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->casConfig['validate'], array( 'ticket' => $ticket, 'service' => $service, )); @@ -120,7 +121,7 @@ class CAS extends \SimpleSAML\Auth\Source private function casServiceValidate($ticket, $service) { $url = \SimpleSAML\Utils\HTTP::addURLParameters( - $this->_casConfig['serviceValidate'], + $this->casConfig['serviceValidate'], array( 'ticket' => $ticket, 'service' => $service, @@ -137,7 +138,7 @@ class CAS extends \SimpleSAML\Auth\Source throw new \Exception("Error when validating CAS service ticket: ".$failure->item(0)->textContent); } else { $attributes = array(); - if ($casattributes = $this->_casConfig['attributes']) { + if ($casattributes = $this->casConfig['attributes']) { // Some has attributes in the xml - attributes is a list of XPath expressions to get them foreach ($casattributes as $name => $query) { $attrs = $xPath->query($query); @@ -163,7 +164,7 @@ class CAS extends \SimpleSAML\Auth\Source */ protected function casValidation($ticket, $service) { - switch ($this->_validationMethod) { + switch ($this->validationMethod) { case 'validate': return $this->casValidate($ticket, $service); case 'serviceValidate': @@ -187,9 +188,11 @@ class CAS extends \SimpleSAML\Auth\Source list($username, $casattributes) = $this->casValidation($ticket, $service); $ldapattributes = array(); - $config = \SimpleSAML\Configuration::loadFromArray($this->_ldapConfig, - 'Authentication source '.var_export($this->authId, true)); - if ($this->_ldapConfig['servers']) { + $config = \SimpleSAML\Configuration::loadFromArray( + $this->ldapConfig, + 'Authentication source '.var_export($this->authId, true) + ); + if ($this->ldapConfig['servers']) { $ldap = new \SimpleSAML\Auth\LDAP( $config->getString('servers'), $config->getBoolean('enable_tls', false), @@ -198,7 +201,7 @@ class CAS extends \SimpleSAML\Auth\Source $config->getInteger('port', 389), $config->getBoolean('referrals', true) ); - $ldapattributes = $ldap->validate($this->_ldapConfig, $username); + $ldapattributes = $ldap->validate($this->ldapConfig, $username); } $attributes = array_merge_recursive($casattributes, $ldapattributes); $state['Attributes'] = $attributes; @@ -223,7 +226,7 @@ class CAS extends \SimpleSAML\Auth\Source $serviceUrl = \SimpleSAML\Module::getModuleURL('cas/linkback.php', array('stateID' => $stateID)); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->_loginMethod, array('service' => $serviceUrl)); + \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->loginMethod, array('service' => $serviceUrl)); } @@ -243,7 +246,7 @@ class CAS extends \SimpleSAML\Auth\Source public function logout(&$state) { assert(is_array($state)); - $logoutUrl = $this->_casConfig['logout']; + $logoutUrl = $this->casConfig['logout']; \SimpleSAML\Auth\State::deleteState($state); // we want cas to log us out diff --git a/modules/cas/www/linkback.php b/modules/cas/www/linkback.php index e547a9afe..366583c8a 100644 --- a/modules/cas/www/linkback.php +++ b/modules/cas/www/linkback.php @@ -24,5 +24,3 @@ if ($source === null) { } $source->finalStep($state); - - diff --git a/modules/cdc/lib/Server.php b/modules/cdc/lib/Server.php index 4292ce53f..7414004b0 100644 --- a/modules/cdc/lib/Server.php +++ b/modules/cdc/lib/Server.php @@ -66,7 +66,9 @@ class Server $this->cookieLifetime = $config->getInteger('cookie.lifetime', 0); if ($this->key === 'ExampleSharedKey') { - throw new \SimpleSAML\Error\Exception('Key for CDC domain '.var_export($domain, true).' not changed from default.'); + throw new \SimpleSAML\Error\Exception( + 'Key for CDC domain '.var_export($domain, true).' not changed from default.' + ); } } diff --git a/modules/consent/lib/Auth/Process/Consent.php b/modules/consent/lib/Auth/Process/Consent.php index 7dbacd4a6..f19c2b20e 100644 --- a/modules/consent/lib/Auth/Process/Consent.php +++ b/modules/consent/lib/Auth/Process/Consent.php @@ -23,49 +23,49 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter * * @var string|null */ - private $_focus = null; + private $focus = null; /** * Include attribute values * * @var bool */ - private $_includeValues = false; + private $includeValues = false; /** * Check remember consent * * @var bool */ - private $_checked = false; + private $checked = false; /** * Consent backend storage configuration * * @var \SimpleSAML\Module\consent\Store|null */ - private $_store = null; + private $store = null; /** * Attributes where the value should be hidden * * @var array */ - private $_hiddenAttributes = array(); + private $hiddenAttributes = array(); /** * Attributes which should not require consent * * @var array */ - private $_noconsentattributes = array(); + private $noconsentattributes = array(); /** * Whether we should show the "about service"-link on the no consent page. * * @var bool */ - private $_showNoConsentAboutService = true; + private $showNoConsentAboutService = true; /** @@ -90,7 +90,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['includeValues'], true).' given.' ); } - $this->_includeValues = $config['includeValues']; + $this->includeValues = $config['includeValues']; } if (array_key_exists('checked', $config)) { @@ -100,7 +100,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['checked'], true).' given.' ); } - $this->_checked = $config['checked']; + $this->checked = $config['checked']; } if (array_key_exists('focus', $config)) { @@ -110,7 +110,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['focus'], true).' given.' ); } - $this->_focus = $config['focus']; + $this->focus = $config['focus']; } if (array_key_exists('hiddenAttributes', $config)) { @@ -120,7 +120,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['hiddenAttributes'], true).' given.' ); } - $this->_hiddenAttributes = $config['hiddenAttributes']; + $this->hiddenAttributes = $config['hiddenAttributes']; } if (array_key_exists('attributes.exclude', $config)) { @@ -130,7 +130,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['attributes.exclude'], true).' given.' ); } - $this->_noconsentattributes = $config['attributes.exclude']; + $this->noconsentattributes = $config['attributes.exclude']; } elseif (array_key_exists('noconsentattributes', $config)) { Logger::warning("The 'noconsentattributes' option has been deprecated in favour of 'attributes.exclude'."); if (!is_array($config['noconsentattributes'])) { @@ -139,12 +139,12 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter var_export($config['noconsentattributes'], true).' given.' ); } - $this->_noconsentattributes = $config['noconsentattributes']; + $this->noconsentattributes = $config['noconsentattributes']; } if (array_key_exists('store', $config)) { try { - $this->_store = \SimpleSAML\Module\consent\Store::parseStoreConfig($config['store']); + $this->store = \SimpleSAML\Module\consent\Store::parseStoreConfig($config['store']); } catch (\Exception $e) { Logger::error( 'Consent: Could not create consent storage: '. @@ -157,7 +157,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter if (!is_bool($config['showNoConsentAboutService'])) { throw new \SimpleSAML\Error\Exception('Consent: showNoConsentAboutService must be a boolean.'); } - $this->_showNoConsentAboutService = $config['showNoConsentAboutService']; + $this->showNoConsentAboutService = $config['showNoConsentAboutService']; } } @@ -276,14 +276,14 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter return; } - if ($this->_store !== null) { + if ($this->store !== null) { $source = $state['Source']['metadata-set'].'|'.$idpEntityId; $destination = $state['Destination']['metadata-set'].'|'.$spEntityId; $attributes = $state['Attributes']; // Remove attributes that do not require consent foreach ($attributes as $attrkey => $attrval) { - if (in_array($attrkey, $this->_noconsentattributes, true)) { + if (in_array($attrkey, $this->noconsentattributes, true)) { unset($attributes[$attrkey]); } } @@ -294,7 +294,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter $userId = self::getHashedUserID($state['UserID'], $source); $targetedId = self::getTargetedID($state['UserID'], $source, $destination); - $attributeSet = self::getAttributeHash($attributes, $this->_includeValues); + $attributeSet = self::getAttributeHash($attributes, $this->includeValues); Logger::debug( 'Consent: hasConsent() ['.$userId.'|'.$targetedId.'|'. @@ -302,7 +302,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter ); try { - if ($this->_store->hasConsent($userId, $targetedId, $attributeSet)) { + if ($this->store->hasConsent($userId, $targetedId, $attributeSet)) { // Consent already given Logger::stats('consent found'); Stats::log('consent:found', $statsData); @@ -312,7 +312,7 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter Logger::stats('consent notfound'); Stats::log('consent:notfound', $statsData); - $state['consent:store'] = $this->_store; + $state['consent:store'] = $this->store; $state['consent:store.userId'] = $userId; $state['consent:store.destination'] = $targetedId; $state['consent:store.attributeSet'] = $attributeSet; @@ -326,18 +326,18 @@ class Consent extends \SimpleSAML\Auth\ProcessingFilter Stats::log('consent:nostorage', $statsData); } - $state['consent:focus'] = $this->_focus; - $state['consent:checked'] = $this->_checked; - $state['consent:hiddenAttributes'] = $this->_hiddenAttributes; - $state['consent:noconsentattributes'] = $this->_noconsentattributes; - $state['consent:showNoConsentAboutService'] = $this->_showNoConsentAboutService; + $state['consent:focus'] = $this->focus; + $state['consent:checked'] = $this->checked; + $state['consent:hiddenAttributes'] = $this->hiddenAttributes; + $state['consent:noconsentattributes'] = $this->noconsentattributes; + $state['consent:showNoConsentAboutService'] = $this->showNoConsentAboutService; // user interaction necessary. Throw exception on isPassive request if (isset($state['isPassive']) && $state['isPassive'] === true) { Stats::log('consent:nopassive', $statsData); throw new Module\saml\Error\NoPassive( - \SAML2\Constants::STATUS_REQUESTER, - 'Unable to give consent on passive request.' + \SAML2\Constants::STATUS_REQUESTER, + 'Unable to give consent on passive request.' ); } diff --git a/modules/consent/lib/Consent/Store/Cookie.php b/modules/consent/lib/Consent/Store/Cookie.php index 52ea5f952..19ab9b401 100644 --- a/modules/consent/lib/Consent/Store/Cookie.php +++ b/modules/consent/lib/Consent/Store/Cookie.php @@ -42,7 +42,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store assert(is_string($destinationId)); assert(is_string($attributeSet)); - $cookieName = self::_getCookieName($userId, $destinationId); + $cookieName = self::getCookieName($userId, $destinationId); $data = $userId.':'.$attributeSet.':'.$destinationId; @@ -62,7 +62,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store return false; } - $data = self::_sign($data); + $data = self::sign($data); if ($_COOKIE[$cookieName] !== $data) { \SimpleSAML\Logger::info( @@ -97,13 +97,13 @@ class Cookie extends \SimpleSAML\Module\consent\Store assert(is_string($destinationId)); assert(is_string($attributeSet)); - $name = self::_getCookieName($userId, $destinationId); + $name = self::getCookieName($userId, $destinationId); $value = $userId.':'.$attributeSet.':'.$destinationId; \SimpleSAML\Logger::debug('Consent cookie - Set ['.$value.']'); - $value = self::_sign($value); - $this->_setConsentCookie($name, $value); + $value = self::sign($value); + $this->setConsentCookie($name, $value); } @@ -122,8 +122,8 @@ class Cookie extends \SimpleSAML\Module\consent\Store assert(is_string($userId)); assert(is_string($destinationId)); - $name = self::_getCookieName($userId, $destinationId); - $this->_setConsentCookie($name, null); + $name = self::getCookieName($userId, $destinationId); + $this->setConsentCookie($name, null); } @@ -169,7 +169,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store continue; } - $value = self::_verify($value); + $value = self::verify($value); if ($value === false) { continue; } @@ -204,7 +204,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store * * @return string The signed data. */ - private static function _sign($data) + private static function sign($data) { assert(is_string($data)); @@ -223,7 +223,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store * * @return string|false The data, or false if the signature is invalid. */ - private static function _verify($signedData) + private static function verify($signedData) { assert(is_string($signedData)); @@ -234,7 +234,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store } $data = $data[1]; - $newSignedData = self::_sign($data); + $newSignedData = self::sign($data); if ($newSignedData !== $signedData) { \SimpleSAML\Logger::warning('Consent cookie: Invalid signature.'); return false; @@ -254,7 +254,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store * * @return string The cookie name */ - private static function _getCookieName($userId, $destinationId) + private static function getCookieName($userId, $destinationId) { assert(is_string($userId)); assert(is_string($destinationId)); @@ -271,7 +271,7 @@ class Cookie extends \SimpleSAML\Module\consent\Store * * @return void */ - private function _setConsentCookie($name, $value) + private function setConsentCookie($name, $value) { assert(is_string($name)); assert(is_string($value) || $value === null); diff --git a/modules/consent/lib/Consent/Store/Database.php b/modules/consent/lib/Consent/Store/Database.php index 35f438f16..5f5f3b126 100644 --- a/modules/consent/lib/Consent/Store/Database.php +++ b/modules/consent/lib/Consent/Store/Database.php @@ -24,46 +24,46 @@ class Database extends \SimpleSAML\Module\consent\Store /** * DSN for the database. */ - private $_dsn; + private $dsn; /** * The DATETIME SQL function to use */ - private $_dateTime; + private $dateTime; /** * Username for the database. */ - private $_username; + private $username; /** * Password for the database; */ - private $_password; + private $password; /** * Options for the database; */ - private $_options; + private $options; /** * Table with consent. */ - private $_table; + private $table; /** * The timeout of the database connection. * * @var int|null */ - private $_timeout = null; + private $timeout = null; /** * Database handle. * * This variable can't be serialized. */ - private $_db; + private $db; /** @@ -86,49 +86,49 @@ class Database extends \SimpleSAML\Module\consent\Store throw new \Exception('consent:Database - \'dsn\' is supposed to be a string.'); } - $this->_dsn = $config['dsn']; - $this->_dateTime = (0 === strpos($this->_dsn, 'sqlite:')) ? 'DATETIME("NOW")' : 'NOW()'; + $this->dsn = $config['dsn']; + $this->dateTime = (0 === strpos($this->dsn, 'sqlite:')) ? 'DATETIME("NOW")' : 'NOW()'; if (array_key_exists('username', $config)) { if (!is_string($config['username'])) { throw new \Exception('consent:Database - \'username\' is supposed to be a string.'); } - $this->_username = $config['username']; + $this->username = $config['username']; } else { - $this->_username = null; + $this->username = null; } if (array_key_exists('password', $config)) { if (!is_string($config['password'])) { throw new \Exception('consent:Database - \'password\' is supposed to be a string.'); } - $this->_password = $config['password']; + $this->password = $config['password']; } else { - $this->_password = null; + $this->password = null; } if (array_key_exists('options', $config)) { if (!is_array($config['options'])) { throw new \Exception('consent:Database - \'options\' is supposed to be an array.'); } - $this->_options = $config['options']; + $this->options = $config['options']; } else { - $this->_options = null; + $this->options = null; } if (array_key_exists('table', $config)) { if (!is_string($config['table'])) { throw new \Exception('consent:Database - \'table\' is supposed to be a string.'); } - $this->_table = $config['table']; + $this->table = $config['table']; } else { - $this->_table = 'consent'; + $this->table = 'consent'; } if (isset($config['timeout'])) { if (!is_int($config['timeout'])) { throw new \Exception('consent:Database - \'timeout\' is supposed to be an integer.'); } - $this->_timeout = $config['timeout']; + $this->timeout = $config['timeout']; } } @@ -141,12 +141,12 @@ class Database extends \SimpleSAML\Module\consent\Store public function __sleep() { return array( - '_dsn', - '_dateTime', - '_username', - '_password', - '_table', - '_timeout', + 'dsn', + 'dateTime', + 'username', + 'password', + 'table', + 'timeout', ); } @@ -170,9 +170,9 @@ class Database extends \SimpleSAML\Module\consent\Store assert(is_string($destinationId)); assert(is_string($attributeSet)); - $st = $this->_execute( - 'UPDATE '.$this->_table.' '. - 'SET usage_date = '.$this->_dateTime.' '. + $st = $this->execute( + 'UPDATE '.$this->table.' '. + 'SET usage_date = '.$this->dateTime.' '. 'WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', array($userId, $destinationId, $attributeSet) ); @@ -211,9 +211,9 @@ class Database extends \SimpleSAML\Module\consent\Store assert(is_string($attributeSet)); // Check for old consent (with different attribute set) - $st = $this->_execute( - 'UPDATE '.$this->_table.' '. - 'SET consent_date = '.$this->_dateTime.', usage_date = '.$this->_dateTime.', attribute = ? '. + $st = $this->execute( + 'UPDATE '.$this->table.' '. + 'SET consent_date = '.$this->dateTime.', usage_date = '.$this->dateTime.', attribute = ? '. 'WHERE hashed_user_id = ? AND service_id = ?', array($attributeSet, $userId, $destinationId) ); @@ -229,9 +229,9 @@ class Database extends \SimpleSAML\Module\consent\Store } // Add new consent - $st = $this->_execute( - 'INSERT INTO '.$this->_table.' ('.'consent_date, usage_date, hashed_user_id, service_id, attribute'. - ') '.'VALUES ('.$this->_dateTime.', '.$this->_dateTime.', ?, ?, ?)', + $st = $this->execute( + 'INSERT INTO '.$this->table.' ('.'consent_date, usage_date, hashed_user_id, service_id, attribute'. + ') '.'VALUES ('.$this->dateTime.', '.$this->dateTime.', ?, ?, ?)', array($userId, $destinationId, $attributeSet) ); @@ -257,8 +257,8 @@ class Database extends \SimpleSAML\Module\consent\Store assert(is_string($userId)); assert(is_string($destinationId)); - $st = $this->_execute( - 'DELETE FROM '.$this->_table.' WHERE hashed_user_id = ? AND service_id = ?;', + $st = $this->execute( + 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ?;', array($userId, $destinationId) ); @@ -288,8 +288,8 @@ class Database extends \SimpleSAML\Module\consent\Store { assert(is_string($userId)); - $st = $this->_execute( - 'DELETE FROM '.$this->_table.' WHERE hashed_user_id = ?', + $st = $this->execute( + 'DELETE FROM '.$this->table.' WHERE hashed_user_id = ?', array($userId) ); @@ -321,8 +321,8 @@ class Database extends \SimpleSAML\Module\consent\Store $ret = array(); - $st = $this->_execute( - 'SELECT service_id, attribute, consent_date, usage_date FROM '.$this->_table. + $st = $this->execute( + 'SELECT service_id, attribute, consent_date, usage_date FROM '.$this->table. ' WHERE hashed_user_id = ?', array($userId) ); @@ -350,12 +350,12 @@ class Database extends \SimpleSAML\Module\consent\Store * * @return \PDOStatement|false The statement, or false if execution failed. */ - private function _execute($statement, $parameters) + private function execute($statement, $parameters) { assert(is_string($statement)); assert(is_array($parameters)); - $db = $this->_getDB(); + $db = $this->getDB(); if ($db === false) { return false; } @@ -364,7 +364,7 @@ class Database extends \SimpleSAML\Module\consent\Store if ($st === false) { \SimpleSAML\Logger::error( 'consent:Database - Error preparing statement \''. - $statement.'\': '.self::_formatError($db->errorInfo()) + $statement.'\': '.self::formatError($db->errorInfo()) ); return false; } @@ -372,7 +372,7 @@ class Database extends \SimpleSAML\Module\consent\Store if ($st->execute($parameters) !== true) { \SimpleSAML\Logger::error( 'consent:Database - Error executing statement \''. - $statement.'\': '.self::_formatError($st->errorInfo()) + $statement.'\': '.self::formatError($st->errorInfo()) ); return false; } @@ -396,7 +396,7 @@ class Database extends \SimpleSAML\Module\consent\Store $ret = array(); // Get total number of consents - $st = $this->_execute('SELECT COUNT(*) AS no FROM '.$this->_table, array()); + $st = $this->execute('SELECT COUNT(*) AS no FROM '.$this->table, array()); if ($st === false) { return array(); @@ -407,9 +407,9 @@ class Database extends \SimpleSAML\Module\consent\Store } // Get total number of users that has given consent - $st = $this->_execute( + $st = $this->execute( 'SELECT COUNT(*) AS no '. - 'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->_table.' ) AS foo', + 'FROM (SELECT DISTINCT hashed_user_id FROM '.$this->table.' ) AS foo', array() ); @@ -422,8 +422,8 @@ class Database extends \SimpleSAML\Module\consent\Store } // Get total number of services that has been given consent to - $st = $this->_execute( - 'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->_table.') AS foo', + $st = $this->execute( + 'SELECT COUNT(*) AS no FROM (SELECT DISTINCT service_id FROM '.$this->table.') AS foo', array() ); @@ -444,25 +444,25 @@ class Database extends \SimpleSAML\Module\consent\Store * * @return \PDO|false Database handle, or false if we fail to connect. */ - private function _getDB() + private function getDB() { - if ($this->_db !== null) { - return $this->_db; + if ($this->db !== null) { + return $this->db; } $driver_options = array(); - if (isset($this->_timeout)) { - $driver_options[\PDO::ATTR_TIMEOUT] = $this->_timeout; + if (isset($this->timeout)) { + $driver_options[\PDO::ATTR_TIMEOUT] = $this->timeout; } - if (isset($this->_options)) { - $this->_options = array_merge($driver_options, $this->_options); + if (isset($this->options)) { + $this->options = array_merge($driver_options, $this->options); } else { - $this->_options = $driver_options; + $this->options = $driver_options; } - $this->_db = new \PDO($this->_dsn, $this->_username, $this->_password, $this->_options); + $this->db = new \PDO($this->dsn, $this->username, $this->password, $this->options); - return $this->_db; + return $this->db; } @@ -475,7 +475,7 @@ class Database extends \SimpleSAML\Module\consent\Store * * @return string Error text. */ - private static function _formatError($error) + private static function formatError($error) { assert(is_array($error)); assert(count($error) >= 3); @@ -491,8 +491,8 @@ class Database extends \SimpleSAML\Module\consent\Store */ public function selftest() { - $st = $this->_execute( - 'SELECT * FROM '.$this->_table.' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', + $st = $this->execute( + 'SELECT * FROM '.$this->table.' WHERE hashed_user_id = ? AND service_id = ? AND attribute = ?', array('test', 'test', 'test') ); diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 2bdfc82b8..24fe3b528 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -6,11 +6,10 @@ * authorizes the release of attributes. * * @package SimpleSAMLphp - */ -/** - * Explicit instruct consent page to send no-cache header to browsers to make + * + * Explicit instruct consent page to send no-cache header to browsers to make * sure the users attribute information are not store on client disk. - * + * * In an vanilla apache-php installation is the php variables set to: * * session.cache_limiter = nocache @@ -34,7 +33,7 @@ $state = \SimpleSAML\Auth\State::loadState($id, 'consent:request'); if (array_key_exists('core:SP', $state)) { $spentityid = $state['core:SP']; -} else if (array_key_exists('saml:sp:State', $state)) { +} elseif (array_key_exists('saml:sp:State', $state)) { $spentityid = $state['saml:sp:State']['core:SP']; } else { $spentityid = 'UNKNOWN'; @@ -57,7 +56,7 @@ if (array_key_exists('yes', $_REQUEST)) { } \SimpleSAML\Stats::log('consent:accept', $statsInfo); - if (array_key_exists('consent:store', $state) + if (array_key_exists('consent:store', $state) && array_key_exists('saveconsent', $_REQUEST) && $_REQUEST['saveconsent'] === '1' ) { @@ -69,7 +68,7 @@ if (array_key_exists('yes', $_REQUEST)) { \SimpleSAML\Logger::debug( 'Consent - saveConsent() : ['.$userId.'|'.$targetedId.'|'.$attributeSet.']' - ); + ); try { $store->saveConsent($userId, $targetedId, $attributeSet); } catch (\Exception $e) { @@ -169,7 +168,7 @@ if (array_key_exists('privacypolicy', $state['Destination'])) { if ($privacypolicy !== false) { $privacypolicy = str_replace( '%SPENTITYID%', - urlencode($spentityid), + urlencode($spentityid), $privacypolicy ); } diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php index 3895ef9f7..b9bc74667 100644 --- a/modules/consentAdmin/templates/consentadmin.php +++ b/modules/consentAdmin/templates/consentadmin.php @@ -1,6 +1,8 @@ -<?php - $this->data['head'] = '<link rel="stylesheet" type="text/css" href="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/css/consentAdmin.css").'" />'."\n"; - $this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentAdmin.js").'"></script>'; +<?php + $this->data['head'] = '<link rel="stylesheet" type="text/css" href="'. + SimpleSAML\Module::getModuleURL("consentAdmin/assets/css/consentAdmin.css").'" />'."\n"; + $this->data['head'] .= '<script type="text/javascript" src="'. + SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentAdmin.js").'"></script>'; // default theme $this->includeAtTemplateBase('includes/header.php'); ?> @@ -22,7 +24,8 @@ $attributes_text = $this->t('{consentAdmin:consentadmin:attributes_text}'); foreach ($spList as $spName => $spValues) { if (!is_null($spValues['serviceurl'])) { - $htmlSpName = '<a class="serviceUrl" href="'.$spValues['serviceurl'].'">'.htmlspecialchars($spValues['name']).'</a>'; + $htmlSpName = '<a class="serviceUrl" href="'.$spValues['serviceurl'].'">'. + htmlspecialchars($spValues['name']).'</a>'; } else { $htmlSpName = htmlspecialchars($spValues['name']); } @@ -35,7 +38,10 @@ <tr class="$row_class"> <td> <table> - <tr class="$row_class"><td><span class='caSPName'><span title='$spDescription'>$htmlSpName</span> <span class="show_hide" id="show_hide_$show_spid"><span id='showing_$show_spid'>$show_text</span><span id='hiding_$show_spid'>$hide_text</span> $attributes_text</span></span></td></tr> + <tr class="$row_class"> + <td><span class='caSPName'><span title='$spDescription'>$htmlSpName</span>  + <span class="show_hide" id="show_hide_$show_spid"><span id='showing_$show_spid'>$show_text</span> + <span id='hiding_$show_spid'>$hide_text</span> $attributes_text</span></span></td></tr> <tr><td colspan="2" class="caAttributes"><div id="attributes_$show_spid"> TRSTART; $attributes = $spValues['attributes_by_sp']; @@ -44,8 +50,7 @@ TRSTART; } echo "\n<ul>\n"; foreach ($attributes as $name => $value) { - - if (sizeof($value) > 1) { + if (sizeof($value) > 1) { echo "<li>".htmlspecialchars($name).":\n<ul>\n"; foreach ($value as $v) { echo '<li>'.htmlspecialchars($v)."</li>\n"; @@ -61,7 +66,9 @@ TRSTART; </table> </td> -<td class='caAllowed'><input id="checkbox_$show_spid" class="checkbox" value='$consentValue' type='checkbox' $checkedAttr /><span id="consentText_$show_spid">$consentText</span></td> +<td class='caAllowed'> + <input id="checkbox_$show_spid" class="checkbox" value='$consentValue' type='checkbox' $checkedAttr /> + <span id="consentText_$show_spid">$consentText</span></td> TRSTART; echo "</tr>\n"; $show_spid++; @@ -73,7 +80,11 @@ TRSTART; <?php echo $this->t('{consentAdmin:consentadmin:consentadmin_description2}') ?> </p> <h2>Logout</h2> - - <p><a href="<?php echo \SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php', array('logout' => 1)); ?>">Logout</a></p> + <p> + <a href=" + <?php + echo \SimpleSAML\Module::getModuleURL('consentAdmin/consentAdmin.php', array('logout' => 1)); + ?>">Logout</a> + </p> <?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/consentAdmin/templates/consentadminajax.php b/modules/consentAdmin/templates/consentadminajax.php index f6d54c72d..c8520b085 100644 --- a/modules/consentAdmin/templates/consentadminajax.php +++ b/modules/consentAdmin/templates/consentadminajax.php @@ -1,2 +1,2 @@ -<?php +<?php echo $res; diff --git a/modules/consentAdmin/www/assets/js/consentAdmin.js b/modules/consentAdmin/www/assets/js/consentAdmin.js index 7c0359cd4..59cf4e17b 100644 --- a/modules/consentAdmin/www/assets/js/consentAdmin.js +++ b/modules/consentAdmin/www/assets/js/consentAdmin.js @@ -16,7 +16,7 @@ function checkConsent() url = url+"&action="+checkbox.checked url = url+"&sid="+Math.random() - xmlHttp.onreadystatechange=function() { + xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { document.getElementById("consentText_" + show_spid).innerHTML = xmlHttp.responseText; } diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index bbb281c07..8591a9c62 100644 --- a/modules/consentAdmin/www/consentAdmin.php +++ b/modules/consentAdmin/www/consentAdmin.php @@ -24,8 +24,7 @@ function driveProcessingChain( $userid, $hashAttributes = false, $excludeAttributes = array() -) -{ +) { /* * Create a new processing chain */ @@ -122,7 +121,11 @@ if ($as->getAuthData('saml:sp:IdP') !== null) { } // Get user ID -$userid_attributename = (isset($idp_metadata['userid.attribute']) && is_string($idp_metadata['userid.attribute'])) ? $idp_metadata['userid.attribute'] : 'eduPersonPrincipalName'; +if (isset($idp_metadata['userid.attribute']) && is_string($idp_metadata['userid.attribute'])) { + $userid_attributename = $idp_metadata['userid.attribute']; +} else { + $userid_attributename = 'eduPersonPrincipalName'; +} $userids = $attributes[$userid_attributename]; @@ -168,14 +171,26 @@ $hashed_user_id = \SimpleSAML\Module\consent\Auth\Process\Consent::getHashedUser // If a checkbox have been clicked if ($action !== null && $sp_entityid !== null) { // init template to enable translation of status messages - $template = new \SimpleSAML\XHTML\Template($config, 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin'); + $template = new \SimpleSAML\XHTML\Template( + $config, + 'consentAdmin:consentadminajax.php', + 'consentAdmin:consentadmin' + ); // Get SP metadata $sp_metadata = $metadata->getMetaData($sp_entityid, 'saml20-sp-remote'); // Run AuthProc filters - list($targeted_id, $attribute_hash, $attributes_new) = driveProcessingChain($idp_metadata, $source, $sp_metadata, - $sp_entityid, $attributes, $userid, $hashAttributes, $excludeAttributes); + list($targeted_id, $attribute_hash, $attributes_new) = driveProcessingChain( + $idp_metadata, + $source, + $sp_metadata, + $sp_entityid, + $attributes, + $userid, + $hashAttributes, + $excludeAttributes + ); // Add a consent (or update if attributes have changed and old consent for SP and IdP exists) if ($action == 'true') { @@ -228,8 +243,16 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { $sp_metadata = $metadata->getMetaData($sp_entityid, 'saml20-sp-remote'); // Run attribute filters - list($targeted_id, $attribute_hash, $attributes_new) = driveProcessingChain($idp_metadata, $source, $sp_metadata, - $sp_entityid, $attributes, $userid, $hashAttributes, $excludeAttributes); + list($targeted_id, $attribute_hash, $attributes_new) = driveProcessingChain( + $idp_metadata, + $source, + $sp_metadata, + $sp_entityid, + $attributes, + $userid, + $hashAttributes, + $excludeAttributes + ); // Translate attribute-names foreach ($attributes_new as $orig_name => $value) { diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index 2f40c8cfe..1dd97a96c 100644 --- a/modules/core/hooks/hook_sanitycheck.php +++ b/modules/core/hooks/hook_sanitycheck.php @@ -28,7 +28,8 @@ function core_hook_sanitycheck(&$hookinfo) if (version_compare(phpversion(), '5.4', '>=')) { $hookinfo['info'][] = '[core] You are running a PHP version suitable for SimpleSAMLphp.'; } else { - $hookinfo['errors'][] = '[core] You are running an old PHP installation. Please check the requirements for your SimpleSAMLphp version and upgrade.'; + $hookinfo['errors'][] = '[core] You are running an old PHP installation. '. + 'Please check the requirements for your SimpleSAMLphp version and upgrade.'; } $info = array(); diff --git a/modules/core/lib/ACL.php b/modules/core/lib/ACL.php index aa67c31c5..558bf9479 100644 --- a/modules/core/lib/ACL.php +++ b/modules/core/lib/ACL.php @@ -40,7 +40,9 @@ class ACL $action = array_shift($rule); if ($action !== 'allow' && $action !== 'deny') { - throw new \SimpleSAML\Error\Exception('Invalid action in rule in access control list: '.var_export($action, true)); + throw new \SimpleSAML\Error\Exception( + 'Invalid action in rule in access control list: '.var_export($action, true) + ); } } $this->acl = $acl; diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index 5672947c6..d17c74d29 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -168,7 +168,8 @@ class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter // replace only the part that matches if ($this->subject === $this->target) { $attributes[$this->target] = preg_replace( - $this->pattern, $this->replacement, + $this->pattern, + $this->replacement, $attributes[$this->subject] ); } else { diff --git a/modules/core/lib/Auth/Process/AttributeCopy.php b/modules/core/lib/Auth/Process/AttributeCopy.php index 44d3b71f0..127eafec6 100644 --- a/modules/core/lib/Auth/Process/AttributeCopy.php +++ b/modules/core/lib/Auth/Process/AttributeCopy.php @@ -38,7 +38,6 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($config)); foreach ($config as $source => $destination) { - if (!is_string($source)) { throw new \Exception('Invalid source attribute name: '.var_export($source, true)); } diff --git a/modules/core/lib/Auth/Process/Cardinality.php b/modules/core/lib/Auth/Process/Cardinality.php index 6f85b8b39..204de7f6f 100644 --- a/modules/core/lib/Auth/Process/Cardinality.php +++ b/modules/core/lib/Auth/Process/Cardinality.php @@ -114,7 +114,6 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter } foreach ($request['Attributes'] as $k => $v) { - if (!array_key_exists($k, $this->cardinality)) { continue; } @@ -125,12 +124,20 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter /* minimum cardinality */ if (count($v) < $this->cardinality[$k]['min']) { if ($this->cardinality[$k]['warn']) { - \SimpleSAML\Logger::warning(sprintf( - 'Cardinality: attribute %s from %s does not meet minimum cardinality of %d (%d)', - $k, $entityid, $this->cardinality[$k]['min'], count($v) - )); + \SimpleSAML\Logger::warning( + sprintf( + 'Cardinality: attribute %s from %s does not meet minimum cardinality of %d (%d)', + $k, + $entityid, + $this->cardinality[$k]['min'], + count($v) + ) + ); } else { - $request['core:cardinality:errorAttributes'][$k] = array(count($v), $this->cardinality[$k]['_expr']); + $request['core:cardinality:errorAttributes'][$k] = array( + count($v), + $this->cardinality[$k]['_expr'] + ); } continue; } @@ -138,12 +145,20 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter /* maximum cardinality */ if (array_key_exists('max', $this->cardinality[$k]) && count($v) > $this->cardinality[$k]['max']) { if ($this->cardinality[$k]['warn']) { - \SimpleSAML\Logger::warning(sprintf( - 'Cardinality: attribute %s from %s does not meet maximum cardinality of %d (%d)', - $k, $entityid, $this->cardinality[$k]['max'], count($v) - )); + \SimpleSAML\Logger::warning( + sprintf( + 'Cardinality: attribute %s from %s does not meet maximum cardinality of %d (%d)', + $k, + $entityid, + $this->cardinality[$k]['max'], + count($v) + ) + ); } else { - $request['core:cardinality:errorAttributes'][$k] = array(count($v), $this->cardinality[$k]['_expr']); + $request['core:cardinality:errorAttributes'][$k] = array( + count($v), + $this->cardinality[$k]['_expr'] + ); } continue; } @@ -157,10 +172,14 @@ class Cardinality extends \SimpleSAML\Auth\ProcessingFilter if ($this->cardinality[$k]['warn']) { \SimpleSAML\Logger::warning(sprintf( 'Cardinality: attribute %s from %s is missing', - $k, $entityid + $k, + $entityid )); } else { - $request['core:cardinality:errorAttributes'][$k] = array(0, $this->cardinality[$k]['_expr']); + $request['core:cardinality:errorAttributes'][$k] = array( + 0, + $this->cardinality[$k]['_expr'] + ); } } diff --git a/modules/core/lib/Auth/Process/CardinalitySingle.php b/modules/core/lib/Auth/Process/CardinalitySingle.php index be7707e59..ce4b12aac 100644 --- a/modules/core/lib/Auth/Process/CardinalitySingle.php +++ b/modules/core/lib/Auth/Process/CardinalitySingle.php @@ -55,7 +55,11 @@ class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter $this->firstValue = $config['firstValue']; } if (array_key_exists('flattenWith', $config)) { - $this->flattenWith = is_array($config['flattenWith']) ? array_shift($config['flattenWith']) : $config['flattenWith']; + if (is_array($config['flattenWith'])) { + $this->flattenWith = array_shift($config['flattenWith']); + } else { + $this->flattenWith = $config['flattenWith']; + } } if (array_key_exists('flatten', $config)) { $this->flatten = $config['flatten']; diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php index 4d28c5cf7..92102262b 100644 --- a/modules/core/lib/Auth/Process/ExtendIdPSession.php +++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php @@ -35,7 +35,9 @@ class ExtendIdPSession extends \SimpleSAML\Auth\ProcessingFilter // If remember me is active $rememberMeExpire = $session->getRememberMeExpire(); - if (!empty($state['RememberMe']) && $rememberMeExpire !== null && $globalConfig->getBoolean('session.rememberme.enable', false)) { + if (!empty($state['RememberMe']) && $rememberMeExpire !== null && + $globalConfig->getBoolean('session.rememberme.enable', false) + ) { $session->setRememberMeExpire(); return; } diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php index 12af86f80..c8069eb31 100644 --- a/modules/core/lib/Auth/Process/GenerateGroups.php +++ b/modules/core/lib/Auth/Process/GenerateGroups.php @@ -135,7 +135,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter return preg_replace_callback( '/([^a-zA-Z0-9_@=.])/', - function($m) { + function ($m) { return sprintf("%%%02x", ord($m[1])); }, $string diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php index 7a538ec1b..f3c9a293e 100644 --- a/modules/core/lib/Auth/Process/PHP.php +++ b/modules/core/lib/Auth/Process/PHP.php @@ -49,7 +49,9 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($request)); assert(array_key_exists('Attributes', $request)); - $function = function(/** @scrutinizer ignore-unused */ &$attributes) { eval($this->code); }; + $function = function (/** @scrutinizer ignore-unused */ &$attributes) { + eval($this->code); + }; $function($request['Attributes']); } } diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php index 8b73c77a8..46da86828 100644 --- a/modules/core/lib/Storage/SQLPermanentStorage.php +++ b/modules/core/lib/Storage/SQLPermanentStorage.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Module\core\Storage; /** * SQLPermanentStorage - * + * * Generic SQL Store to store key value pairs. To be used in several other modules that needs * to store data permanently. * @@ -26,7 +26,7 @@ class SQLPermanentStorage if (!is_dir($datadir)) { throw new \Exception('Data directory ['.$datadir.'] does not exist'); - } else if (!is_writable($datadir)) { + } elseif (!is_writable($datadir)) { throw new \Exception('Data directory ['.$datadir.'] is not writable'); } @@ -51,7 +51,7 @@ class SQLPermanentStorage PRIMARY KEY (key1,key2,type) ); '); - } + } } else { throw new \Exception('Error creating SQL lite database ['.$dbfile.'].'); } @@ -86,7 +86,8 @@ class SQLPermanentStorage { $expire = is_null($duration) ? null : (time() + $duration); - $query = "UPDATE data SET updated = :updated, value = :value, expire = :expire WHERE key1 = :key1 AND key2 = :key2 AND type = :type"; + $query = "UPDATE data SET updated = :updated, value = :value, ". + "expire = :expire WHERE key1 = :key1 AND key2 = :key2 AND type = :type"; $prepared = $this->db->prepare($query); $data = array(':key1' => $key1, ':key2' => $key2, ':type' => $type, ':updated' => time(), @@ -216,4 +217,3 @@ class SQLPermanentStorage return join(' AND ', $conditions); } } - diff --git a/modules/core/templates/authsource_list.tpl.php b/modules/core/templates/authsource_list.tpl.php index db0a7cede..20522518d 100644 --- a/modules/core/templates/authsource_list.tpl.php +++ b/modules/core/templates/authsource_list.tpl.php @@ -4,14 +4,13 @@ * */ $this->data['header'] = 'Test authentication sources'; - $this->includeAtTemplateBase('includes/header.php'); ?> <h1><?php echo $this->data['header']; ?></h1> <ul> <?php foreach ($this->data['sources'] as $id) { - echo '<li><a href="?as=' . htmlspecialchars(urlencode($id)) . '">' . htmlspecialchars($id) . '</a></li>'; + echo '<li><a href="?as='.htmlspecialchars(urlencode($id)).'">'.htmlspecialchars($id).'</a></li>'; } ?> </ul> diff --git a/modules/core/templates/cardinality_error.tpl.php b/modules/core/templates/cardinality_error.tpl.php index dc75c540a..036f06a67 100644 --- a/modules/core/templates/cardinality_error.tpl.php +++ b/modules/core/templates/cardinality_error.tpl.php @@ -20,18 +20,17 @@ $this->includeAtTemplateBase('includes/header.php'); <p><?php echo $this->data['cardinality_text']; ?></p> <h3><?php echo $this->data['problematic_attributes']; ?></h3> <dl class="cardinalityErrorAttributes"> -<?php foreach ($this->data['cardinalityErrorAttributes'] as $attr => $v) { ?> - <dt><?php echo $attr ?></td> - <dd><?php echo $this->t('{core:cardinality:got_want}', array('%GOT%' => $v[0], '%WANT%' => htmlspecialchars($v[1]))) ?></dd> - </tr> -<?php } ?> -</dl> <?php +foreach ($this->data['cardinalityErrorAttributes'] as $attr => $v) { + echo '<dt>'.$attr.'</td><dd>'; + echo $this->t( + '{core:cardinality:got_want}', + array('%GOT%' => $v[0], '%WANT%' => htmlspecialchars($v[1])) + ); + echo '</dd></tr>'; +} +echo '</dl>'; if (isset($this->data['LogoutURL'])) { -?> -<p><a href="<?php echo htmlspecialchars($this->data['LogoutURL']); ?>"><?php echo $this->t('{status:logout}'); ?></a></p> -<?php + echo '<p><a href="'.htmlspecialchars($this->data['LogoutURL']).'>">'.$this->t('{status:logout}').'</a></p>'; } -?> -<?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/frontpage_auth.tpl.php b/modules/core/templates/frontpage_auth.tpl.php index f0594948f..afb55b30d 100644 --- a/modules/core/templates/frontpage_auth.tpl.php +++ b/modules/core/templates/frontpage_auth.tpl.php @@ -1,34 +1,30 @@ -<?php +<?php $this->data['header'] = $this->t('{core:frontpage:page_title}'); -$this->includeAtTemplateBase('includes/header.php'); +$this->includeAtTemplateBase('includes/header.php'); ?> <?php if ($this->data['isadmin']) { - echo '<p class="float-r youareadmin">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r youareadmin">'.$this->t('{core:frontpage:loggedin_as_admin}').'</p>'; } else { - echo '<p class="float-r youareadmin"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r youareadmin"><a href="'.$this->data['loginurl'].'">'. + $this->t('{core:frontpage:login_as_admin}').'</a></p>'; } ?> - - -<!-- <h2><?php echo $this->t('{core:frontpage:useful_links_header}'); ?></h2> --> +<!-- <h2><?php echo $this->t('{core:frontpage:useful_links_header}'); ?></h2> --> <ul> <?php - foreach ($this->data['links_auth'] AS $link) { - echo '<li><a href="' . htmlspecialchars($link['href']) . '">' . $this->t($link['text']) . '</a>'; - if (isset($link['deprecated']) && $link['deprecated']) { - echo ' <b>' . $this->t('{core:frontpage:deprecated}') . '</b>'; - } - echo '</li>'; - } +foreach ($this->data['links_auth'] as $link) { + echo '<li><a href="'.htmlspecialchars($link['href']).'">'.$this->t($link['text']).'</a>'; + if (isset($link['deprecated']) && $link['deprecated']) { + echo ' <b>'.$this->t('{core:frontpage:deprecated}').'</b>'; + } + echo '</li>'; +} ?> </ul> - - - <?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/frontpage_config.tpl.php b/modules/core/templates/frontpage_config.tpl.php index 3e4b52701..10f7463cf 100644 --- a/modules/core/templates/frontpage_config.tpl.php +++ b/modules/core/templates/frontpage_config.tpl.php @@ -5,93 +5,74 @@ $this->includeAtTemplateBase('includes/header.php'); ?> - <!-- <div id="tabdiv"> <ul> - <li><a href="#welcome"><?php echo $this->t('{core:frontpage:welcome}'); ?></a></li> - <li><a href="#configuration"><?php echo $this->t('{core:frontpage:configuration}'); ?></a></li> - <li><a href="#metadata"><?php echo $this->t('{core:frontpage:metadata}'); ?></a></li> + <li><a href="#welcome"><?php echo $this->t('{core:frontpage:welcome}'); ?></a></li> + <li><a href="#configuration"><?php echo $this->t('{core:frontpage:configuration}'); ?></a></li> + <li><a href="#metadata"><?php echo $this->t('{core:frontpage:metadata}'); ?></a></li> </ul> --> <?php if ($this->data['isadmin']) { - echo '<p class="float-r youareadmin">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r youareadmin">'.$this->t('{core:frontpage:loggedin_as_admin}').'</p>'; } else { - echo '<p class="float-r youareadmin"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r youareadmin"><a href="'.$this->data['loginurl'].'">'. + $this->t('{core:frontpage:login_as_admin}').'</a></p>'; } ?> - - - <div style="margin-top: 1em;"> - <code style="background: white; background: #f5f5f5; border: 1px dotted #bbb; padding: 1em; color: #555" ><?php - echo $this->data['directory'] . ' (' . $this->data['version'] . ')'; - ?></code> + <code style="background: white; background: #f5f5f5; border: 1px dotted #bbb; padding: 1em; color: #555" ><?php + echo $this->data['directory'].' ('.$this->data['version'].')'; + ?></code> </div> - - <div style="clear: both" class="enablebox mini"> - <table> - - <?php - $icon_enabled = '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/accept.png" alt="enabled" />'; - $icon_disabled = '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="disabled" />'; - ?> - - <tr class="<?php echo $this->data['enablematrix']['saml20idp'] ? 'enabled' : 'disabled'; ?>"><td>SAML 2.0 IdP</td> - <td><?php echo $this->data['enablematrix']['saml20idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> - - <tr class="<?php echo $this->data['enablematrix']['shib13idp'] ? 'enabled' : 'disabled'; ?>"><td>Shib 1.3 IdP</td> - <td><?php echo $this->data['enablematrix']['shib13idp'] ? $icon_enabled : $icon_disabled; ?></td></tr> - - </table> -</div> + <table> + <?php + $icon_enabled = '<img src="/'.$this->data['baseurlpath'].'resources/icons/silk/accept.png" alt="enabled" />'; + $icon_disabled = '<img src="/'.$this->data['baseurlpath'].'resources/icons/silk/delete.png" alt="disabled" />'; + echo '<tr class="'.($this->data['enablematrix']['saml20idp'] ? 'enabled' : 'disabled').'"><td>SAML 2.0 IdP</td>'; + echo '<td>'.($this->data['enablematrix']['saml20idp'] ? $icon_enabled : $icon_disabled).'</td></tr>'; + echo '<tr class="'.($this->data['enablematrix']['shib13idp'] ? 'enabled' : 'disabled').'"><td>Shib 1.3 IdP</td>'; + echo '<td>'.($this->data['enablematrix']['shib13idp'] ? $icon_enabled : $icon_disabled).'</td></tr>'; + ?> + + </table> +</div> <h2><?php echo $this->t('{core:frontpage:configuration}'); ?></h2> <ul> <?php - foreach ($this->data['links_config'] AS $link) { - echo '<li><a href="' . htmlspecialchars($link['href']) . '">' . $this->t($link['text']) . '</a></li>'; - } +foreach ($this->data['links_config'] as $link) { + echo '<li><a href="'.htmlspecialchars($link['href']).'">'.$this->t($link['text']).'</a></li>'; +} ?> </ul> - <?php - if (array_key_exists('warnings', $this->data) && is_array($this->data['warnings']) && !empty($this->data['warnings'])) { - - echo '<h2>' . $this->t('{core:frontpage:warnings}') . '</h2>'; +if (array_key_exists('warnings', $this->data) && is_array($this->data['warnings']) && !empty($this->data['warnings'])) { + echo '<h2>'.$this->t('{core:frontpage:warnings}').'</h2>'; + foreach ($this->data['warnings'] as $warning) { + echo '<div class="caution">'.$warning.'</div>'; + } +} - foreach($this->data['warnings'] AS $warning) { - echo '<div class="caution">'.$warning.'</div>'; - } - } -?> -<?php if ($this->data['isadmin']) { - - echo '<h2>'. $this->t('{core:frontpage:checkphp}') . '</h2>'; - echo '<div class="enablebox"><table>'; - - - $icon_enabled = '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/accept.png" alt="enabled" />'; - $icon_disabled = '<img src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="disabled" />'; - - - foreach ($this->data['funcmatrix'] AS $func) { - echo '<tr class="' . ($func['enabled'] ? 'enabled' : 'disabled') . '"><td>' . ($func['enabled'] ? $icon_enabled : $icon_disabled) . '</td>'; - echo '<td>' . $this->t($this->data['requiredmap'][$func['required']]) . '</td><td>' . $func['descr'] . '</td></tr>'; - } - echo('</table></div>'); + echo '<h2>'.$this->t('{core:frontpage:checkphp}').'</h2>'; + echo '<div class="enablebox"><table>'; + + $icon_enabled = '<img src="/'.$this->data['baseurlpath'].'resources/icons/silk/accept.png" alt="enabled" />'; + $icon_disabled = '<img src="/'.$this->data['baseurlpath'].'resources/icons/silk/delete.png" alt="disabled" />'; + + foreach ($this->data['funcmatrix'] as $func) { + echo '<tr class="'.($func['enabled'] ? 'enabled' : 'disabled').'"><td>'. + ($func['enabled'] ? $icon_enabled : $icon_disabled).'</td>'; + echo '<td>'.$this->t($this->data['requiredmap'][$func['required']]).'</td><td>'.$func['descr'].'</td></tr>'; + } + echo '</table></div>'; } -?> - - - - -<?php $this->includeAtTemplateBase('includes/footer.php'); +$this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php index f6e1596c5..2516c065a 100644 --- a/modules/core/templates/frontpage_federation.tpl.php +++ b/modules/core/templates/frontpage_federation.tpl.php @@ -43,7 +43,6 @@ if (is_array($this->data['metaentries']['hosted']) && count($this->data['metaent if (is_array($this->data['metaentries']['remote']) && count($this->data['metaentries']['remote']) > 0) { $now = time(); foreach ($this->data['metaentries']['remote'] as $setkey => $set) { - echo '<fieldset class="fancyfieldset"><legend>'.$this->t($this->data['mtype'][$setkey]).' (Trusted)</legend>'; echo '<ul>'; foreach ($set as $entry) { @@ -81,26 +80,26 @@ if (is_array($this->data['metaentries']['remote']) && count($this->data['metaent echo '</fieldset>'; } } + +echo '<h2>'.$this->t('{core:frontpage:tools}').'</h2>'; +echo '<ul>'; +foreach ($this->data['links_federation'] as $link) { + echo '<li><a href="'.htmlspecialchars($link['href']).'">'.$this->t($link['text']).'</a></li>'; +} +echo '</ul>'; +if ($this->data['isadmin']) { ?> - <h2><?php echo $this->t('{core:frontpage:tools}'); ?></h2> - <ul><?php - foreach ($this->data['links_federation'] as $link) { - echo '<li><a href="'.htmlspecialchars($link['href']).'">'.$this->t($link['text']).'</a></li>'; - } -?> - </ul> -<?php - if ($this->data['isadmin']) { ?> <fieldset class="fancyfieldset"> <legend>Lookup metadata</legend> <form action="<?php echo SimpleSAML\Module::getModuleURL('core/show_metadata.php'); ?>" method="get"> <p style="margin: 1em 2em ">Look up metadata for entity: - <select name="set"><?php - if (is_array($this->data['metaentries']['remote']) && count($this->data['metaentries']['remote']) > 0) { - foreach ($this->data['metaentries']['remote'] as $setkey => $set) { - echo '<option value="'.htmlspecialchars($setkey).'">'.$this->t($this->data['mtype'][$setkey]).'</option>'; - } - } + <select name="set"> +<?php + if (is_array($this->data['metaentries']['remote']) && count($this->data['metaentries']['remote']) > 0) { + foreach ($this->data['metaentries']['remote'] as $setkey => $set) { + echo '<option value="'.htmlspecialchars($setkey).'">'.$this->t($this->data['mtype'][$setkey]).'</option>'; + } + } ?> </select> <input type="text" name="entityid" /> @@ -109,5 +108,5 @@ if (is_array($this->data['metaentries']['remote']) && count($this->data['metaent </form> </fieldset> <?php - } +} $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/frontpage_welcome.tpl.php b/modules/core/templates/frontpage_welcome.tpl.php index 33d5ff251..ae9f923e7 100644 --- a/modules/core/templates/frontpage_welcome.tpl.php +++ b/modules/core/templates/frontpage_welcome.tpl.php @@ -1,36 +1,25 @@ -<?php - +<?php $this->data['header'] = $this->t('{core:frontpage:page_title}'); -$this->includeAtTemplateBase('includes/header.php'); - -?> - +$this->includeAtTemplateBase('includes/header.php'); -<?php if ($this->data['isadmin']) { - echo '<p class="float-r youareadmin">' . $this->t('{core:frontpage:loggedin_as_admin}') . '</p>'; + echo '<p class="float-r youareadmin">'.$this->t('{core:frontpage:loggedin_as_admin}').'</p>'; } else { - echo '<p class="float-r youareadmin"><a href="' . $this->data['loginurl'] . '">' . $this->t('{core:frontpage:login_as_admin}') . '</a></p>'; + echo '<p class="float-r youareadmin"><a href="'.$this->data['loginurl'].'">'. + $this->t('{core:frontpage:login_as_admin}').'</a></p>'; } ?> <p><?php echo $this->t('{core:frontpage:intro}'); ?></p> - <ul> <?php - foreach ($this->data['links_welcome'] AS $link) { - echo '<li><a href="' . htmlspecialchars($link['href']) . '">' . $this->t($link['text']) . '</a></li>'; - } +foreach ($this->data['links_welcome'] as $link) { + echo '<li><a href="'. htmlspecialchars($link['href']).'">'.$this->t($link['text']).'</a></li>'; +} ?> </ul> - - - - <h2><?php echo $this->t('{core:frontpage:about_header}'); ?></h2> - <p><?php echo $this->t('{core:frontpage:about_text}'); ?></p> - - +<h2><?php echo $this->t('{core:frontpage:about_header}'); ?></h2> +<p><?php echo $this->t('{core:frontpage:about_text}'); ?></p> - <?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/loginuserpass.php b/modules/core/templates/loginuserpass.php index 4e012eee1..9e0fc646a 100644 --- a/modules/core/templates/loginuserpass.php +++ b/modules/core/templates/loginuserpass.php @@ -8,26 +8,37 @@ if (strlen($this->data['username']) > 0) { } $this->includeAtTemplateBase('includes/header.php'); -?> - -<?php if ($this->data['errorcode'] !== null) { - ?> +?> <div style="border-left: 1px solid #e8e8e8; border-bottom: 1px solid #e8e8e8; background: #f5f5f5"> <img src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-error.48x48.png" class="float-l erroricon" style="margin: 15px" alt=""/> <h2><?php echo $this->t('{login:error_header}'); ?></h2> - <p><strong><?php - echo htmlspecialchars($this->t($this->data['errorcodes']['title'][$this->data['errorcode']], $this->data['errorparams'])); ?></strong></p> - - <p><?php - echo htmlspecialchars($this->t($this->data['errorcodes']['descr'][$this->data['errorcode']], $this->data['errorparams'])); ?></p> + <p><strong> + <?php + echo htmlspecialchars( + $this->t( + $this->data['errorcodes']['title'][$this->data['errorcode']], + $this->data['errorparams'] + ) + ); + ?> + </strong></p> + <p> + <?php + echo htmlspecialchars( + $this->t( + $this->data['errorcodes']['descr'][$this->data['errorcode']], + $this->data['errorparams'] + ) + ); + ?> + </p> </div> <?php } - ?> <h2 style="break: both"><?php echo $this->t('{login:user_pass_header}'); ?></h2> @@ -38,15 +49,14 @@ if ($this->data['errorcode'] !== null) { <tr> <td rowspan="2" class="loginicon"> <img alt="" - src="/<?php echo $this->data['baseurlpath']; ?>resources/icons/experience/gtk-dialog-authentication.48x48.png" /> + src="/<?php echo $this->data['baseurlpath']; ?> + resources/icons/experience/gtk-dialog-authentication.48x48.png" /> </td> <td><label for="username"><?php echo $this->t('{login:username}'); ?></label></td> <td> <input id="username" <?php echo ($this->data['forceUsername']) ? 'disabled="disabled"' : ''; ?> - type="text" name="username" -<?php if (!$this->data['forceUsername']) { - echo 'tabindex="1"'; -} ?> value="<?php echo htmlspecialchars($this->data['username']); ?>"/> + type="text" name="username"<?php echo $this->data['forceUsername'] ? '' : 'tabindex="1"'; ?> + value="<?php echo htmlspecialchars($this->data['username']); ?>" /> </td> <?php if ($this->data['rememberUsernameEnabled'] && !$this->data['forceUsername']) { @@ -55,7 +65,7 @@ if ($this->data['errorcode'] !== null) { <td id="regular_remember_username"> <input type="checkbox" id="remember_username" tabindex="4" <?php echo ($this->data['rememberUsernameChecked']) ? 'checked="checked"' : ''; ?> - name="remember_username" value="Yes"/> + name="remember_username" value="Yes" /> <small><?php echo $this->t('{login:remember_username}'); ?></small> </td> <?php @@ -65,24 +75,22 @@ if ($this->data['errorcode'] !== null) { <?php if ($this->data['rememberUsernameEnabled'] && !$this->data['forceUsername']) { // display the "remember my username" checkbox - ?> + ?> <tr id="mobile_remember_username"> <td> </td> <td> <input type="checkbox" id="remember_username" tabindex="4" <?php echo ($this->data['rememberUsernameChecked']) ? 'checked="checked"' : ''; ?> - name="remember_username" value="Yes"/> + name="remember_username" value="Yes" /> <small><?php echo $this->t('{login:remember_username}'); ?></small> </td> </tr> - <?php + <?php } ?> <tr> <td><label for="password"><?php echo $this->t('{login:password}'); ?></label></td> - <td> - <input id="password" type="password" tabindex="2" name="password"/> - </td> + <td><input id="password" type="password" tabindex="2" name="password" /></td> <?php if ($this->data['rememberMeEnabled']) { // display the remember me checkbox (keep me logged in) @@ -90,7 +98,7 @@ if ($this->data['errorcode'] !== null) { <td id="regular_remember_me"> <input type="checkbox" id="remember_me" tabindex="5" <?php echo ($this->data['rememberMeChecked']) ? 'checked="checked"' : ''; ?> - name="remember_me" value="Yes"/> + name="remember_me" value="Yes" /> <small><?php echo $this->t('{login:remember_me}'); ?></small> </td> <?php @@ -106,7 +114,7 @@ if ($this->data['errorcode'] !== null) { <td id="mobile_remember_me"> <input type="checkbox" id="remember_me" tabindex="5" <?php echo ($this->data['rememberMeChecked']) ? 'checked="checked"' : ''; ?> - name="remember_me" value="Yes"/> + name="remember_me" value="Yes" /> <small><?php echo $this->t('{login:remember_me}'); ?></small> </td> </tr> @@ -115,45 +123,47 @@ if ($this->data['errorcode'] !== null) { ?> <?php if (array_key_exists('organizations', $this->data)) { - ?> + ?> <tr> <td></td> <td><label for="organization"><?php echo $this->t('{login:organization}'); ?></label></td> <td><select name="organization" tabindex="3"> - <?php - if (array_key_exists('selectedOrg', $this->data)) { - $selectedOrg = $this->data['selectedOrg']; - } else { - $selectedOrg = null; - } - - foreach ($this->data['organizations'] as $orgId => $orgDesc) { - if (is_array($orgDesc)) { - $orgDesc = $this->t($orgDesc); - } + <?php + if (array_key_exists('selectedOrg', $this->data)) { + $selectedOrg = $this->data['selectedOrg']; + } else { + $selectedOrg = null; + } - if ($orgId === $selectedOrg) { - $selected = 'selected="selected" '; - } else { - $selected = ''; - } + foreach ($this->data['organizations'] as $orgId => $orgDesc) { + if (is_array($orgDesc)) { + $orgDesc = $this->t($orgDesc); + } - echo '<option '.$selected.'value="'.htmlspecialchars($orgId).'">'.htmlspecialchars($orgDesc).'</option>'; + if ($orgId === $selectedOrg) { + $selected = 'selected="selected" '; + } else { + $selected = ''; } - ?> + + echo '<option '.$selected.'value="'.htmlspecialchars($orgId).'">'. + htmlspecialchars($orgDesc).'</option>'; + } + ?> </select></td> <td style="padding: .4em;"> <?php if ($this->data['rememberOrganizationEnabled']) { echo str_repeat("\t", 4); - echo '<input type="checkbox" id="remember_organization" tabindex="5" name="remember_organization" value="Yes" '; - echo ($this->data['rememberOrganizationChecked'] ? 'checked="Yes" /> ' : '/> '); - echo $this->t('{login:remember_organization}'); + echo '<input type="checkbox" id="remember_organization" tabindex="5"'. + ' name="remember_organization" value="Yes" '. + ($this->data['rememberOrganizationChecked'] ? 'checked="Yes" /> ' : '/> '). + $this->t('{login:remember_organization}'); } ?> </td> </tr> - <?php + <?php } ?> <tr id="submit"> @@ -168,7 +178,7 @@ if ($this->data['errorcode'] !== null) { <input type="hidden" id="processing_trans" value="<?php echo $this->t('{login:processing}'); ?>" /> <?php foreach ($this->data['stateparams'] as $name => $value) { - echo('<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'); + echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; } ?> </form> @@ -180,7 +190,7 @@ if (!empty($this->data['links'])) { } echo '</ul>'; } -echo('<h2 class="logintext">'.$this->t('{login:help_header}').'</h2>'); -echo('<p class="logintext">'.$this->t('{login:help_text}').'</p>'); +echo '<h2 class="logintext">'.$this->t('{login:help_header}').'</h2>'; +echo '<p class="logintext">'.$this->t('{login:help_text}').'</p>'; $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/core/templates/logout-iframe.php b/modules/core/templates/logout-iframe.php index 634ed122d..59e6ae770 100644 --- a/modules/core/templates/logout-iframe.php +++ b/modules/core/templates/logout-iframe.php @@ -71,8 +71,8 @@ if ($type === 'embed') { $this->includeAtTemplateBase('includes/header.php'); } ?> - <div id="wrap"> - <div id="content"> +<div id="wrap"> + <div id="content"> <?php if ($from !== null) { echo '<div><img style="float: left; margin-right: 12px" src="/'.$this->data['baseurlpath']. @@ -90,9 +90,9 @@ if ($type === 'init') { } else { echo $this->t('{logout:logging_out_from}'); } -echo('</p>'); ?> - <table id="slostatustable"> + </p> + <table id="slostatustable"> <?php foreach ($SPs as $assocId => $sp) { if (isset($sp['core:Logout-IFrame:Name'])) { @@ -123,24 +123,26 @@ if (isset($from)) { } ?> - </table> - </div> + </table> +</div> <?php if ($type === 'init') { ?> - <div id="confirmation" style="margin-top: 1em"> - <p><?php echo $this->t('{logout:logout_all_question}'); ?> <br/></p> - <form id="startform" method="get" style="display:inline;" action="logout-iframe.php"> - <input type="hidden" name="id" value="<?php echo $id; ?>"/> - <input type="hidden" id="logout-type-selector" name="type" value="nojs"/> - <button type="submit" id="logout-all" name="ok" class="btn"><?php echo $this->t('{logout:logout_all}'); ?></button> - </form> - <form method="get" style="display:inline;" action="logout-iframe-done.php"> - <input type="hidden" name="id" value="<?php echo $id; ?>"/> - <button type="submit" name="cancel" class="btn"><?php echo $logoutCancelText; ?></button> - </form> - </div> +<div id="confirmation" style="margin-top: 1em"> + <p><?php echo $this->t('{logout:logout_all_question}'); ?> <br/></p> + <form id="startform" method="get" style="display:inline;" action="logout-iframe.php"> + <input type="hidden" name="id" value="<?php echo $id; ?>"/> + <input type="hidden" id="logout-type-selector" name="type" value="nojs"/> + <button type="submit" id="logout-all" name="ok" class="btn"> + <?php echo $this->t('{logout:logout_all}'); ?> + </button> + </form> + <form method="get" style="display:inline;" action="logout-iframe-done.php"> + <input type="hidden" name="id" value="<?php echo $id; ?>"/> + <button type="submit" name="cancel" class="btn"><?php echo $logoutCancelText; ?></button> + </form> +</div> <?php } else { if ($nFailed > 0) { @@ -150,7 +152,8 @@ if ($type === 'init') { } echo '<div id="logout-failed-message" style="margin-top: 1em; border: 1px solid #ccc; padding: 1em; '. 'background: #eaeaea;'.$displayStyle.'">'; - echo '<img src="/'.$this->data['baseurlpath'].'resources/icons/experience/gtk-dialog-warning.48x48.png" alt="" '. + echo '<img src="/'.$this->data['baseurlpath']. + 'resources/icons/experience/gtk-dialog-warning.48x48.png" alt="" '. 'style="float: left; margin-right: 5px;" />'; echo '<p>'.$this->t('{logout:failedsps}').'</p>'; echo '<form method="post" action="logout-iframe-done.php" id="failed-form" target="_top">'; @@ -166,11 +169,11 @@ if ($type === 'init') { } echo '<p>'.$this->t('{logout:success}').'</p>'; ?> - <form method="post" action="logout-iframe-done.php" id="done-form" target="_top"> - <input type="hidden" name="id" value="<?php echo $id; ?>"/> - <button type="submit" name="continue" class="btn"><?php echo $this->t('{logout:return}'); ?></button> - </form> - </div> + <form method="post" action="logout-iframe-done.php" id="done-form" target="_top"> + <input type="hidden" name="id" value="<?php echo $id; ?>"/> + <button type="submit" name="continue" class="btn"><?php echo $this->t('{logout:return}'); ?></button> + </form> +</div> <?php if ($type === 'js') { foreach ($SPs as $assocId => $sp) { @@ -185,8 +188,8 @@ if ($type === 'init') { } } ?> - </div><!-- #content --> - </div><!-- #wrap --> + </div><!-- #content --> + </div><!-- #wrap --> <?php if ($type === 'embed') { $this->includeAtTemplateBase('includes/footer-embed.php'); diff --git a/modules/core/templates/no_metadata.tpl.php b/modules/core/templates/no_metadata.tpl.php index d3b638b22..a00f3ce91 100644 --- a/modules/core/templates/no_metadata.tpl.php +++ b/modules/core/templates/no_metadata.tpl.php @@ -1,9 +1,8 @@ <?php -echo('<p>' . $this->t('{core:no_metadata:config_problem}') . '</p>'); - -echo('<ul>'); -echo('<li>' . $this->t('{core:no_metadata:suggestion_user_link}') . '</li>'); -echo('<li>' . $this->t('{core:no_metadata:suggestion_developer}') . '</li>'); -echo('</ul>'); +echo '<p>'.$this->t('{core:no_metadata:config_problem}').'</p>'; +echo '<ul>'; +echo '<li>'.$this->t('{core:no_metadata:suggestion_user_link}').'</li>'; +echo '<li>'.$this->t('{core:no_metadata:suggestion_developer}').'</li>'; +echo '</ul>'; diff --git a/modules/core/templates/no_state.tpl.php b/modules/core/templates/no_state.tpl.php index f86e346e0..01ea6db78 100644 --- a/modules/core/templates/no_state.tpl.php +++ b/modules/core/templates/no_state.tpl.php @@ -1,15 +1,14 @@ <?php -echo('<h3>' . $this->t('{core:no_state:suggestions}') . '</h3>'); -echo('<ul>'); -echo('<li>' . $this->t('{core:no_state:suggestion_goback}') . '</li>'); -echo('<li>' . $this->t('{core:no_state:suggestion_closebrowser}') . '</li>'); -echo('</ul>'); - -echo('<h3>' . $this->t('{core:no_state:causes}') . '</h3>'); -echo('<ul>'); -echo('<li>' . $this->t('{core:no_state:cause_backforward}') . '</li>'); -echo('<li>' . $this->t('{core:no_state:cause_openbrowser}') . '</li>'); -echo('<li>' . $this->t('{core:no_state:cause_nocookie}') . '</li>'); -echo('</ul>'); +echo '<h3>'.$this->t('{core:no_state:suggestions}').'</h3>'; +echo '<ul>'; +echo '<li>'.$this->t('{core:no_state:suggestion_goback}').'</li>'; +echo '<li>'.$this->t('{core:no_state:suggestion_closebrowser}').'</li>'; +echo '</ul>'; +echo '<h3>'.$this->t('{core:no_state:causes}').'</h3>'; +echo '<ul>'; +echo '<li>'.$this->t('{core:no_state:cause_backforward}').'</li>'; +echo '<li>'.$this->t('{core:no_state:cause_openbrowser}').'</li>'; +echo '<li>'.$this->t('{core:no_state:cause_nocookie}').'</li>'; +echo '</ul>'; diff --git a/modules/core/templates/short_sso_interval.php b/modules/core/templates/short_sso_interval.php index ac334a6c0..2e305c2b9 100644 --- a/modules/core/templates/short_sso_interval.php +++ b/modules/core/templates/short_sso_interval.php @@ -14,15 +14,17 @@ $this->data['header'] = $this->t('{core:short_sso_interval:warning_header}'); $this->data['autofocus'] = 'contbutton'; $this->includeAtTemplateBase('includes/header.php'); +$target = htmlspecialchars($this->data['target']); +$contButton = htmlspecialchars($this->t('{core:short_sso_interval:retry}')); ?> <h1><?php echo $this->data['header']; ?></h1> -<form style="display: inline; margin: 0px; padding: 0px" action="<?php echo htmlspecialchars($this->data['target']); ?>"> +<form style="display: inline; margin: 0px; padding: 0px" action="<?php echo $target; ?>"> <?php - // Embed hidden fields... - foreach ($this->data['params'] as $name => $value) { - echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; - } +// Embed hidden fields... +foreach ($this->data['params'] as $name => $value) { + echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; +} ?> <p><?php echo $this->t('{core:short_sso_interval:warning}'); ?></p> <div class="trackidtext"><p> @@ -31,7 +33,7 @@ $this->includeAtTemplateBase('includes/header.php'); </p> </div> - <input type="submit" name="continue" id="contbutton" value="<?php echo htmlspecialchars($this->t('{core:short_sso_interval:retry}')) ?>" /> + <input type="submit" name="continue" id="contbutton" value="<?php echo $contButton; ?>" /> </form> diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php index c73a4fee6..9c14a8215 100644 --- a/modules/core/www/cardinality_error.php +++ b/modules/core/www/cardinality_error.php @@ -20,7 +20,10 @@ $globalConfig = \SimpleSAML\Configuration::getInstance(); $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:cardinality_error.tpl.php'); $t->data['cardinalityErrorAttributes'] = $state['core:cardinality:errorAttributes']; if (isset($state['Source']['auth'])) { - $t->data['LogoutURL'] = \SimpleSAML\Module::getModuleURL('core/authenticate.php', array('as' => $state['Source']['auth']))."&logout"; + $t->data['LogoutURL'] = \SimpleSAML\Module::getModuleURL( + 'core/authenticate.php', + array('as' => $state['Source']['auth']) + )."&logout"; } header('HTTP/1.0 403 Forbidden'); $t->show(); diff --git a/modules/core/www/cleardiscochoices.php b/modules/core/www/cleardiscochoices.php index 8d134f7d7..afc794a0e 100644 --- a/modules/core/www/cleardiscochoices.php +++ b/modules/core/www/cleardiscochoices.php @@ -33,4 +33,3 @@ if (array_key_exists('ReturnTo', $_REQUEST)) { // Redirect to destination. \SimpleSAML\Utils\HTTP::redirectTrustedURL($returnTo); - diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php index 0c9fb0787..3a89257de 100644 --- a/modules/core/www/frontpage_auth.php +++ b/modules/core/www/frontpage_auth.php @@ -44,5 +44,3 @@ $t->data['links_auth'] = $links_auth; $t->data['links_federation'] = $links_federation; $t->show(); - - diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php index 26d388b8b..9f41db7c7 100644 --- a/modules/core/www/frontpage_config.php +++ b/modules/core/www/frontpage_config.php @@ -102,7 +102,7 @@ $functionchecks = array( 'json_decode' => array('required', 'JSON support'), 'class_implements' => array('required', 'Standard PHP Library (SPL)'), 'mb_strlen' => array('required', 'Multibyte String Extension'), - 'curl_init' => array('optional', 'cURL (required if automatic version checks are used, also by some modules.'), + 'curl_init' => array('optional', 'cURL (required if automatic version checks are used, also by some modules.'), 'session_start' => array('optional', 'Session Extension (required if PHP sessions are used)'), 'pdo_drivers' => array('optional', 'PDO Extension (required if a database backend is used)'), ); @@ -115,7 +115,7 @@ if (\SimpleSAML\Module::isModuleEnabled('radius')) { $funcmatrix = array(); $funcmatrix[] = array( - 'required' => 'required', + 'required' => 'required', 'descr' => 'PHP Version >= 5.4. You run: '.phpversion(), 'enabled' => version_compare(phpversion(), '5.4', '>=') ); @@ -135,7 +135,7 @@ $funcmatrix[] = array( 'enabled' => class_exists('Memcache') || class_exists('Memcached'), ); -/* Some basic configuration checks */ +// Some basic configuration checks if ($config->getString('technicalcontact_email', 'na@example.org') === 'na@example.org') { $mail_ok = false; diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php index ec0132ac8..d3d946fa3 100644 --- a/modules/core/www/frontpage_federation.php +++ b/modules/core/www/frontpage_federation.php @@ -169,4 +169,3 @@ $t->data['metaentries'] = $metaentries; $t->data['mtype'] = $mtype; $t->show(); - diff --git a/modules/core/www/idp/logout-iframe.js b/modules/core/www/idp/logout-iframe.js index 6fc401070..921c23cdf 100644 --- a/modules/core/www/idp/logout-iframe.js +++ b/modules/core/www/idp/logout-iframe.js @@ -1,8 +1,8 @@ /** * This function updates the global logout status. */ -function updateStatus() { - +function updateStatus() +{ var nFailed = 0; var nProgress = 0; for (sp in window.spStatus) { @@ -33,7 +33,8 @@ function updateStatus() { * @param status The new status. * @param reason The reason for the status change. */ -function updateSPStatus(spId, status, reason) { +function updateSPStatus(spId, status, reason) +{ if (window.spStatus[spId] === status) { // unchanged return; @@ -63,7 +64,8 @@ function updateSPStatus(spId, status, reason) { * * @param spId The SP that completed logout successfully. */ -function logoutCompleted(spId) { +function logoutCompleted(spId) +{ updateSPStatus(spId, 'completed', ''); } @@ -75,7 +77,8 @@ function logoutCompleted(spId) { * @param spId The SP that failed to complete logout. * @param reason The reason why logout failed. */ -function logoutFailed(spId, reason) { +function logoutFailed(spId, reason) +{ updateSPStatus(spId, 'failed', reason); } @@ -84,7 +87,8 @@ function logoutFailed(spId, reason) { * * If an SP didn't reply by the timeout, we'll mark it as failed. */ -function timeoutSPs() { +function timeoutSPs() +{ var cTime = ((new Date()).getTime() - window.startTime) / 1000; for (var sp in window.spStatus) { if (window.spTimeout[sp] <= cTime && window.spStatus[sp] === 'inprogress') { diff --git a/modules/core/www/login-admin.php b/modules/core/www/login-admin.php index 01ea86c93..59246f673 100644 --- a/modules/core/www/login-admin.php +++ b/modules/core/www/login-admin.php @@ -10,4 +10,3 @@ if (!array_key_exists('ReturnTo', $_REQUEST)) { \SimpleSAML\Utils\Auth::requireAdmin(); \SimpleSAML\Utils\HTTP::redirectUntrustedURL($_REQUEST['ReturnTo']); - diff --git a/modules/core/www/loginuserpass.php b/modules/core/www/loginuserpass.php index f5211bb7f..c9569dede 100644 --- a/modules/core/www/loginuserpass.php +++ b/modules/core/www/loginuserpass.php @@ -18,7 +18,9 @@ $state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\core $source = \SimpleSAML\Auth\Source::getById($state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]); if ($source === null) { - throw new \Exception('Could not find authentication source with id '.$state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID]); + throw new \Exception( + 'Could not find authentication source with id '.$state[\SimpleSAML\Module\core\Auth\UserPassBase::AUTHID] + ); } @@ -58,15 +60,22 @@ if (!empty($_REQUEST['username']) || !empty($password)) { if ($source->getRememberUsernameEnabled()) { $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler(); $params = $sessionHandler->getCookieParams(); - $params['expire'] = time(); - $params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300); + + if (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes') { + $params['expire'] = time() + 31536000; + } else { + $params['expire'] = time() - 300; + } \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId().'-username', $username, $params, false); } if ($source->isRememberMeEnabled()) { if (array_key_exists('remember_me', $_REQUEST) && $_REQUEST['remember_me'] === 'Yes') { $state['RememberMe'] = true; - $authStateId = \SimpleSAML\Auth\State::saveState($state, \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID); + $authStateId = \SimpleSAML\Auth\State::saveState( + $state, + \SimpleSAML\Module\core\Auth\UserPassBase::STAGEID + ); } } diff --git a/modules/core/www/loginuserpassorg.php b/modules/core/www/loginuserpassorg.php index 4b293e2dc..3b480699b 100644 --- a/modules/core/www/loginuserpassorg.php +++ b/modules/core/www/loginuserpassorg.php @@ -18,7 +18,9 @@ $state = \SimpleSAML\Auth\State::loadState($authStateId, \SimpleSAML\Module\core $source = \SimpleSAML\Auth\Source::getById($state[\SimpleSAML\Module\core\Auth\UserPassOrgBase::AUTHID]); if ($source === null) { - throw new \Exception('Could not find authentication source with id '.$state[\SimpleSAML\Module\core\Auth\UserPassOrgBase::AUTHID]); + throw new \Exception( + 'Could not find authentication source with id '.$state[\SimpleSAML\Module\core\Auth\UserPassOrgBase::AUTHID] + ); } $organizations = \SimpleSAML\Module\core\Auth\UserPassOrgBase::listOrganizations($authStateId); @@ -41,7 +43,9 @@ if (array_key_exists('password', $_REQUEST)) { if (array_key_exists('organization', $_REQUEST)) { $organization = $_REQUEST['organization']; -} elseif ($source->getRememberOrganizationEnabled() && array_key_exists($source->getAuthId().'-organization', $_COOKIE)) { +} elseif ($source->getRememberOrganizationEnabled() && + array_key_exists($source->getAuthId().'-organization', $_COOKIE) + ) { $organization = $_COOKIE[$source->getAuthId().'-organization']; } elseif (isset($state['core:organization'])) { $organization = (string) $state['core:organization']; @@ -61,25 +65,44 @@ if (isset($state['error'])) { if ($organizations === null || !empty($organization)) { if (!empty($username) || !empty($password)) { - if ($source->getRememberUsernameEnabled()) { $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler(); $params = $sessionHandler->getCookieParams(); - $params['expire'] = time(); - $params['expire'] += (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes' ? 31536000 : -300); + if (isset($_REQUEST['remember_username']) && $_REQUEST['remember_username'] == 'Yes') { + $params['expire'] = time() + 3153600; + } else { + $params['expire'] = time() - 300; + } + \SimpleSAML\Utils\HTTP::setCookie($source->getAuthId().'-username', $username, $params, false); } if ($source->getRememberOrganizationEnabled()) { $sessionHandler = \SimpleSAML\SessionHandler::getSessionHandler(); $params = $sessionHandler->getCookieParams(); - $params['expire'] = time(); - $params['expire'] += (isset($_REQUEST['remember_organization']) && $_REQUEST['remember_organization'] == 'Yes' ? 31536000 : -300); - setcookie($source->getAuthId().'-organization', $organization, $params['expire'], $params['path'], $params['domain'], $params['secure'], $params['httponly']); + if (isset($_REQUEST['remember_organization']) && $_REQUEST['remember_organization'] == 'Yes') { + $params['expire'] = time() + 3153600; + } else { + $params['expire'] = time() - 300; + } + setcookie( + $source->getAuthId().'-organization', + $organization, + $params['expire'], + $params['path'], + $params['domain'], + $params['secure'], + $params['httponly'] + ); } try { - \SimpleSAML\Module\core\Auth\UserPassOrgBase::handleLogin($authStateId, $username, $password, $organization); + \SimpleSAML\Module\core\Auth\UserPassOrgBase::handleLogin( + $authStateId, + $username, + $password, + $organization + ); } catch (\SimpleSAML\Error\Error $e) { // Login failed. Extract error code and parameters, to display the error $errorCode = $e->getErrorCode(); @@ -88,7 +111,10 @@ if ($organizations === null || !empty($organization)) { 'code' => $errorCode, 'params' => $errorParams ); - $authStateId = \SimpleSAML\Auth\State::saveState($state, \SimpleSAML\Module\core\Auth\UserPassOrgBase::STAGEID); + $authStateId = \SimpleSAML\Auth\State::saveState( + $state, + \SimpleSAML\Module\core\Auth\UserPassOrgBase::STAGEID + ); $queryParams = array('AuthState' => $authStateId); } if (isset($state['error'])) { @@ -135,4 +161,3 @@ if (isset($state['SPMetadata'])) { $t->show(); exit(); - diff --git a/modules/cron/config-templates/module_cron.php b/modules/cron/config-templates/module_cron.php index abee18711..fe303c9b8 100644 --- a/modules/cron/config-templates/module_cron.php +++ b/modules/cron/config-templates/module_cron.php @@ -1,5 +1,5 @@ <?php -/* +/* * Configuration for the Cron module. */ diff --git a/modules/cron/templates/croninfo-result.php b/modules/cron/templates/croninfo-result.php index fecd11cdb..8cecb5834 100644 --- a/modules/cron/templates/croninfo-result.php +++ b/modules/cron/templates/croninfo-result.php @@ -12,8 +12,7 @@ echo ' <h1>'.$this->t('cron_report_title').'</h1><p>'.$this->t('ran_t '<p>Tag: '.$this->data['tag']."</p>\n\n". '<ul><li>'.join('</li><li>', $this->data['summary']).'</li></ul>'; ?> - </code> - </pre> + </code></pre> </div> <?php diff --git a/modules/cron/templates/croninfo.tpl.php b/modules/cron/templates/croninfo.tpl.php index f6181f6cf..50efe15a1 100644 --- a/modules/cron/templates/croninfo.tpl.php +++ b/modules/cron/templates/croninfo.tpl.php @@ -11,7 +11,7 @@ $run_text = $this->t('run_text'); <p><?php echo $this->t('cron_suggestion') ?></p> <pre style="font-size: x-small; color: #444; padding: 1em; border: 1px solid #eee; margin: .4em "><code> <?php -foreach ($this->data['urls'] as $url ) { +foreach ($this->data['urls'] as $url) { echo "# ".$run_text. ' ['.$url['tag'].']'."\n"; echo $url['int']." curl --silent \"".$url['href']."\" > /dev/null 2>&1\n"; } @@ -22,7 +22,7 @@ foreach ($this->data['urls'] as $url ) { <p><?php echo $this->t('cron_execution') ?></p> <ul> <?php -foreach ($this->data['urls'] as $url ) { +foreach ($this->data['urls'] as $url) { echo ' <li><a href="'.$url['href'].'&output=xhtml">'.$run_text.' ['.$url['tag'].']'.'</a></li>'; } ?> diff --git a/modules/discopower/config-templates/module_discopower.php b/modules/discopower/config-templates/module_discopower.php index 4579f9d10..dfac25817 100644 --- a/modules/discopower/config-templates/module_discopower.php +++ b/modules/discopower/config-templates/module_discopower.php @@ -1,5 +1,5 @@ <?php -/* +/* * Configuration for the DiscoPower module. */ @@ -21,9 +21,9 @@ $config = array( /* * If you want to change the scoring algorithm to a more google suggest like one - * (filters by start of words) uncomment this ... + * (filters by start of words) uncomment this ... * - * 'score' => 'suggest', + * 'score' => 'suggest', */ /* diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index 52ded4331..4e7a39149 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -219,7 +219,6 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco if (array_key_exists('entities.include', $spmd['discopower.filter']) || array_key_exists('tags.include', $spmd['discopower.filter']) ) { - $defaultrule = false; } @@ -326,7 +325,7 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco $translation = $t->getTranslator()->getPreferredTranslation($displayName); } } - + if (($translation === false) && array_key_exists('name', $entity)) { if (is_array($entity['name'])) { $translation = $t->getTranslator()->getPreferredTranslation($entity['name']); @@ -342,14 +341,17 @@ class PowerIdPDisco extends \SimpleSAML\XHTML\IdPDisco // HTML output if ($entity['entityid'] === $favourite) { - $html = '<a class="metaentry favourite" href="'.$basequerystring.urlencode($entity['entityid']).'">'; + $html = '<a class="metaentry favourite" href="'. + $basequerystring.urlencode($entity['entityid']).'">'; } else { - $html = '<a class="metaentry" href="'.$basequerystring.urlencode($entity['entityid']).'">'; + $html = '<a class="metaentry" href="'. + $basequerystring.urlencode($entity['entityid']).'">'; } $html .= $entity['translated']; if (array_key_exists('icon', $entity) && $entity['icon'] !== null) { $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($entity['icon']); - $html .= '<img alt="Icon for identity provider" class="entryicon" src="'.htmlspecialchars($iconUrl).'" />'; + $html .= '<img alt="Icon for identity provider" class="entryicon" src="'. + htmlspecialchars($iconUrl).'" />'; } $html .= '</a>'; $entity['html'] = $html; diff --git a/modules/discopower/templates/disco.tpl.php b/modules/discopower/templates/disco.tpl.php index 035a1b990..72cad5298 100644 --- a/modules/discopower/templates/disco.tpl.php +++ b/modules/discopower/templates/disco.tpl.php @@ -1,172 +1,141 @@ <?php $this->data['header'] = $this->t('selectidp'); -$this->data['jquery'] = array('core' => TRUE, 'ui' => TRUE, 'css' => TRUE); +$this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); -$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . SimpleSAML\Module::getModuleUrl('discopower/assets/css/style.css') . '" />'; +$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="'. + SimpleSAML\Module::getModuleUrl('discopower/assets/css/style.css').'" />'; -$this->data['post'] = '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/assets/js/jquery.livesearch.js') . '"></script>'; -$this->data['post'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/assets/js/quicksilver.js') . '"></script>'; +$this->data['post'] = '<script type="text/javascript" src="'. + SimpleSAML\Module::getModuleUrl('discopower/assets/js/jquery.livesearch.js').'"></script>'; +$this->data['post'] .= '<script type="text/javascript" src="'. + SimpleSAML\Module::getModuleUrl('discopower/assets/js/quicksilver.js').'"></script>'; - - - -if (!empty($this->data['faventry'])) $this->data['autofocus'] = 'favouritesubmit'; - -$this->includeAtTemplateBase('includes/header.php'); - -function showEntry($t, $metadata, $favourite = FALSE) { - - $basequerystring = '?' . - 'entityID=' . urlencode($t->data['entityID']) . '&' . - 'return=' . urlencode($t->data['return']) . '&' . - 'returnIDParam=' . urlencode($t->data['returnIDParam']) . '&idpentityid='; - - $extra = ($favourite ? ' favourite' : ''); - $html = '<a class="metaentry' . $extra . '" href="' . $basequerystring . urlencode($metadata['entityid']) . '">'; - - $html .= '' . htmlspecialchars(getTranslatedName($t, $metadata)) . ''; - - if(array_key_exists('icon', $metadata) && $metadata['icon'] !== NULL) { - $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($metadata['icon']); - $html .= '<img alt="Icon for identity provider" class="entryicon" src="' . htmlspecialchars($iconUrl) . '" />'; - } - - $html .= '</a>'; - - return $html; +if (!empty($this->data['faventry'])) { + $this->data['autofocus'] = 'favouritesubmit'; } -?> +$this->includeAtTemplateBase('includes/header.php'); +function showEntry($t, $metadata, $favourite = false) +{ + $basequerystring = '?'. + 'entityID='.urlencode($t->data['entityID']).'&'. + 'return='.urlencode($t->data['return']).'&'. + 'returnIDParam='.urlencode($t->data['returnIDParam']).'&idpentityid='; + $extra = ($favourite ? ' favourite' : ''); + $html = '<a class="metaentry'.$extra.'" href="'.$basequerystring.urlencode($metadata['entityid']).'">'; + $html .= htmlspecialchars(getTranslatedName($t, $metadata)).''; -<?php + if (array_key_exists('icon', $metadata) && $metadata['icon'] !== null) { + $iconUrl = \SimpleSAML\Utils\HTTP::resolveURL($metadata['icon']); + $html .= '<img alt="Icon for identity provider" class="entryicon" src="'.htmlspecialchars($iconUrl).'" />'; + } -function getTranslatedName($t, $metadata) { - if (isset($metadata['UIInfo']['DisplayName'])) { - $displayName = $metadata['UIInfo']['DisplayName']; - assert(is_array($displayName)); // Should always be an array of language code -> translation - if (!empty($displayName)) { - return $t->getTranslator()->getPreferredTranslation($displayName); - } - } - - if (array_key_exists('name', $metadata)) { - if (is_array($metadata['name'])) { - return $t->getTranslator()->getPreferredTranslation($metadata['name']); - } else { - return $metadata['name']; - } - } - return $metadata['entityid']; + $html .= '</a>'; + return $html; } - - +function getTranslatedName($t, $metadata) +{ + if (isset($metadata['UIInfo']['DisplayName'])) { + $displayName = $metadata['UIInfo']['DisplayName']; + assert(is_array($displayName)); // Should always be an array of language code -> translation + if (!empty($displayName)) { + return $t->getTranslator()->getPreferredTranslation($displayName); + } + } + + if (array_key_exists('name', $metadata)) { + if (is_array($metadata['name'])) { + return $t->getTranslator()->getPreferredTranslation($metadata['name']); + } else { + return $metadata['name']; + } + } + return $metadata['entityid']; +} if (!empty($this->data['faventry'])) { - - - echo('<div class="favourite">'); - echo($this->t('previous_auth')); - echo(' <strong>' . htmlspecialchars(getTranslatedName($this, $this->data['faventry'])) . '</strong>'); - echo(' - <form id="idpselectform" method="get" action="' . $this->data['urlpattern'] . '"> - <input type="hidden" name="entityID" value="' . htmlspecialchars($this->data['entityID']) . '" /> - <input type="hidden" name="return" value="' . htmlspecialchars($this->data['return']) . '" /> - <input type="hidden" name="returnIDParam" value="' . htmlspecialchars($this->data['returnIDParam']) . '" /> - <input type="hidden" name="idpentityid" value="' . htmlspecialchars($this->data['faventry']['entityid']) . '" /> - - <input type="submit" name="formsubmit" id="favouritesubmit" value="' . $this->t('login_at') . ' ' . htmlspecialchars(getTranslatedName($this, $this->data['faventry'])) . '" /> - </form>'); - - echo('</div>'); + echo '<div class="favourite">' ; + echo $this->t('previous_auth'); + echo ' <strong>'.htmlspecialchars(getTranslatedName($this, $this->data['faventry'])).'</strong>'; + echo '<form id="idpselectform" method="get" action="'.$this->data['urlpattern']. + '"><input type="hidden" name="entityID" value="'.htmlspecialchars($this->data['entityID']). + '" /><input type="hidden" name="return" value="'.htmlspecialchars($this->data['return']). + '" /><input type="hidden" name="returnIDParam" value="'.htmlspecialchars($this->data['returnIDParam']). + '" /><input type="hidden" name="idpentityid" value="'.htmlspecialchars($this->data['faventry']['entityid']). + '" /><input type="submit" name="formsubmit" id="favouritesubmit" value="'.$this->t('login_at').' '. + htmlspecialchars(getTranslatedName($this, $this->data['faventry'])).'" /></form>'; + echo '</div>'; } - - ?> - - - - - <div id="tabdiv"> - <ul class="tabset_tabs"> - <?php - - $tabs = array_keys( $this->data['idplist']); - $i = 1; - foreach ($tabs AS $tab) { - if(!empty($this->data['idplist'][$tab])) { - if ($i === 1) { - echo '<li class="tab-link current" data-tab="'.$tab.'"><a href="#' . $tab . '"><span>' . $this->t($this->data['tabNames'][$tab]) . '</span></a></li>'; - } else { - echo '<li class="tab-link" data-tab="'.$tab.'"><a href="#' . $tab . '"><span>' . $this->t($this->data['tabNames'][$tab]) . '</span></a></li> '; - } - $i++; - } - } - - ?> + <?php + $tabs = array_keys($this->data['idplist']); + $i = 1; + foreach ($tabs as $tab) { + if (!empty($this->data['idplist'][$tab])) { + if ($i === 1) { + echo '<li class="tab-link current" data-tab="'.$tab.'"><a href="#'.$tab. + '"><span>'.$this->t($this->data['tabNames'][$tab]).'</span></a></li>'; + } else { + echo '<li class="tab-link" data-tab="'.$tab.'"><a href="#'.$tab. + '"><span>'.$this->t($this->data['tabNames'][$tab]).'</span></a></li> '; + } + $i++; + } + } + ?> </ul> - <?php - - - -foreach( $this->data['idplist'] AS $tab => $slist) { - $first = array_keys($this->data['idplist']); - if ($first[0] === $tab) { - echo '<div id="' . $tab . '" class="tabset_content current">'; - } else { - echo '<div id="' . $tab . '" class="tabset_content">'; - } - if (!empty($slist)) { - - echo(' <div class="inlinesearch">'); - echo(' <p>Incremental search...</p>'); - echo(' <form id="idpselectform" action="?" method="get"><input class="inlinesearch" type="text" value="" name="query_' . $tab . '" id="query_' . $tab . '" /></form>'); - echo(' </div>'); - - echo(' <div class="metalist" id="list_' . $tab . '">'); - if (!empty($this->data['preferredidp']) && array_key_exists($this->data['preferredidp'], $slist)) { - $idpentry = $slist[$this->data['preferredidp']]; - echo (showEntry($this, $idpentry, TRUE)); - } - - foreach ($slist AS $idpentry) { - if ($idpentry['entityid'] != $this->data['preferredidp']) { - echo (showEntry($this, $idpentry)); - } - } - echo(' </div>'); - } - echo '</div>'; - +foreach ($this->data['idplist'] as $tab => $slist) { + $first = array_keys($this->data['idplist']); + if ($first[0] === $tab) { + echo '<div id="'.$tab.'" class="tabset_content current">'; + } else { + echo '<div id="'.$tab.'" class="tabset_content">'; + } + if (!empty($slist)) { + echo '<div class="inlinesearch">'; + echo '<p>Incremental search...</p>'; + echo '<form id="idpselectform" action="?" method="get">'; + echo '<input class="inlinesearch" type="text" value="" name="query_'.$tab.'" id="query_'.$tab.'" /></form>'; + echo '</div>'; + + echo '<div class="metalist" id="list_'.$tab .'">'; + if (!empty($this->data['preferredidp']) && array_key_exists($this->data['preferredidp'], $slist)) { + $idpentry = $slist[$this->data['preferredidp']]; + echo showEntry($this, $idpentry, true); + } + + foreach ($slist as $idpentry) { + if ($idpentry['entityid'] != $this->data['preferredidp']) { + echo showEntry($this, $idpentry); + } + } + echo '</div>'; + } + echo '</div>'; } - -?> - +?> </div> <script type="text/javascript"> -$(document).ready(function() { +$(document).ready(function () { <?php $i = 0; -foreach ($this->data['idplist'] AS $tab => $slist) { - echo "\n" . '$("#query_' . $tab . '").liveUpdate("#list_' . $tab . '")' . - (($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '') . - ';'; - - +foreach ($this->data['idplist'] as $tab => $slist) { + echo "\n".'$("#query_'.$tab.'").liveUpdate("#list_'.$tab.'")'. + (($i++ == 0) && (empty($this->data['faventry'])) ? '.focus()' : '').';'; } ?> }); @@ -174,5 +143,6 @@ foreach ($this->data['idplist'] AS $tab => $slist) { </script> <?php -$this->data['post'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/js/javascript.js') . '"></script>'; +$this->data['post'] .= '<script type="text/javascript" src="'. + SimpleSAML\Module::getModuleUrl('discopower/js/javascript.js').'"></script>'; $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/discopower/www/assets/css/disco.css b/modules/discopower/www/assets/css/disco.css index dddb03c22..c27079832 100644 --- a/modules/discopower/www/assets/css/disco.css +++ b/modules/discopower/www/assets/css/disco.css @@ -15,7 +15,7 @@ margin: 0px 2px 0px 0px; } .inlinesearch * { - margin: 0px; + margin: 0px; padding: 0px; } div.metalist { @@ -51,10 +51,10 @@ a.metaentry:hover img.entryicon { display: inline; top: 0px; bottom: 0px; - clear: both; - float: right; - margin: 1em; - padding: 3px; + clear: both; + float: right; + margin: 1em; + padding: 3px; border: 1px solid #999; } diff --git a/modules/discopower/www/assets/js/jquery.livesearch.js b/modules/discopower/www/assets/js/jquery.livesearch.js index 06c304373..2b125ff95 100644 --- a/modules/discopower/www/assets/js/jquery.livesearch.js +++ b/modules/discopower/www/assets/js/jquery.livesearch.js @@ -1,37 +1,43 @@ -jQuery.fn.liveUpdate = function(list){ - list = jQuery(list); +jQuery.fn.liveUpdate = function (list) { + list = jQuery(list); - if ( list.length ) { - var rows = list.children('a'), - cache = rows.map(function(){ - return jQuery(this).text().toLowerCase(); - }); - - this - .keyup(filter).keyup() - .parents('form').submit(function(){ - return false; - }); - } - - return this; - - function filter(){ - var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = []; - - if ( !term ) { - rows.show(); - } else { - rows.hide(); + if (list.length) { + var rows = list.children('a'), + cache = rows.map(function () { + return jQuery(this).text().toLowerCase(); + }); - cache.each(function(i){ - var score = this.score(term); - if (score > 0) { scores.push([score, i]); } - }); + this.keyup(filter).keyup().parents('form').submit(function () { + return false; + }); + } - jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){ - jQuery(rows[ this[1] ]).show(); - }); - } - } + return this; + + function filter() + { + var term = jQuery.trim(jQuery(this).val().toLowerCase()), scores = []; + + if (!term) { + rows.show(); + } else { + rows.hide(); + + cache.each(function (i) { + var score = this.score(term); + if (score > 0) { + scores.push([score, i]); + } + }); + + jQuery.each( + scores.sort(function (a, b) { + return b[0] - a[0]; + }), + function () { + jQuery(rows[ this[1] ]).show(); + } + ); + } + } }; diff --git a/modules/discopower/www/assets/js/quicksilver.js b/modules/discopower/www/assets/js/quicksilver.js index af29f732b..079ea87d5 100644 --- a/modules/discopower/www/assets/js/quicksilver.js +++ b/modules/discopower/www/assets/js/quicksilver.js @@ -1,7 +1,7 @@ // qs_score - Quicksilver Score -// +// // A port of the Quicksilver string ranking algorithm -// +// // "hello world".score("axl") //=> 0.0 // "hello world".score("ow") //=> 0.6 // "hello world".score("hello world") //=> 1.0 @@ -13,19 +13,19 @@ // http://blacktree-alchemy.googlecode.com/svn/trunk/Crucible/Code/NSString+BLTRRanking.m // // The MIT License -// +// // Copyright (c) 2008 Lachie Cox -// +// // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: -// +// // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -35,61 +35,68 @@ // THE SOFTWARE. -String.prototype.score = function(abbreviation,offset) { - offset = offset || 0 // TODO: I think this is unused... remove +String.prototype.score = function (abbreviation,offset) { + offset = offset || 0 // TODO: I think this is unused... remove - if(abbreviation.length == 0) return 0.9 - if(abbreviation.length > this.length) return 0.0 + if (abbreviation.length == 0) { + return 0.9 + } + if (abbreviation.length > this.length) { + return 0.0 + } - for (var i = abbreviation.length; i > 0; i--) { - var sub_abbreviation = abbreviation.substring(0,i) - var index = this.indexOf(sub_abbreviation) + for (var i = abbreviation.length; i > 0; i--) { + var sub_abbreviation = abbreviation.substring(0,i) + var index = this.indexOf(sub_abbreviation) - if(index < 0) continue; - if(index + abbreviation.length > this.length + offset) continue; + if (index < 0) { + continue; + } + if (index + abbreviation.length > this.length + offset) { + continue; + } - var next_string = this.substring(index+sub_abbreviation.length) - var next_abbreviation = null + var next_string = this.substring(index+sub_abbreviation.length) + var next_abbreviation = null - if(i >= abbreviation.length) - next_abbreviation = '' - else - next_abbreviation = abbreviation.substring(i) + if (i >= abbreviation.length) { + next_abbreviation = '' + } else { + next_abbreviation = abbreviation.substring(i) + } - var remaining_score = next_string.score(next_abbreviation,offset+index) + var remaining_score = next_string.score(next_abbreviation,offset + index) - if (remaining_score > 0) { - var score = this.length-next_string.length; - - if(index != 0) { - var j = 0; + if (remaining_score > 0) { + var score = this.length - next_string.length; - var c = this.charCodeAt(index-1) - if(c==32 || c == 9) { - for(var j=(index-2); j >= 0; j--) { - c = this.charCodeAt(j) - score -= ((c == 32 || c == 9) ? 1 : 0.15) - } - - // XXX maybe not port this heuristic - // - // } else if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:matchedRange.location]]) { - // for (j = matchedRange.location-1; j >= (int) searchRange.location; j--) { - // if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:j]]) - // score--; - // else - // score -= 0.15; - // } - } else { - score -= index - } - } + if (index != 0) { + var j = 0; + var c = this.charCodeAt(index - 1) + if ( c==32 || c == 9) { + for (var j=(index-2); j >= 0; j--) { + c = this.charCodeAt(j) + score -= ((c == 32 || c == 9) ? 1 : 0.15) + } + // XXX maybe not port this heuristic + // + // } else if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:matchedRange.location]]) { + // for (j = matchedRange.location-1; j >= (int) searchRange.location; j--) { + // if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember:[self characterAtIndex:j]]) + // score--; + // else + // score -= 0.15; + // } + } else { + score -= index + } + } - score += remaining_score * next_string.length - score /= this.length; - return score + score += remaining_score * next_string.length + score /= this.length; + return score + } } - } - return 0.0 -} \ No newline at end of file + return 0.0 +} diff --git a/modules/discopower/www/assets/js/suggest.js b/modules/discopower/www/assets/js/suggest.js index 667b35ac9..b404edd0a 100644 --- a/modules/discopower/www/assets/js/suggest.js +++ b/modules/discopower/www/assets/js/suggest.js @@ -1,23 +1,25 @@ var suggest_cache = new Array; -String.prototype.score = function(abbreviation,offset) { - if (suggest_cache['abv'] != abbreviation) { - suggest_cache['abv'] = abbreviation; - var words = abbreviation.split(/\s/); - suggest_cache['len'] = words.length; - suggest_cache.re = new Array; +String.prototype.score = function (abbreviation,offset) { + if (suggest_cache['abv'] != abbreviation) { + suggest_cache['abv'] = abbreviation; + var words = abbreviation.split(/\s/); + suggest_cache['len'] = words.length; + suggest_cache.re = new Array; - //words.each(); - for ( var i=0; i<suggest_cache['len']; ++i ){ - suggest_cache['re'][i] = new Array(); - // /\b<x>/ doesn't work when <x> i a non-ascii - oddly enough \s does ... - suggest_cache['re'][i]['initialword'] = new RegExp("^"+words[i], "i"); - suggest_cache['re'][i]['word'] = new RegExp("[\\s-()_]"+words[i], "i"); - } - } + //words.each(); + for (var i = 0; i < suggest_cache['len']; ++i) { + suggest_cache['re'][i] = new Array(); + // /\b<x>/ doesn't work when <x> i a non-ascii - oddly enough \s does ... + suggest_cache['re'][i]['initialword'] = new RegExp("^"+words[i], "i"); + suggest_cache['re'][i]['word'] = new RegExp("[\\s-()_]"+words[i], "i"); + } + } - for ( var i=0; i<suggest_cache['len']; ++i ){ - if (!(this.match(suggest_cache['re'][i]['initialword']) || this.match(suggest_cache['re'][i]['word']))) return 0; - } - return 1; + for (var i = 0; i < suggest_cache['len']; ++i) { + if (!(this.match(suggest_cache['re'][i]['initialword']) || this.match(suggest_cache['re'][i]['word']))) { + return 0; + } + } + return 1; } diff --git a/modules/discopower/www/disco.php b/modules/discopower/www/disco.php index 29d4343f6..963a9e17b 100644 --- a/modules/discopower/www/disco.php +++ b/modules/discopower/www/disco.php @@ -1,7 +1,10 @@ <?php try { - $discoHandler = new \SimpleSAML\Module\discopower\PowerIdPDisco(array('saml20-idp-remote', 'shib13-idp-remote'), 'poweridpdisco'); + $discoHandler = new \SimpleSAML\Module\discopower\PowerIdPDisco( + array('saml20-idp-remote', 'shib13-idp-remote'), + 'poweridpdisco' + ); } catch (\Exception $exception) { // An error here should be caused by invalid query parameters throw new \SimpleSAML\Error\Error('DISCOPARAMS', $exception); diff --git a/modules/exampleauth/lib/Auth/Source/UserPass.php b/modules/exampleauth/lib/Auth/Source/UserPass.php index f1d6fcb04..633125c15 100644 --- a/modules/exampleauth/lib/Auth/Source/UserPass.php +++ b/modules/exampleauth/lib/Auth/Source/UserPass.php @@ -39,12 +39,16 @@ class UserPass extends \SimpleSAML\Module\core\Auth\UserPassBase // Validate and parse our configuration foreach ($config as $userpass => $attributes) { if (!is_string($userpass)) { - throw new \Exception('Invalid <username>:<password> for authentication source '.$this->authId.': '.$userpass); + throw new \Exception( + 'Invalid <username>:<password> for authentication source '.$this->authId.': '.$userpass + ); } $userpass = explode(':', $userpass, 2); if (count($userpass) !== 2) { - throw new \Exception('Invalid <username>:<password> for authentication source '.$this->authId.': '.$userpass[0]); + throw new \Exception( + 'Invalid <username>:<password> for authentication source '.$this->authId.': '.$userpass[0] + ); } $username = $userpass[0]; $password = $userpass[1]; diff --git a/modules/exampleauth/www/authpage.php b/modules/exampleauth/www/authpage.php index f4fc5339d..e975d6986 100644 --- a/modules/exampleauth/www/authpage.php +++ b/modules/exampleauth/www/authpage.php @@ -96,7 +96,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { </head> <body> <h1>exampleauth login page</h1> -<p>In this example you can log in with two accounts: <code>student</code> and <code>admin</code>. In both cases, the password is the same as the username.</p> +<p> +In this example you can log in with two accounts: <code>student</code> and <code>admin</code>. +In both cases, the password is the same as the username. +</p> <?php if ($badUserPass) { ?> <p>Bad username or password.</p> <?php } ?> diff --git a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php index c41178c84..ca7d97308 100644 --- a/modules/expirycheck/lib/Auth/Process/ExpiryDate.php +++ b/modules/expirycheck/lib/Auth/Process/ExpiryDate.php @@ -52,14 +52,18 @@ class ExpiryDate extends \SimpleSAML\Auth\ProcessingFilter if (array_key_exists('netid_attr', $config)) { $this->netid_attr = $config['netid_attr']; if (!is_string($this->netid_attr)) { - throw new \Exception('Invalid attribute name given as eduPersonPrincipalName to expirycheck::ExpiryDate filter.'); + throw new \Exception( + 'Invalid attribute name given as eduPersonPrincipalName to expirycheck::ExpiryDate filter.' + ); } } if (array_key_exists('expirydate_attr', $config)) { $this->expirydate_attr = $config['expirydate_attr']; if (!is_string($this->expirydate_attr)) { - throw new \Exception('Invalid attribute name given as schacExpiryDate to expirycheck::ExpiryDate filter.'); + throw new \Exception( + 'Invalid attribute name given as schacExpiryDate to expirycheck::ExpiryDate filter.' + ); } } diff --git a/modules/expirycheck/templates/about2expire.php b/modules/expirycheck/templates/about2expire.php index b3c538b2c..6b135f807 100644 --- a/modules/expirycheck/templates/about2expire.php +++ b/modules/expirycheck/templates/about2expire.php @@ -17,24 +17,21 @@ */ $this->data['autofocus'] = 'yesbutton'; - $this->includeAtTemplateBase('includes/header.php'); -?> - -<form style="display: inline; margin: 0px; padding: 0px" action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>"> +$yesTarget = htmlspecialchars($this->data['yesTarget']); +$buttonContinue = htmlspecialchars($this->t('{expirycheck:expwarning:btn_continue}')); - <?php - // Embed hidden fields... - foreach ($this->data['yesData'] as $name => $value) { - echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; - } - ?> - <h3><?php echo $warning; ?></h3> - <p><?php echo $this->t('{expirycheck:expwarning:expiry_date_text}')." ".$this->data['expireOnDate']; ?></p> - - <input type="submit" name="yes" id="yesbutton" value="<?php echo htmlspecialchars($this->t('{expirycheck:expwarning:btn_continue}')) ?>" /> +echo '<form style="display: inline; margin: 0px; padding: 0px" action="'.$yesTarget.'">'; +// Embed hidden fields... +foreach ($this->data['yesData'] as $name => $value) { + echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; +} +?> +<h3><?php echo $warning; ?></h3> +<p><?php echo $this->t('{expirycheck:expwarning:expiry_date_text}')." ".$this->data['expireOnDate']; ?></p> +<input type="submit" name="yes" id="yesbutton" value="<?php echo $buttonContinue; ?>" /> </form> <?php diff --git a/modules/expirycheck/templates/expired.php b/modules/expirycheck/templates/expired.php index dc4f54718..ee1e73bda 100644 --- a/modules/expirycheck/templates/expired.php +++ b/modules/expirycheck/templates/expired.php @@ -3,8 +3,18 @@ $this->data['header'] = $this->t('{expirycheck:expwarning:access_denied}'); $this->includeAtTemplateBase('includes/header.php'); ?> <h2><?php echo $this->t('{expirycheck:expwarning:access_denied}'); ?></h2> - <p><?php echo $this->t('{expirycheck:expwarning:no_access_to}', array('%NETID%' => htmlspecialchars($this->data['netId']))); ?></p> - <p><?php echo $this->t('{expirycheck:expwarning:expiry_date_text}'); ?> <b><?php echo htmlspecialchars($this->data['expireOnDate']); ?></b></p> + <p> + <?php + echo $this->t( + '{expirycheck:expwarning:no_access_to}', + array('%NETID%' => htmlspecialchars($this->data['netId'])) + ); + ?> + </p> + <p> + <?php echo $this->t('{expirycheck:expwarning:expiry_date_text}'); ?> + <b><?php echo htmlspecialchars($this->data['expireOnDate']); ?></b> + </p> <p><?php echo $this->t('{expirycheck:expwarning:contact_home}'); ?></p> <?php $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php index 20ebfd330..76d78fba8 100644 --- a/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php +++ b/modules/ldap/lib/Auth/Process/AttributeAddUsersGroups.php @@ -105,7 +105,8 @@ class AttributeAddUsersGroups extends BaseFilter if (!isset($attributes[$map['memberof']])) { throw new \SimpleSAML\Error\Exception( $this->title.'The memberof attribute ['.$map['memberof']. - '] is not defined in the user\'s Attributes: '.implode(', ', array_keys($attributes))); + '] is not defined in the user\'s Attributes: '.implode(', ', array_keys($attributes)) + ); } // MemberOf must be an array of group DN's @@ -156,8 +157,14 @@ class AttributeAddUsersGroups extends BaseFilter $groups = array(); try { - // Intention is to filter in 'ou=groups,dc=example,dc=com' for '(memberUid = <value of attribute.username>)' and take only the attributes 'cn' (=name of the group) - $all_groups = $this->getLdap()->searchformultiple($openldap_base, array($map['memberof'] => $attributes[$map['username']][0]), array($map['member'])); + /* Intention is to filter in 'ou=groups,dc=example,dc=com' for + * '(memberUid = <value of attribute.username>)' and take only the attributes 'cn' (=name of the group) + */ + $all_groups = $this->getLdap()->searchformultiple( + $openldap_base, + array($map['memberof'] => $attributes[$map['username']][0]), + array($map['member']) + ); } catch (\SimpleSAML\Error\UserNotFound $e) { return $groups; // if no groups found return with empty (still just initialized) groups array } @@ -194,7 +201,8 @@ class AttributeAddUsersGroups extends BaseFilter if (!isset($attributes[$map['dn']])) { throw new \SimpleSAML\Error\Exception( $this->title.'The DN attribute ['.$map['dn']. - '] is not defined in the user\'s Attributes: '.implode(', ', array_keys($attributes))); + '] is not defined in the user\'s Attributes: '.implode(', ', array_keys($attributes)) + ); } // DN attribute must have a value @@ -249,7 +257,6 @@ class AttributeAddUsersGroups extends BaseFilter // Check each DN of the passed memberOf foreach ($memberof as $dn) { - // Avoid infinite loops, only need to check a DN once if (isset($searched[$dn])) { continue; diff --git a/modules/ldap/lib/Auth/Process/BaseFilter.php b/modules/ldap/lib/Auth/Process/BaseFilter.php index 60e9b70d9..42d5abb26 100644 --- a/modules/ldap/lib/Auth/Process/BaseFilter.php +++ b/modules/ldap/lib/Auth/Process/BaseFilter.php @@ -110,7 +110,6 @@ abstract class BaseFilter extends \SimpleSAML\Auth\ProcessingFilter // If an authsource was defined (an not empty string)... if (isset($config['authsource']) && $config['authsource']) { - // Log the authsource request \SimpleSAML\Logger::debug( $this->title.'Attempting to get configuration values from authsource ['. diff --git a/modules/ldap/lib/Auth/Source/LDAP.php b/modules/ldap/lib/Auth/Source/LDAP.php index e3cbd9d52..4757a3bb2 100644 --- a/modules/ldap/lib/Auth/Source/LDAP.php +++ b/modules/ldap/lib/Auth/Source/LDAP.php @@ -35,8 +35,10 @@ class LDAP extends \SimpleSAML\Module\core\Auth\UserPassBase // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $this->ldapConfig = new \SimpleSAML\Module\ldap\ConfigHelper($config, - 'Authentication source '.var_export($this->authId, true)); + $this->ldapConfig = new \SimpleSAML\Module\ldap\ConfigHelper( + $config, + 'Authentication source '.var_export($this->authId, true) + ); } diff --git a/modules/ldap/lib/Auth/Source/LDAPMulti.php b/modules/ldap/lib/Auth/Source/LDAPMulti.php index 8025d4471..88a575b74 100644 --- a/modules/ldap/lib/Auth/Source/LDAPMulti.php +++ b/modules/ldap/lib/Auth/Source/LDAPMulti.php @@ -45,25 +45,29 @@ class LDAPMulti extends \SimpleSAML\Module\core\Auth\UserPassOrgBase // Call the parent constructor first, as required by the interface parent::__construct($info, $config); - $cfgHelper = \SimpleSAML\Configuration::loadFromArray($config, - 'Authentication source '.var_export($this->authId, true)); + $cfgHelper = \SimpleSAML\Configuration::loadFromArray( + $config, + 'Authentication source '.var_export($this->authId, true) + ); $this->orgs = array(); $this->ldapOrgs = array(); foreach ($config as $name => $value) { - if ($name === 'username_organization_method') { $usernameOrgMethod = $cfgHelper->getValueValidate( 'username_organization_method', - array('none', 'allow', 'force')); + array('none', 'allow', 'force') + ); $this->setUsernameOrgMethod($usernameOrgMethod); continue; } if ($name === 'include_organization_in_username') { $this->includeOrgInUsername = $cfgHelper->getBoolean( - 'include_organization_in_username', false); + 'include_organization_in_username', + false + ); continue; } @@ -76,9 +80,10 @@ class LDAPMulti extends \SimpleSAML\Module\core\Auth\UserPassOrgBase $this->orgs[$orgId] = $orgId; } - $orgCfg = new \SimpleSAML\Module\ldap\ConfigHelper($orgCfg, - 'Authentication source '.var_export($this->authId, true). - ', organization '.var_export($orgId, true)); + $orgCfg = new \SimpleSAML\Module\ldap\ConfigHelper( + $orgCfg, + 'Authentication source '.var_export($this->authId, true).', organization '.var_export($orgId, true) + ); $this->ldapOrgs[$orgId] = $orgCfg; } } diff --git a/modules/ldap/lib/ConfigHelper.php b/modules/ldap/lib/ConfigHelper.php index 3b03a0826..d4dcff33a 100644 --- a/modules/ldap/lib/ConfigHelper.php +++ b/modules/ldap/lib/ConfigHelper.php @@ -151,7 +151,6 @@ class ConfigHelper $this->searchScope = $config->getString('search.scope', 'subtree'); $this->searchFilter = $config->getString('search.filter', null); $this->searchAttributes = $config->getArray('search.attributes'); - } else { $this->dnPattern = $config->getString('dnpattern'); } @@ -187,7 +186,14 @@ class ConfigHelper throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); } - $ldap = new \SimpleSAML\Auth\LDAP($this->hostname, $this->enableTLS, $this->debug, $this->timeout, $this->port, $this->referrals); + $ldap = new \SimpleSAML\Auth\LDAP( + $this->hostname, + $this->enableTLS, + $this->debug, + $this->timeout, + $this->port, + $this->referrals + ); if (!$this->searchEnable) { $ldapusername = addcslashes($username, ',+"\\<>;*'); @@ -199,7 +205,14 @@ class ConfigHelper } } - $dn = $ldap->searchfordn($this->searchBase, $this->searchAttributes, $username, true, $this->searchFilter, $this->searchScope); + $dn = $ldap->searchfordn( + $this->searchBase, + $this->searchAttributes, + $username, + true, + $this->searchFilter, + $this->searchScope + ); if ($dn === null) { /* User not found with search. */ \SimpleSAML\Logger::info($this->location.': Unable to find users DN. username=\''.$username.'\''); @@ -212,14 +225,14 @@ class ConfigHelper throw new \SimpleSAML\Error\Error('WRONGUSERPASS'); } - /* In case of SASL bind, authenticated and authorized DN may differ */ + // In case of SASL bind, authenticated and authorized DN may differ if (isset($sasl_args)) { $dn = $ldap->whoami($this->searchBase, $this->searchAttributes); } - /* Are privs needed to get the attributes? */ + // Are privs needed to get the attributes? if ($this->privRead) { - /* Yes, rebind with privs */ + // Yes, rebind with privs if (!$ldap->bind($this->privUsername, $this->privPassword)) { throw new \Exception('Error authenticating using privileged DN & password.'); } @@ -253,12 +266,14 @@ class ConfigHelper */ public function searchfordn($attribute, $value, $allowZeroHits) { - $ldap = new \SimpleSAML\Auth\LDAP($this->hostname, + $ldap = new \SimpleSAML\Auth\LDAP( + $this->hostname, $this->enableTLS, $this->debug, $this->timeout, $this->port, - $this->referrals); + $this->referrals + ); if ($attribute == null) { $attribute = $this->searchAttributes; @@ -270,8 +285,14 @@ class ConfigHelper } } - return $ldap->searchfordn($this->searchBase, $attribute, - $value, $allowZeroHits, $this->searchFilter, $this->searchScope); + return $ldap->searchfordn( + $this->searchBase, + $attribute, + $value, + $allowZeroHits, + $this->searchFilter, + $this->searchScope + ); } public function getAttributes($dn, $attributes = null) @@ -280,16 +301,18 @@ class ConfigHelper $attributes = $this->attributes; } - $ldap = new \SimpleSAML\Auth\LDAP($this->hostname, + $ldap = new \SimpleSAML\Auth\LDAP( + $this->hostname, $this->enableTLS, $this->debug, $this->timeout, $this->port, - $this->referrals); + $this->referrals + ); - /* Are privs needed to get the attributes? */ + // Are privs needed to get the attributes? if ($this->privRead) { - /* Yes, rebind with privs */ + // Yes, rebind with privs if (!$ldap->bind($this->privUsername, $this->privPassword)) { throw new \Exception('Error authenticating using privileged DN & password.'); } diff --git a/modules/memcacheMonitor/www/memcachestat.php b/modules/memcacheMonitor/www/memcachestat.php index 3025afce4..78bf44f56 100644 --- a/modules/memcacheMonitor/www/memcachestat.php +++ b/modules/memcacheMonitor/www/memcachestat.php @@ -2,7 +2,7 @@ function tdate($input) { - return date(DATE_RFC822, $input); + return date(DATE_RFC822, $input); } function hours($input) @@ -23,42 +23,42 @@ function humanreadable($input) { $output = ""; $input = abs($input); - + if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 100)) { - $output = sprintf("%5ldEi", $input / (1024 * 1024 * 1024 * 1024 * 1024 * 1024)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 10)) { - $output = sprintf("%5.1fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024)) { - $output = sprintf("%5.2fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 100)) { - $output = sprintf("%5ldPi", $input / (1024 * 1024 * 1024 * 1024 * 1024)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 10)) { - $output = sprintf("%5.1fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 1024)) { - $output = sprintf("%5.2fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 100)) { + $output = sprintf("%5ldEi", $input / (1024 * 1024 * 1024 * 1024 * 1024 * 1024)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024 * 10)) { + $output = sprintf("%5.1fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 1024)) { + $output = sprintf("%5.2fEi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 100)) { + $output = sprintf("%5ldPi", $input / (1024 * 1024 * 1024 * 1024 * 1024)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 1024 * 10)) { + $output = sprintf("%5.1fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 1024)) { + $output = sprintf("%5.2fPi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 100)) { $output = sprintf("%5ldTi", $input / (1024 * 1024 * 1024 * 1024)); - } else if ($input >= (1024 * 1024 * 1024 * 1024 * 10)) { - $output = sprintf("%5.1fTi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 1024)) { + } elseif ($input >= (1024 * 1024 * 1024 * 1024 * 10)) { + $output = sprintf("%5.1fTi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024 * 1024)) { $output = sprintf("%5.2fTi", $input / (1024.0 * 1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024 * 100)) { - $output = sprintf("%5ldGi", $input / (1024 * 1024 * 1024)); - } else if ($input >= (1024 * 1024 * 1024 * 10)) { - $output = sprintf("%5.1fGi", $input / (1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 1024)) { - $output = sprintf("%5.2fGi", $input / (1024.0 * 1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024 * 100)) { + } elseif ($input >= (1024 * 1024 * 1024 * 100)) { + $output = sprintf("%5ldGi", $input / (1024 * 1024 * 1024)); + } elseif ($input >= (1024 * 1024 * 1024 * 10)) { + $output = sprintf("%5.1fGi", $input / (1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 1024)) { + $output = sprintf("%5.2fGi", $input / (1024.0 * 1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024 * 100)) { $output = sprintf("%5ldMi", $input / (1024 * 1024)); - } else if ($input >= (1024 * 1024 * 10)) { - $output = sprintf("%5.1fM", $input / (1024.0 * 1024.0)); - } else if ($input >= (1024 * 1024)) { - $output = sprintf("%5.2fMi", $input / (1024.0 * 1024.0)); - } else if ($input >= (1024 * 100)) { + } elseif ($input >= (1024 * 1024 * 10)) { + $output = sprintf("%5.1fM", $input / (1024.0 * 1024.0)); + } elseif ($input >= (1024 * 1024)) { + $output = sprintf("%5.2fMi", $input / (1024.0 * 1024.0)); + } elseif ($input >= (1024 * 100)) { $output = sprintf("%5ldKi", $input / 1024); - } else if ($input >= (1024 * 10)) { + } elseif ($input >= (1024 * 10)) { $output = sprintf("%5.1fKi", $input / 1024.0); - } else if ($input >= (1024)) { + } elseif ($input >= (1024)) { $output = sprintf("%5.2fKi", $input / 1024.0); } else { $output = sprintf("%5ld", $input); @@ -109,7 +109,9 @@ $rowTitles = array( 'cmd_get' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_get}'), 'cmd_set' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_set}'), 'cmd_touch' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:cmd_touch}'), - 'connection_structures' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:connection_structures}'), + 'connection_structures' => \SimpleSAML\Locale\Translate::noop( + '{memcacheMonitor:memcachestat:connection_structures}' + ), 'conn_yields' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:conn_yields}'), 'curr_connections' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:curr_connections}'), 'curr_items' => \SimpleSAML\Locale\Translate::noop('{memcacheMonitor:memcachestat:curr_items}'), diff --git a/modules/metarefresh/config-templates/config-metarefresh.php b/modules/metarefresh/config-templates/config-metarefresh.php index 978170178..e86585c6a 100644 --- a/modules/metarefresh/config-templates/config-metarefresh.php +++ b/modules/metarefresh/config-templates/config-metarefresh.php @@ -68,7 +68,7 @@ $config = array( ), 'expireAfter' => 34560060, // Maximum 4 days cache time (3600*24*4) - 'outputDir' => 'metadata/metadata-kalmar-consuming/', + 'outputDir' => 'metadata/metadata-kalmar-consuming/', /* * Which output format the metadata should be saved as. diff --git a/modules/metarefresh/hooks/hook_cron.php b/modules/metarefresh/hooks/hook_cron.php index 8feee46ee..bb396b8a0 100644 --- a/modules/metarefresh/hooks/hook_cron.php +++ b/modules/metarefresh/hooks/hook_cron.php @@ -1,4 +1,7 @@ <?php + +use \SimpleSAML\Logger; + /** * Hook to run a cron job. * @@ -10,7 +13,7 @@ function metarefresh_hook_cron(&$croninfo) assert(array_key_exists('summary', $croninfo)); assert(array_key_exists('tag', $croninfo)); - SimpleSAML\Logger::info('cron [metarefresh]: Running cron in cron tag ['.$croninfo['tag'].'] '); + Logger::info('cron [metarefresh]: Running cron in cron tag ['.$croninfo['tag'].'] '); try { $config = \SimpleSAML\Configuration::getInstance(); @@ -26,7 +29,7 @@ function metarefresh_hook_cron(&$croninfo) continue; } - \SimpleSAML\Logger::info('cron [metarefresh]: Executing set ['.$setkey.']'); + Logger::info('cron [metarefresh]: Executing set ['.$setkey.']'); $expireAfter = $set->getInteger('expireAfter', null); if ($expireAfter !== null) { @@ -62,7 +65,6 @@ function metarefresh_hook_cron(&$croninfo) $set_types = $set->getArrayize('types', $available_types); foreach ($set->getArray('sources') as $source) { - // filter metadata by type of entity if (isset($source['types'])) { $metaloader->setTypes($source['types']); @@ -89,7 +91,7 @@ function metarefresh_hook_cron(&$croninfo) $source['conditionalGET'] = $conditionalGET; } - \SimpleSAML\Logger::debug('cron [metarefresh]: In set ['.$setkey.'] loading source ['.$source['src'].']'); + Logger::debug('cron [metarefresh]: In set ['.$setkey.'] loading source ['.$source['src'].']'); $metaloader->loadSource($source); } diff --git a/modules/metarefresh/lib/ARP.php b/modules/metarefresh/lib/ARP.php index 00ce46972..c64ff3463 100644 --- a/modules/metarefresh/lib/ARP.php +++ b/modules/metarefresh/lib/ARP.php @@ -47,7 +47,7 @@ class ARP $this->loadAttributeMap($attributemap_filename); } } - + /** * @param string $attributemap_filename * diff --git a/modules/metarefresh/lib/MetaLoader.php b/modules/metarefresh/lib/MetaLoader.php index abdc37160..d9c92a027 100644 --- a/modules/metarefresh/lib/MetaLoader.php +++ b/modules/metarefresh/lib/MetaLoader.php @@ -2,6 +2,8 @@ namespace SimpleSAML\Module\metarefresh; +use SimpleSAML\Logger; + /** * @package SimpleSAMLphp * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> @@ -85,23 +87,23 @@ class MetaLoader try { list($data, $responseHeaders) = \SimpleSAML\Utils\HTTP::fetch($source['src'], $context, true); } catch (\Exception $e) { - \SimpleSAML\Logger::warning('metarefresh: '.$e->getMessage()); + Logger::warning('metarefresh: '.$e->getMessage()); } // We have response headers, so the request succeeded if (!isset($responseHeaders)) { // No response headers, this means the request failed in some way, so re-use old data - \SimpleSAML\Logger::debug('No response from '.$source['src'].' - attempting to re-use cached metadata'); + Logger::debug('No response from '.$source['src'].' - attempting to re-use cached metadata'); $this->addCachedMetadata($source); return; } elseif (preg_match('@^HTTP/1\.[01]\s304\s@', $responseHeaders[0])) { // 304 response - \SimpleSAML\Logger::debug('Received HTTP 304 (Not Modified) - attempting to re-use cached metadata'); + Logger::debug('Received HTTP 304 (Not Modified) - attempting to re-use cached metadata'); $this->addCachedMetadata($source); return; } elseif (!preg_match('@^HTTP/1\.[01]\s200\s@', $responseHeaders[0])) { // Other error - \SimpleSAML\Logger::debug('Error from '.$source['src'].' - attempting to re-use cached metadata'); + Logger::debug('Error from '.$source['src'].' - attempting to re-use cached metadata'); $this->addCachedMetadata($source); return; } @@ -114,37 +116,38 @@ class MetaLoader // Everything OK. Proceed. if (isset($source['conditionalGET']) && $source['conditionalGET']) { // Stale or no metadata, so a fresh copy - \SimpleSAML\Logger::debug('Downloaded fresh copy'); + Logger::debug('Downloaded fresh copy'); } try { $entities = $this->loadXML($data, $source); } catch (\Exception $e) { - \SimpleSAML\Logger::debug('XML parser error when parsing '.$source['src'].' - attempting to re-use cached metadata'); - \SimpleSAML\Logger::debug('XML parser returned: '.$e->getMessage()); + Logger::debug('XML parser error when parsing '.$source['src'].' - attempting to re-use cached metadata'); + Logger::debug('XML parser returned: '.$e->getMessage()); $this->addCachedMetadata($source); return; } foreach ($entities as $entity) { - if (isset($source['blacklist'])) { if (!empty($source['blacklist']) && in_array($entity->getEntityID(), $source['blacklist'], true)) { - \SimpleSAML\Logger::info('Skipping "'.$entity->getEntityID().'" - blacklisted.'."\n"); + Logger::info('Skipping "'.$entity->getEntityID().'" - blacklisted.'."\n"); continue; } } if (isset($source['whitelist'])) { if (!empty($source['whitelist']) && !in_array($entity->getEntityID(), $source['whitelist'], true)) { - \SimpleSAML\Logger::info('Skipping "'.$entity->getEntityID().'" - not in the whitelist.'."\n"); + Logger::info('Skipping "'.$entity->getEntityID().'" - not in the whitelist.'."\n"); continue; } } if (array_key_exists('certificates', $source) && $source['certificates'] !== null) { if (!$entity->validateSignature($source['certificates'])) { - \SimpleSAML\Logger::info('Skipping "'.$entity->getEntityId().'" - could not verify signature using certificate.'."\n"); + Logger::info( + 'Skipping "'.$entity->getEntityId().'" - could not verify signature using certificate.'."\n" + ); continue; } } @@ -152,11 +155,13 @@ class MetaLoader if (array_key_exists('validateFingerprint', $source) && $source['validateFingerprint'] !== null) { if (!array_key_exists('certificates', $source) || $source['certificates'] == null) { if (!$entity->validateFingerprint($source['validateFingerprint'])) { - \SimpleSAML\Logger::info('Skipping "'.$entity->getEntityId().'" - could not verify signature using fingerprint.'."\n"); + Logger::info( + 'Skipping "'.$entity->getEntityId().'" - could not verify signature using fingerprint.'."\n" + ); continue; } } else { - \SimpleSAML\Logger::info('Skipping validation with fingerprint since option certificate is set.'."\n"); + Logger::info('Skipping validation with fingerprint since option certificate is set.'."\n"); } } @@ -180,7 +185,12 @@ class MetaLoader if (in_array('attributeauthority-remote', $this->types, true)) { $attributeAuthorities = $entity->getAttributeAuthorities(); if (!empty($attributeAuthorities)) { - $this->addMetadata($source['src'], $attributeAuthorities[0], 'attributeauthority-remote', $template); + $this->addMetadata( + $source['src'], + $attributeAuthorities[0], + 'attributeauthority-remote', + $template + ); } } } @@ -281,7 +291,7 @@ class MetaLoader public function writeState() { if ($this->changed) { - \SimpleSAML\Logger::debug('Writing: '.$this->stateFile); + Logger::debug('Writing: '.$this->stateFile); \SimpleSAML\Utils\System::writeFile( $this->stateFile, "<?php\n/* This file was generated by the metarefresh module at ".$this->getTime().".\n". @@ -299,7 +309,6 @@ class MetaLoader public function dumpMetadataStdOut() { foreach ($this->metadata as $category => $elements) { - echo '/* The following data should be added to metadata/'.$category.'.php. */'."\n"; foreach ($elements as $m) { @@ -378,7 +387,8 @@ class MetaLoader } // $metadata, $attributemap, $prefix, $suffix - $arp = new \SimpleSAML\Module\metarefresh\ARP($md, + $arp = new \SimpleSAML\Module\metarefresh\ARP( + $md, $config->getValue('attributemap', ''), $config->getValue('prefix', ''), $config->getValue('suffix', '') @@ -387,7 +397,7 @@ class MetaLoader $arpxml = $arp->getXML(); - \SimpleSAML\Logger::info('Writing ARP file: '.$arpfile."\n"); + Logger::info('Writing ARP file: '.$arpfile."\n"); file_put_contents($arpfile, $arpxml); } @@ -402,7 +412,7 @@ class MetaLoader } if (!file_exists($outputDir)) { - \SimpleSAML\Logger::info('Creating directory: '.$outputDir."\n"); + Logger::info('Creating directory: '.$outputDir."\n"); $res = @mkdir($outputDir, 0777, true); if ($res === false) { throw new \Exception('Error creating directory: '.$outputDir); @@ -414,15 +424,15 @@ class MetaLoader if (array_key_exists($type, $this->metadata)) { $elements = $this->metadata[$type]; - \SimpleSAML\Logger::debug('Writing: '.$filename); + Logger::debug('Writing: '.$filename); - $content = '<?php'."\n".'/* This file was generated by the metarefresh module at '.$this->getTime()."\n"; - $content .= ' Do not update it manually as it will get overwritten'."\n".'*/'."\n"; + $content = '<?php'."\n".'/* This file was generated by the metarefresh module at '; + $content .= $this->getTime()."\nDo not update it manually as it will get overwritten\n".'*/'."\n"; foreach ($elements as $m) { $entityID = $m['metadata']['entityid']; - $content .= "\n"; - $content .= '$metadata[\''.addslashes($entityID).'\'] = '.var_export($m['metadata'], true).';'."\n"; + $content .= "\n".'$metadata[\''. + $content .= addslashes($entityID).'\'] = '.var_export($m['metadata'], true).';'."\n"; } $content .= "\n".'?>'; @@ -430,9 +440,9 @@ class MetaLoader \SimpleSAML\Utils\System::writeFile($filename, $content, 0644); } elseif (is_file($filename)) { if (unlink($filename)) { - \SimpleSAML\Logger::debug('Deleting stale metadata file: '.$filename); + Logger::debug('Deleting stale metadata file: '.$filename); } else { - \SimpleSAML\Logger::warning('Could not delete stale metadata file: '.$filename); + Logger::warning('Could not delete stale metadata file: '.$filename); } } } @@ -455,7 +465,7 @@ class MetaLoader foreach ($elements as $m) { $entityId = $m['metadata']['entityid']; - \SimpleSAML\Logger::debug( + Logger::debug( 'metarefresh: Add metadata entry '. var_export($entityId, true).' in set '.var_export($set, true).'.' ); @@ -468,7 +478,7 @@ class MetaLoader foreach ($metaHandler->getMetadataSets() as $set) { foreach ($metaHandler->getMetadataSet($set) as $entityId => $metadata) { if (!array_key_exists('expire', $metadata)) { - \SimpleSAML\Logger::warning( + Logger::warning( 'metarefresh: Metadata entry without expire timestamp: '.var_export($entityId, true). ' in set '.var_export($set, true).'.' ); @@ -477,10 +487,11 @@ class MetaLoader if ($metadata['expire'] > $ct) { continue; } - \SimpleSAML\Logger::debug('metarefresh: '.$entityId.' expired '.date('l jS \of F Y h:i:s A', $metadata['expire'])); - \SimpleSAML\Logger::debug( + Logger::debug('metarefresh: '.$entityId.' expired '.date('l jS \of F Y h:i:s A', $metadata['expire'])); + Logger::debug( 'metarefresh: Delete expired metadata entry '. - var_export($entityId, true).' in set '.var_export($set, true).'. ('.($ct - $metadata['expire']).' sec)' + var_export($entityId, true).' in set '.var_export($set, true). + '. ('.($ct - $metadata['expire']).' sec)' ); $metaHandler->deleteMetadata($entityId, $set); } diff --git a/modules/metarefresh/templates/fetch.tpl.php b/modules/metarefresh/templates/fetch.tpl.php index 780e98c89..5a988ce74 100644 --- a/modules/metarefresh/templates/fetch.tpl.php +++ b/modules/metarefresh/templates/fetch.tpl.php @@ -2,21 +2,16 @@ $this->data['header'] = $this->t('{metarefresh:metarefresh:metarefresh_header}'); $this->includeAtTemplateBase('includes/header.php'); -echo('<h1>'.$this->data['header'].'</h1>'); - +echo '<h1>'.$this->data['header'].'</h1>'; if (!empty($this->data['logentries'])) { - - echo '<pre style="border: 1px solid #aaa; padding: .5em; overflow: scroll">'; - foreach($this->data['logentries'] AS $l) { - echo $l . "\n"; - } - echo '</pre>'; - + echo '<pre style="border: 1px solid #aaa; padding: .5em; overflow: scroll">'; + foreach ($this->data['logentries'] as $l) { + echo $l."\n"; + } + echo '</pre>'; } else { - echo $this->t('{metarefresh:metarefresh:no_output}'); + echo $this->t('{metarefresh:metarefresh:no_output}'); } - - $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/metarefresh/www/fetch.php b/modules/metarefresh/www/fetch.php index 2a1bbc01f..0ecb548d0 100644 --- a/modules/metarefresh/www/fetch.php +++ b/modules/metarefresh/www/fetch.php @@ -36,7 +36,6 @@ foreach ($sets as $setkey => $set) { $set_types = $set->getArrayize('types', $available_types); foreach ($set->getArray('sources') as $source) { - // filter metadata by type of entity if (isset($source['types'])) { $metaloader->setTypes($source['types']); @@ -73,7 +72,7 @@ foreach ($sets as $setkey => $set) { case 'serialize': $metaloader->writeMetadataSerialize($outputDir); break; - } + } } catch (\Exception $e) { $e = \SimpleSAML\Error\Exception::fromException($e); $e->logWarning(); diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index ae3682f69..a0f9778a2 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -40,8 +40,8 @@ class MultiAuth extends \SimpleSAML\Auth\Source /** * Constructor for this authentication source. * - * @param array $info Information about this authentication source. - * @param array $config Configuration. + * @param array $info Information about this authentication source. + * @param array $config Configuration. */ public function __construct($info, $config) { @@ -61,7 +61,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $this->sources = array(); foreach ($config['sources'] as $source => $info) { if (is_int($source)) { - // Backwards compatibility + // Backwards compatibility $source = $info; $info = array(); } @@ -106,7 +106,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * This method never return. The authentication process is finished * in the delegateAuthentication method. * - * @param array &$state Information about the current authentication. + * @param array &$state Information about the current authentication. */ public function authenticate(&$state) { @@ -143,8 +143,8 @@ class MultiAuth extends \SimpleSAML\Auth\Source * to be able to logout properly. Then it calls the authenticate method * on such selected authentication source. * - * @param string $authId Selected authentication source - * @param array $state Information about the current authentication. + * @param string $authId Selected authentication source + * @param array $state Information about the current authentication. */ public static function delegateAuthentication($authId, $state) { @@ -153,7 +153,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $as = \SimpleSAML\Auth\Source::getById($authId); $valid_sources = array_map( - function($src) { + function ($src) { return $src['source']; }, $state[self::SOURCESID] @@ -164,7 +164,12 @@ class MultiAuth extends \SimpleSAML\Auth\Source // Save the selected authentication source for the logout process. $session = \SimpleSAML\Session::getSessionFromRequest(); - $session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId, \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END); + $session->setData( + self::SESSION_SOURCE, + $state[self::AUTHID], + $authId, + \SimpleSAML\Session::DATA_TIMEOUT_SESSION_END + ); try { $as->authenticate($state); @@ -183,7 +188,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * This method retrieves the authentication source used for this * session and then call the logout method on it. * - * @param array &$state Information about the current logout operation. + * @param array &$state Information about the current logout operation. */ public function logout(&$state) { diff --git a/modules/multiauth/www/selectsource.php b/modules/multiauth/www/selectsource.php index 70c889d8a..287f7808e 100644 --- a/modules/multiauth/www/selectsource.php +++ b/modules/multiauth/www/selectsource.php @@ -56,8 +56,17 @@ $language = $t->getTranslator()->getLanguage()->getLanguage(); $sources = $state[\SimpleSAML\Module\multiauth\Auth\Source\MultiAuth::SOURCESID]; foreach ($sources as $key => $source) { $sources[$key]['source64'] = base64_encode($sources[$key]['source']); - $sources[$key]['text'] = (isset($sources[$key]['text'][$language]) ? $sources[$key]['text'][$language] : $sources[$key]['text'][$defaultLanguage]); - $sources[$key]['help'] = (isset($sources[$key]['help'][$language]) ? $sources[$key]['help'][$language] : $sources[$key]['help'][$defaultLanguage]); + if (isset($sources[$key]['text'][$language])) { + $sources[$key]['text'] = $sources[$key]['text'][$language]; + } else { + $sources[$key]['text'] = $sources[$key]['text'][$defaultLanguage]; + } + + if (isset($sources[$key]['help'][$language])) { + $sources[$key]['help'] = $sources[$key]['help'][$language]; + } else { + $sources[$key]['help'] = $sources[$key]['help'][$defaultLanguage]; + } } $t->data['authstate'] = $authStateId; diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php index b862d55e1..4d98c96bb 100644 --- a/modules/negotiate/lib/Auth/Source/Negotiate.php +++ b/modules/negotiate/lib/Auth/Source/Negotiate.php @@ -2,6 +2,8 @@ namespace SimpleSAML\Module\negotiate\Auth\Source; +use \SimpleSAML\Logger; + /** * The Negotiate module. Allows for password-less, secure login by Kerberos and Negotiate. * @@ -105,7 +107,7 @@ class Negotiate extends \SimpleSAML\Auth\Source (!empty($_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT']) && $_COOKIE['NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT'] == 'True') ) { - \SimpleSAML\Logger::debug('Negotiate - session disabled. falling back'); + Logger::debug('Negotiate - session disabled. falling back'); $this->fallBack($state); // never executed assert(false); @@ -117,9 +119,9 @@ class Negotiate extends \SimpleSAML\Auth\Source assert(false); } - \SimpleSAML\Logger::debug('Negotiate - authenticate(): looking for Negotiate'); + Logger::debug('Negotiate - authenticate(): looking for Negotiate'); if (!empty($_SERVER['HTTP_AUTHORIZATION'])) { - \SimpleSAML\Logger::debug('Negotiate - authenticate(): Negotiate found'); + Logger::debug('Negotiate - authenticate(): Negotiate found'); $this->ldap = new \SimpleSAML\Auth\LDAP( $this->hostname, $this->enableTLS, @@ -131,10 +133,10 @@ class Negotiate extends \SimpleSAML\Auth\Source list($mech,) = explode(' ', $_SERVER['HTTP_AUTHORIZATION'], 2); if (strtolower($mech) == 'basic') { - \SimpleSAML\Logger::debug('Negotiate - authenticate(): Basic found. Skipping.'); + Logger::debug('Negotiate - authenticate(): Basic found. Skipping.'); } else { if (strtolower($mech) != 'negotiate') { - \SimpleSAML\Logger::debug('Negotiate - authenticate(): No "Negotiate" found. Skipping.'); + Logger::debug('Negotiate - authenticate(): No "Negotiate" found. Skipping.'); } } @@ -143,14 +145,14 @@ class Negotiate extends \SimpleSAML\Auth\Source try { $reply = $auth->doAuthentication(); } catch (\Exception $e) { - \SimpleSAML\Logger::error('Negotiate - authenticate(): doAuthentication() exception: '.$e->getMessage()); + Logger::error('Negotiate - authenticate(): doAuthentication() exception: '.$e->getMessage()); $reply = null; } if ($reply) { // success! krb TGS received $user = $auth->getAuthenticatedUser(); - \SimpleSAML\Logger::info('Negotiate - authenticate(): '.$user.' authenticated.'); + Logger::info('Negotiate - authenticate(): '.$user.' authenticated.'); $lookup = $this->lookupUserData($user); if ($lookup !== null) { $state['Attributes'] = $lookup; @@ -158,20 +160,20 @@ class Negotiate extends \SimpleSAML\Auth\Source $state['LogoutState'] = array( 'negotiate:backend' => null, ); - \SimpleSAML\Logger::info('Negotiate - authenticate(): '.$user.' authorized.'); + Logger::info('Negotiate - authenticate(): '.$user.' authorized.'); \SimpleSAML\Auth\Source::completeAuth($state); // Never reached. assert(false); } } else { // Some error in the received ticket. Expired? - \SimpleSAML\Logger::info('Negotiate - authenticate(): Kerberos authN failed. Skipping.'); + Logger::info('Negotiate - authenticate(): Kerberos authN failed. Skipping.'); } } else { // No auth token. Send it. - \SimpleSAML\Logger::debug('Negotiate - authenticate(): Sending Negotiate.'); + Logger::debug('Negotiate - authenticate(): Sending Negotiate.'); // Save the $state array, so that we can restore if after a redirect - \SimpleSAML\Logger::debug('Negotiate - fallback: '.$state['LogoutState']['negotiate:backend']); + Logger::debug('Negotiate - fallback: '.$state['LogoutState']['negotiate:backend']); $id = \SimpleSAML\Auth\State::saveState($state, self::STAGEID); $params = array('AuthState' => $id); @@ -179,10 +181,9 @@ class Negotiate extends \SimpleSAML\Auth\Source exit; } - \SimpleSAML\Logger::info('Negotiate - authenticate(): Client failed Negotiate. Falling back'); + Logger::info('Negotiate - authenticate(): Client failed Negotiate. Falling back'); $this->fallBack($state); - /* The previous function never returns, so this code is never - executed */ + // The previous function never returns, so this code is never executed assert(false); } @@ -191,13 +192,13 @@ class Negotiate extends \SimpleSAML\Auth\Source { if (array_key_exists('negotiate:disable', $spMetadata)) { if ($spMetadata['negotiate:disable'] == true) { - \SimpleSAML\Logger::debug('Negotiate - SP disabled. falling back'); + Logger::debug('Negotiate - SP disabled. falling back'); return true; } else { - \SimpleSAML\Logger::debug('Negotiate - SP disable flag found but set to FALSE'); + Logger::debug('Negotiate - SP disable flag found but set to FALSE'); } } else { - \SimpleSAML\Logger::debug('Negotiate - SP disable flag not found'); + Logger::debug('Negotiate - SP disable flag not found'); } return false; } @@ -221,11 +222,11 @@ class Negotiate extends \SimpleSAML\Auth\Source foreach ($this->subnet as $cidr) { $ret = \SimpleSAML\Utils\Net::ipCIDRcheck($cidr); if ($ret) { - \SimpleSAML\Logger::debug('Negotiate: Client "'.$ip.'" matched subnet.'); + Logger::debug('Negotiate: Client "'.$ip.'" matched subnet.'); return true; } } - \SimpleSAML\Logger::debug('Negotiate: Client "'.$ip.'" did not match subnet.'); + Logger::debug('Negotiate: Client "'.$ip.'" did not match subnet.'); return false; } @@ -281,7 +282,7 @@ class Negotiate extends \SimpleSAML\Auth\Source \SimpleSAML\Auth\State::throwException($state, $e); } // fallBack never returns after loginCompleted() - \SimpleSAML\Logger::debug('Negotiate: backend returned'); + Logger::debug('Negotiate: backend returned'); self::loginCompleted($state); } @@ -308,7 +309,7 @@ class Negotiate extends \SimpleSAML\Auth\Source $dn = $this->ldap->searchfordn($this->base, $this->attr, $uid); return $this->ldap->getAttributes($dn, $this->attributes); } catch (\SimpleSAML\Error\Exception $e) { - \SimpleSAML\Logger::debug('Negotiate - ldap lookup failed: '.$e); + Logger::debug('Negotiate - ldap lookup failed: '.$e); return null; } } @@ -324,13 +325,11 @@ class Negotiate extends \SimpleSAML\Auth\Source // no admin user return; } - \SimpleSAML\Logger::debug( - 'Negotiate - authenticate(): Binding as system user '.var_export($this->admin_user, true) - ); + Logger::debug('Negotiate - authenticate(): Binding as system user '.var_export($this->admin_user, true)); if (!$this->ldap->bind($this->admin_user, $this->admin_pw)) { $msg = 'Unable to authenticate system user (LDAP_INVALID_CREDENTIALS) '.var_export($this->admin_user, true); - \SimpleSAML\Logger::error('Negotiate - authenticate(): '.$msg); + Logger::error('Negotiate - authenticate(): '.$msg); throw new \SimpleSAML\Error\AuthSource('negotiate', $msg); } } @@ -349,7 +348,7 @@ class Negotiate extends \SimpleSAML\Auth\Source assert(is_array($state)); // get the source that was used to authenticate $authId = $state['negotiate:backend']; - \SimpleSAML\Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"'); + Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"'); if ($authId === null) { $session = \SimpleSAML\Session::getSessionFromRequest(); diff --git a/modules/negotiate/www/backend.php b/modules/negotiate/www/backend.php index 07550c9e0..8a5222f26 100644 --- a/modules/negotiate/www/backend.php +++ b/modules/negotiate/www/backend.php @@ -8,7 +8,10 @@ * @package SimpleSAMLphp */ -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['AuthState'], \SimpleSAML\Module\negotiate\Auth\Source\Negotiate::STAGEID); +$state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['AuthState'], + \SimpleSAML\Module\negotiate\Auth\Source\Negotiate::STAGEID +); \SimpleSAML\Logger::debug('backend - fallback: '.$state['LogoutState']['negotiate:backend']); \SimpleSAML\Module\negotiate\Auth\Source\Negotiate::fallBack($state); diff --git a/modules/negotiate/www/retry.php b/modules/negotiate/www/retry.php index 390e712e4..c4ffd87a5 100644 --- a/modules/negotiate/www/retry.php +++ b/modules/negotiate/www/retry.php @@ -8,7 +8,10 @@ * */ -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['AuthState'], \SimpleSAML\Module\negotiate\Auth\Source\Negotiate::STAGEID); +$state = \SimpleSAML\Auth\State::loadState( + $_REQUEST['AuthState'], + \SimpleSAML\Module\negotiate\Auth\Source\Negotiate::STAGEID +); $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpid = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted', 'metaindex'); diff --git a/modules/oauth/config-template/module_oauth.php b/modules/oauth/config-template/module_oauth.php index a99f2acf1..475acb3e2 100644 --- a/modules/oauth/config-template/module_oauth.php +++ b/modules/oauth/config-template/module_oauth.php @@ -1,7 +1,7 @@ <?php -/* +/* * Configuration for the OAuth module. - * + * */ $config = array( @@ -17,7 +17,7 @@ $config = array( // Tag to run storage cleanup script using the cron module... 'cron_tag' => 'hourly', - // auth is the idp to use for admin authentication, + // auth is the idp to use for admin authentication, // useridattr is the attribute-name that contains the userid as returned from idp 'auth' => 'default-sp', 'useridattr', 'user', diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php index 43642f49f..71643df8a 100644 --- a/modules/oauth/lib/Consumer.php +++ b/modules/oauth/lib/Consumer.php @@ -51,9 +51,9 @@ class Consumer * This static helper function wraps \SimpleSAML\Utils\HTTP::fetch * and throws an exception with diagnostics messages if it appear * to be failing on an OAuth endpoint. - * + * * If the status code is not 200, an exception is thrown. If the content-type - * of the response if text/plain, the content of the response is included in + * of the response if text/plain, the content of the response is included in * the text of the Exception thrown. */ public static function getHTTP($url, $context = '') @@ -74,7 +74,7 @@ class Consumer } throw new \Exception($error.':'.$url); - } + } // Fall back to return response, if could not reckognize HTTP header. Should not happen. return $response; } @@ -111,7 +111,7 @@ class Consumer if ($redirect) { \SimpleSAML\Utils\HTTP::redirectTrustedURL($authorizeURL); exit; - } + } return $authorizeURL; } diff --git a/modules/oauth/lib/OAuthServer.php b/modules/oauth/lib/OAuthServer.php index 5114fff1f..b6607e6fe 100644 --- a/modules/oauth/lib/OAuthServer.php +++ b/modules/oauth/lib/OAuthServer.php @@ -23,4 +23,3 @@ class OAuthServer extends OAuthServer return $this->signature_methods; } } - diff --git a/modules/oauth/lib/OAuthStore.php b/modules/oauth/lib/OAuthStore.php index 5469dab2d..ee5725cb1 100644 --- a/modules/oauth/lib/OAuthStore.php +++ b/modules/oauth/lib/OAuthStore.php @@ -6,8 +6,8 @@ require_once(dirname(dirname(__FILE__)).'/libextinc/OAuth.php'); /** * OAuth Store - * - * Updated version, works with consumer-callbacks, certificates and 1.0-RevA protocol + * + * Updated version, works with consumer-callbacks, certificates and 1.0-RevA protocol * behaviour (requestToken-callbacks and verifiers) * * @author Andreas Ă…kre Solberg, <andreas.solberg@uninett.no>, UNINETT AS. @@ -22,7 +22,7 @@ class OAuthStore extends \OAuthDataStore private $defaultversion = '1.0'; protected $_store_tables = array( - 'consumers' => 'consumer = array with consumer attributes', + 'consumers' => 'consumer = array with consumer attributes', 'nonce' => 'nonce+consumer_key = -boolean-', 'requesttorequest' => 'requestToken.key = array(version,callback,consumerKey,)', 'authorized' => 'requestToken.key, verifier = array(authenticated-user-attributes)', @@ -153,7 +153,7 @@ class OAuthStore extends \OAuthDataStore { \SimpleSAML\Logger::info('OAuth new_request_token('.$consumer.')'); - $lifetime = $this->config->getValue('requestTokenDuration', 1800); //60*30 + $lifetime = $this->config->getValue('requestTokenDuration', 1800); //60*30 $token = new \OAuthToken(\SimpleSAML\Utils\Random::generateID(), \SimpleSAML\Utils\Random::generateID()); $token->callback = $callback; // OAuth1.0-RevA @@ -161,13 +161,15 @@ class OAuthStore extends \OAuthDataStore // also store in requestToken->key => array('callback'=>CallbackURL, 'version'=>oauth_version $request_attributes = array( - 'callback' => $callback, + 'callback' => $callback, 'version' => ($version ? $version : $this->defaultversion), 'consumerKey' => $consumer->key, ); $this->store->set('requesttorequest', $token->key, '', $request_attributes, $lifetime); - // also store in requestToken->key => Consumer->key (enables consumer-lookup during reqToken-authorization stage) + /* also store in requestToken->key => + * Consumer->key (enables consumer-lookup during reqToken-authorization stage) + */ $this->store->set('requesttoconsumer', $token->key, '', $consumer->key, $lifetime); return $token; @@ -177,7 +179,13 @@ class OAuthStore extends \OAuthDataStore { \SimpleSAML\Logger::info('OAuth new_access_token('.$requestToken.','.$consumer.')'); $accesstoken = new \OAuthToken(\SimpleSAML\Utils\Random::generateID(), \SimpleSAML\Utils\Random::generateID()); - $this->store->set('access', $accesstoken->key, $consumer->key, $accesstoken, $this->config->getValue('accessTokenDuration', 86400)); //60*60*24=86400 + $this->store->set( + 'access', + $accesstoken->key, + $consumer->key, + $accesstoken, + $this->config->getValue('accessTokenDuration', 86400) //60*60*24=86400 + ); return $accesstoken; } diff --git a/modules/oauth/lib/Registry.php b/modules/oauth/lib/Registry.php index aea40cc86..984638b6f 100644 --- a/modules/oauth/lib/Registry.php +++ b/modules/oauth/lib/Registry.php @@ -15,7 +15,7 @@ class Registry { if (array_key_exists('field_'.$key, $request)) { $entry[$key] = $request['field_'.$key]; - } else if (isset($entry[$key])) { + } elseif (isset($entry[$key])) { unset($entry[$key]); } } @@ -53,7 +53,7 @@ class Registry $this->requireStandardField($request, 'description'); $this->requireStandardField($request, 'key'); } - + protected function header($name) { return '<tr><td> </td><td class="header">'.$name.'</td></tr>'; @@ -124,7 +124,12 @@ class Registry $this->readonlyField($metadata, 'owner', 'Owner'). $this->standardField($metadata, 'key', 'Consumer Key'). $this->readonlyField($metadata, 'secret', 'Consumer Secret<br />(Used for HMAC_SHA1 signatures)'). - $this->standardField($metadata, 'RSAcertificate', 'RSA certificate (PEM)<br />(Used for RSA_SHA1 signatures)', true). + $this->standardField( + $metadata, + 'RSAcertificate', + 'RSA certificate (PEM)<br />(Used for RSA_SHA1 signatures)', + true + ). $this->standardField($metadata, 'callback_url', 'Static/enforcing callback-url'). '</table></div>'. '</div>'. diff --git a/modules/oauth/libextinc/OAuth.php b/modules/oauth/libextinc/OAuth.php index 7ea0d8dfe..994241b33 100644 --- a/modules/oauth/libextinc/OAuth.php +++ b/modules/oauth/libextinc/OAuth.php @@ -316,9 +316,8 @@ class OAuthRequest // It's a POST request of the proper content-type, so parse POST // parameters and add those overriding any duplicates from GET if ($http_method == "POST" - && isset($request_headers['Content-Type']) - && strstr($request_headers['Content-Type'], - 'application/x-www-form-urlencoded') + && isset($request_headers['Content-Type']) + && strstr($request_headers['Content-Type'], 'application/x-www-form-urlencoded') ) { $post_data = OAuthUtil::parse_parameters( file_get_contents(self::$POST_INPUT) @@ -328,13 +327,14 @@ class OAuthRequest // We have a Authorization-header with OAuth data. Parse the header // and add those overriding any duplicates from GET or POST - if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 0, 6) == 'OAuth ') { + if (isset($request_headers['Authorization']) + && substr($request_headers['Authorization'], 0, 6) == 'OAuth ' + ) { $header_parameters = OAuthUtil::split_header( $request_headers['Authorization'] ); $parameters = array_merge($parameters, $header_parameters); } - } return new OAuthRequest($http_method, $http_url, $parameters); @@ -577,14 +577,14 @@ class OAuthServer */ public function fetch_request_token(&$request) { - $this->get_version($request); + $this->getVersion($request); - $consumer = $this->get_consumer($request); + $consumer = $this->getConsumer($request); // no token required for the initial token request $token = null; - $this->check_signature($request, $consumer, $token); + $this->checkSignature($request, $consumer, $token); // Rev A change $callback = $request->get_parameter('oauth_callback'); @@ -599,14 +599,14 @@ class OAuthServer */ public function fetch_access_token(&$request) { - $this->get_version($request); + $this->getVersion($request); - $consumer = $this->get_consumer($request); + $consumer = $this->getConsumer($request); // requires authorized request token - $token = $this->get_token($request, $consumer, "request"); + $token = $this->getToken($request, $consumer, "request"); - $this->check_signature($request, $consumer, $token); + $this->checkSignature($request, $consumer, $token); // Rev A change $verifier = $request->get_parameter('oauth_verifier'); @@ -620,10 +620,10 @@ class OAuthServer */ public function verify_request(&$request) { - $this->get_version($request); - $consumer = $this->get_consumer($request); - $token = $this->get_token($request, $consumer, "access"); - $this->check_signature($request, $consumer, $token); + $this->getVersion($request); + $consumer = $this->getConsumer($request); + $token = $this->getToken($request, $consumer, "access"); + $this->checkSignature($request, $consumer, $token); return array($consumer, $token); } @@ -631,7 +631,7 @@ class OAuthServer /** * version 1 */ - private function get_version(&$request) + private function getVersion(&$request) { $version = $request->get_parameter("oauth_version"); if (!$version) { @@ -648,7 +648,7 @@ class OAuthServer /** * figure out the signature with some defaults */ - private function get_signature_method($request) + private function getSignatureMethod($request) { $signature_method = $request instanceof OAuthRequest ? $request->get_parameter("oauth_signature_method") @@ -660,8 +660,7 @@ class OAuthServer throw new OAuthException('No signature method parameter. This parameter is required'); } - if (!in_array($signature_method, - array_keys($this->signature_methods))) { + if (!in_array($signature_method, array_keys($this->signature_methods))) { throw new OAuthException( "Signature method '$signature_method' not supported ". "try one of the following: ". @@ -674,7 +673,7 @@ class OAuthServer /** * try to find the consumer for the provided request's consumer key */ - private function get_consumer($request) + private function getConsumer($request) { $consumer_key = $request instanceof OAuthRequest ? $request->get_parameter("oauth_consumer_key") @@ -695,16 +694,14 @@ class OAuthServer /** * try to find the token for the provided request's token key */ - private function get_token($request, $consumer, $token_type = "access") + private function getToken($request, $consumer, $token_type = "access") { $token_field = $request instanceof OAuthRequest ? $request->get_parameter('oauth_token') : null; if (!empty($token_field)) { - $token = $this->data_store->lookup_token( - $consumer, $token_type, $token_field - ); + $token = $this->data_store->lookup_token($consumer, $token_type, $token_field); if (!$token) { throw new OAuthException('Invalid '.$token_type.' token: '.$token_field); } @@ -718,7 +715,7 @@ class OAuthServer * all-in-one function to check the signature on a request * should guess the signature method appropriately */ - private function check_signature($request, $consumer, $token) + private function checkSignature($request, $consumer, $token) { // this should probably be in a different method $timestamp = $request instanceof OAuthRequest @@ -728,13 +725,13 @@ class OAuthServer ? $request->get_parameter('oauth_nonce') : null; - $this->check_timestamp($timestamp); - $this->check_nonce($consumer, $token, $nonce, $timestamp); + $this->checkTimestamp($timestamp); + $this->checkNonce($consumer, $token, $nonce, $timestamp); - $signature_method = $this->get_signature_method($request); + $signature_method = $this->getSignatureMethod($request); $signature = $request->get_parameter('oauth_signature'); - $valid_sig = $signature_method->check_signature( + $valid_sig = $signature_method->checkSignature( $request, $consumer, $token, @@ -749,7 +746,7 @@ class OAuthServer /** * check that the timestamp is new enough */ - private function check_timestamp($timestamp) + private function checkTimestamp($timestamp) { if (!$timestamp) { throw new OAuthException( @@ -769,7 +766,7 @@ class OAuthServer /** * check that the nonce is not repeated */ - private function check_nonce($consumer, $token, $nonce, $timestamp) + private function checkNonce($consumer, $token, $nonce, $timestamp) { if (!$nonce) { throw new OAuthException( @@ -819,7 +816,6 @@ class OAuthDataStore // is authorized // should also invalidate the request token } - } class OAuthUtil @@ -828,7 +824,7 @@ class OAuthUtil { if (is_array($input)) { return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input); - } else if (is_scalar($input)) { + } elseif (is_scalar($input)) { return str_replace( '+', ' ', @@ -856,7 +852,11 @@ class OAuthUtil public static function split_header($header, $only_allow_oauth_parameters = true) { $params = array(); - if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) { + if (preg_match_all( + '/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', + $header, + $matches + )) { foreach ($matches[1] as $i => $h) { $params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]); } diff --git a/modules/oauth/templates/registry.edit.tpl.php b/modules/oauth/templates/registry.edit.tpl.php index 0faa690e7..58a58d010 100644 --- a/modules/oauth/templates/registry.edit.tpl.php +++ b/modules/oauth/templates/registry.edit.tpl.php @@ -1,8 +1,10 @@ <?php $this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); -$this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'.$this->data['baseurlpath'].'module.php/oauth/assets/css/oauth.css" />'."\n"; -$this->data['head'] .= '<script type="text/javascript" src="/'.$this->data['baseurlpath'].'module.php/oauth/assets/js/oauth.js"></script>'; +$this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'. + $this->data['baseurlpath'].'module.php/oauth/assets/css/oauth.css" />'."\n"; +$this->data['head'] .= '<script type="text/javascript" src="/'. + $this->data['baseurlpath'].'module.php/oauth/assets/js/oauth.js"></script>'; $this->includeAtTemplateBase('includes/header.php'); @@ -10,7 +12,7 @@ echo '<h1>OAuth Client</h1>'; echo $this->data['form']; -echo '<p style="float: right"><a href="registry.php">Return to entity listing <strong>without saving...</strong></a></p>'; +echo '<p style="float: right"><a href="registry.php">'. + 'Return to entity listing <strong>without saving...</strong></a></p>'; $this->includeAtTemplateBase('includes/footer.php'); - diff --git a/modules/oauth/templates/registry.list.php b/modules/oauth/templates/registry.list.php index 376352714..912f5a71c 100644 --- a/modules/oauth/templates/registry.list.php +++ b/modules/oauth/templates/registry.list.php @@ -1,10 +1,12 @@ <?php $this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); -$this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'.$this->data['baseurlpath'].'module.php/oauth/assets/oauth.css" />'."\n"; +$this->data['head'] = '<link rel="stylesheet" type="text/css" href="/'. + $this->data['baseurlpath'].'module.php/oauth/assets/oauth.css" />'."\n"; $this->includeAtTemplateBase('includes/header.php'); echo '<h1>OAuth Client Registry</h1>'; -echo '<p>Here you can register new OAuth Clients. You are successfully logged in as '.htmlspecialchars($this->data['userid']).'</p>'; +echo '<p>Here you can register new OAuth Clients. You are successfully logged in as '. + htmlspecialchars($this->data['userid']).'</p>'; echo '<h2>Your clients</h2>'; echo '<table class="metalist" style="width: 100%">'; @@ -12,7 +14,7 @@ $i = 0; $rows = array('odd', 'even'); foreach ($this->data['entries']['mine'] as $entryc) { $entry = $entryc['value']; - $i++; + $i++; echo '<tr class="'.$rows[$i % 2].'"><td>'. htmlspecialchars($entry['name']).'</td> <td><tt>'.htmlspecialchars($entry['key']). '</tt></td><td><a href="registry.edit.php?editkey='.urlencode($entry['key']). @@ -31,7 +33,7 @@ $i = 0; $rows = array('odd', 'even'); foreach ($this->data['entries']['others'] as $entryc) { $entry = $entryc['value']; - $i++; + $i++; echo '<tr class="'.$rows[$i % 2].'"><td>'. htmlspecialchars($entry['name']).'</td><td><tt>'.htmlspecialchars($entry['key']). '</tt></td><td>'.(isset($entry['owner']) ? htmlspecialchars($entry['owner']) : 'No owner'). @@ -43,4 +45,3 @@ if ($i == 0) { echo '</table>'; $this->includeAtTemplateBase('includes/footer.php'); - diff --git a/modules/oauth/www/assets/css/oauth.css b/modules/oauth/www/assets/css/oauth.css index 4df7a7950..7b8ad7e92 100644 --- a/modules/oauth/www/assets/css/oauth.css +++ b/modules/oauth/www/assets/css/oauth.css @@ -1,39 +1,38 @@ table.formtable { - width: 100%; + width: 100%; } table.formtable tr td.name { - text-align: right; - vertical-align: top; - padding-right: .6em; + text-align: right; + vertical-align: top; + padding-right: .6em; } table.formtable tr td.value { - text-align: left; - padding: 0px; + text-align: left; + padding: 0px; } table.formtable tr td.header { - padding-left: 5px; - padding-top: 8px; - font-weight: bold; - font-size: 110%; + padding-left: 5px; + padding-top: 8px; + font-weight: bold; + font-size: 110%; } table.formtable tr td input,table.formtable tr td textarea { - width: 90%; - border: 1px solid #bbb; - margin: 2px 5px; - padding: 2px 4px; + width: 90%; + border: 1px solid #bbb; + margin: 2px 5px; + padding: 2px 4px; } - table.metalist { - border: 1px solid #aaa; - border-collapse: collapse; + border: 1px solid #aaa; + border-collapse: collapse; } table.metalist tr td { - padding: 2px 5px; + padding: 2px 5px; } table.metalist tr.even td { - background: #e5e5e5; + background: #e5e5e5; } @media all { diff --git a/modules/oauth/www/getUserInfo.php b/modules/oauth/www/getUserInfo.php index d793ed973..ad9f878c8 100644 --- a/modules/oauth/www/getUserInfo.php +++ b/modules/oauth/www/getUserInfo.php @@ -5,7 +5,9 @@ require_once(dirname(dirname(__FILE__)).'/libextinc/OAuth.php'); $oauthconfig = \SimpleSAML\Configuration::getConfig('module_oauth.php'); if (!$oauthconfig->getBoolean('getUserInfo.enable', false)) { - throw new \Exception('Get user info endpoint is disabled. This endpoint can be enabled in the module_oauth.php configuration file.'); + throw new \Exception( + 'Get user info endpoint is disabled. This endpoint can be enabled in the module_oauth.php configuration file.' + ); } $store = new \SimpleSAML\Module\oauth\OAuthStore(); diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php index 053f7737f..b475e0aa9 100644 --- a/modules/oauth/www/registry.edit.php +++ b/modules/oauth/www/registry.edit.php @@ -28,7 +28,9 @@ function requireOwnership($entry, $userid) throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.'); } if ($entry['owner'] !== $userid) { - throw new \Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.'); + throw new \Exception( + 'OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.' + ); } } diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php index 4fbdcd1ed..9f97762ac 100644 --- a/modules/oauth/www/registry.php +++ b/modules/oauth/www/registry.php @@ -1,5 +1,4 @@ <?php - // Load SimpleSAMLphp, configuration and metadata $config = \SimpleSAML\Configuration::getInstance(); $session = \SimpleSAML\Session::getSessionFromRequest(); @@ -28,7 +27,9 @@ function requireOwnership($entry, $userid) throw new \Exception('OAuth Consumer has no owner. Which means no one is granted access, not even you.'); } if ($entry['owner'] !== $userid) { - throw new \Exception('OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.'); + throw new \Exception( + 'OAuth Consumer has an owner that is not equal to your userid, hence you are not granted access.' + ); } } @@ -47,7 +48,8 @@ if (is_array($list)) { foreach ($list as $listitem) { if (array_key_exists('owner', $listitem['value'])) { if ($listitem['value']['owner'] === $userid) { - $slist['mine'][] = $listitem; continue; + $slist['mine'][] = $listitem; + continue; } } } diff --git a/modules/portal/config-templates/module_portal.php b/modules/portal/config-templates/module_portal.php index e390ce250..99cdaf4f9 100644 --- a/modules/portal/config-templates/module_portal.php +++ b/modules/portal/config-templates/module_portal.php @@ -1,5 +1,5 @@ <?php -/* +/* * Configuration for the module portal. */ diff --git a/modules/portal/hooks/hook_htmlinject.php b/modules/portal/hooks/hook_htmlinject.php index 699837c05..5fffdf608 100644 --- a/modules/portal/hooks/hook_htmlinject.php +++ b/modules/portal/hooks/hook_htmlinject.php @@ -36,8 +36,8 @@ function portal_hook_htmlinject(&$hookinfo) $hookinfo['jquery']['css'] = true; // Header - $hookinfo['pre'][] = '<div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all">'. - $portal->getMenu($hookinfo['page']). + $hookinfo['pre'][] = '<div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all">'. + $portal->getMenu($hookinfo['page']). '<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom">'; // Footer diff --git a/modules/portal/lib/Portal.php b/modules/portal/lib/Portal.php index 52d722c11..a27bb343d 100644 --- a/modules/portal/lib/Portal.php +++ b/modules/portal/lib/Portal.php @@ -49,8 +49,8 @@ class Portal $t = new \SimpleSAML\Locale\Translate($config); $tabset = $this->getTabset($thispage); $logininfo = $this->getLoginInfo($t, $thispage); - $text = ''; - $text .= '<ul class="tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">'; + $classes = 'tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all'; + $text = '<ul class="'.$classes.'">'; foreach ($this->pages as $pageid => $page) { if (isset($tabset) && !in_array($pageid, $tabset, true)) { continue; @@ -65,7 +65,7 @@ class Portal if (!isset($page['href'])) { $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">'. $t->t($name).'</a></li>'; - } else if ($pageid === $thispage) { + } elseif ($pageid === $thispage) { $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">'. $t->t($name).'</a></li>'; } else { diff --git a/modules/preprodwarning/templates/warning.php b/modules/preprodwarning/templates/warning.php index 41f2912d8..3d09fa9c3 100644 --- a/modules/preprodwarning/templates/warning.php +++ b/modules/preprodwarning/templates/warning.php @@ -20,22 +20,17 @@ $this->data['header'] = $this->t('{preprodwarning:warning:warning_header}'); $this->data['autofocus'] = 'yesbutton'; $this->includeAtTemplateBase('includes/header.php'); - -?> - -<form style="display: inline; margin: 0px; padding: 0px" action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>"> - -<?php - // Embed hidden fields... - foreach ($this->data['yesData'] as $name => $value) { - echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; - } -?> - <p><?php echo $this->t('{preprodwarning:warning:warning}'); ?></p> - <input type="submit" name="yes" id="yesbutton" value="<?php echo htmlspecialchars($this->t('{preprodwarning:warning:yes}')) ?>" /> - -</form> - -<?php +$yesTarget = htmlspecialchars($this->data['yesTarget']); +$yesWarning = htmlspecialchars($this->t('{preprodwarning:warning:yes}')); +$warning = $this->t('{preprodwarning:warning:warning}'); +echo '<form style="display: inline; margin: 0px; padding: 0px" action="'.$yesTarget.'">'; + +// Embed hidden fields... +foreach ($this->data['yesData'] as $name => $value) { + echo '<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />'; +} +echo '<p>'.$warning.'</p>'; +echo '<input type="submit" name="yes" id="yesbutton" value="'.$yesWarning.'" />'; +echo '</form>'; $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/radius/lib/Auth/Source/Radius.php b/modules/radius/lib/Auth/Source/Radius.php index c37238e82..4709f3bec 100644 --- a/modules/radius/lib/Auth/Source/Radius.php +++ b/modules/radius/lib/Auth/Source/Radius.php @@ -83,8 +83,10 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase parent::__construct($info, $config); // Parse configuration. - $config = \SimpleSAML\Configuration::loadFromArray($config, - 'Authentication source '.var_export($this->authId, true)); + $config = \SimpleSAML\Configuration::loadFromArray( + $config, + 'Authentication source '.var_export($this->authId, true) + ); $this->servers = $config->getArray('servers', array()); // For backwards compatibility @@ -102,7 +104,8 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase $this->retries = $config->getInteger('retries', 3); $this->realm = $config->getString('realm', null); $this->usernameAttribute = $config->getString('username_attribute', null); - $this->nasIdentifier = $config->getString('nas_identifier', + $this->nasIdentifier = $config->getString( + 'nas_identifier', \SimpleSAML\Utils\HTTP::getSelfHost() ); @@ -127,7 +130,7 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase $radius = radius_auth_open(); - /* Try to add all radius servers, trigger a failure if no one works. */ + // Try to add all radius servers, trigger a failure if no one works $success = false; foreach ($this->servers as $server) { if (!isset($server['port'])) { @@ -135,10 +138,14 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase } if (!radius_add_server( $radius, - $server['hostname'], $server['port'], $server['secret'], - $this->timeout, $this->retries)) { - \SimpleSAML\Logger::info("Could not add radius server: ". - radius_strerror($radius) + $server['hostname'], + $server['port'], + $server['secret'], + $this->timeout, + $this->retries + )) { + \SimpleSAML\Logger::info( + "Could not add radius server: ".radius_strerror($radius) ); continue; } @@ -149,8 +156,8 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase } if (!radius_create_request($radius, \RADIUS_ACCESS_REQUEST)) { - throw new \Exception('Error creating radius request: '. - radius_strerror($radius) + throw new \Exception( + 'Error creating radius request: '.radius_strerror($radius) ); } @@ -174,9 +181,9 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase case \RADIUS_ACCESS_CHALLENGE: throw new \Exception('Radius authentication error: Challenge requested, but not supported.'); default: - throw new \Exception('Error during radius authentication: '. - radius_strerror($radius) - ); + throw new \Exception( + 'Error during radius authentication: '.radius_strerror($radius) + ); } } @@ -198,10 +205,9 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase // get AAI attribute sets. Contributed by Stefan Winter, (c) RESTENA while ($resa = radius_get_attr($radius)) { - if (!is_array($resa)) { - throw new \Exception('Error getting radius attributes: '. - radius_strerror($radius) + throw new \Exception( + 'Error getting radius attributes: '.radius_strerror($radius) ); } @@ -217,8 +223,8 @@ class Radius extends \SimpleSAML\Module\core\Auth\UserPassBase $resv = radius_get_vendor_attr($resa['data']); if (!is_array($resv)) { - throw new \Exception('Error getting vendor specific attribute: '. - radius_strerror($radius) + throw new \Exception( + 'Error getting vendor specific attribute: '.radius_strerror($radius) ); } diff --git a/modules/riak/hooks/hook_cron.php b/modules/riak/hooks/hook_cron.php index c7bc7e6f1..c42d2c313 100644 --- a/modules/riak/hooks/hook_cron.php +++ b/modules/riak/hooks/hook_cron.php @@ -41,14 +41,14 @@ function riak_hook_cron(&$croninfo) try { $store = new \SimpleSAML\Module\riak\Store\Store(); - $result = $store->bucket->indexSearch('expires', 'int', - 1, time() - 30); + $result = $store->bucket->indexSearch('expires', 'int', 1, time() - 30); foreach ($result as $link) { $link->getBinary()->delete(); } - \SimpleSAML\Logger::info(sprintf("deleted %s riak key%s", - sizeof($result), sizeof($result) == 1 ? '' : 's')); + \SimpleSAML\Logger::info( + sprintf("deleted %s riak key%s", sizeof($result), sizeof($result) == 1 ? '' : 's') + ); } catch (\Exception $e) { $message = 'riak threw exception: '.$e->getMessage(); \SimpleSAML\Logger::warning($message); diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 25a700781..e1017175b 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -247,13 +247,15 @@ class SP extends Source $IDPList = array(); } - $ar->setIDPList(array_unique( - array_merge( - $this->metadata->getArray('IDPList', array()), - $idpMetadata->getArray('IDPList', array() - ), - (array) $IDPList) - )); + $ar->setIDPList( + array_unique( + array_merge( + $this->metadata->getArray('IDPList', array()), + $idpMetadata->getArray('IDPList', array()), + (array) $IDPList + ) + ) + ); if (isset($state['saml:ProxyCount']) && $state['saml:ProxyCount'] !== null) { $ar->setProxyCount($state['saml:ProxyCount']); @@ -284,19 +286,26 @@ class SP extends Source $id = State::saveState($state, 'saml:sp:sso', true); $ar->setId($id); - \SimpleSAML\Logger::debug('Sending SAML 2 AuthnRequest to '. - var_export($idpMetadata->getString('entityid'), true)); + \SimpleSAML\Logger::debug( + 'Sending SAML 2 AuthnRequest to '.var_export($idpMetadata->getString('entityid'), true) + ); // Select appropriate SSO endpoint if ($ar->getProtocolBinding() === \SAML2\Constants::BINDING_HOK_SSO) { - $dst = $idpMetadata->getDefaultEndpoint('SingleSignOnService', array( - \SAML2\Constants::BINDING_HOK_SSO) + $dst = $idpMetadata->getDefaultEndpoint( + 'SingleSignOnService', + array( + \SAML2\Constants::BINDING_HOK_SSO + ) ); } else { - $dst = $idpMetadata->getEndpointPrioritizedByBinding('SingleSignOnService', [ - \SAML2\Constants::BINDING_HTTP_REDIRECT, - \SAML2\Constants::BINDING_HTTP_POST, - ]); + $dst = $idpMetadata->getEndpointPrioritizedByBinding( + 'SingleSignOnService', + [ + \SAML2\Constants::BINDING_HTTP_REDIRECT, + \SAML2\Constants::BINDING_HTTP_POST, + ] + ); } $ar->setDestination($dst['Location']); @@ -539,8 +548,8 @@ class SP extends Source if (isset($state['isPassive']) && (bool) $state['isPassive']) { // passive request, we cannot authenticate the user throw new \SimpleSAML\Module\saml\Error\NoPassive( - \SAML2\Constants::STATUS_REQUESTER, - 'Reauthentication required' + \SAML2\Constants::STATUS_REQUESTER, + 'Reauthentication required' ); } diff --git a/modules/saml/lib/BaseNameIDGenerator.php b/modules/saml/lib/BaseNameIDGenerator.php index 12115dc37..c5360854e 100644 --- a/modules/saml/lib/BaseNameIDGenerator.php +++ b/modules/saml/lib/BaseNameIDGenerator.php @@ -117,5 +117,4 @@ abstract class BaseNameIDGenerator extends \SimpleSAML\Auth\ProcessingFilter $state['saml:NameID'][$this->format] = $nameId; } - } diff --git a/modules/saml/lib/Error.php b/modules/saml/lib/Error.php index b288ef107..e45b846ff 100644 --- a/modules/saml/lib/Error.php +++ b/modules/saml/lib/Error.php @@ -36,8 +36,10 @@ class Error extends \SimpleSAML\Error\Exception * Create a SAML 2 error. * * @param string $status The top-level status code. - * @param string|null $subStatus The second-level status code. Can be NULL, in which case there is no second-level status code. - * @param string|null $statusMessage The status message. Can be NULL, in which case there is no status message. + * @param string|null $subStatus The second-level status code. + * Can be NULL, in which case there is no second-level status code. + * @param string|null $statusMessage The status message. + * Can be NULL, in which case there is no status message. * @param \Exception|null $cause The cause of this exception. Can be NULL. */ public function __construct($status, $subStatus = null, $statusMessage = null, \Exception $cause = null) @@ -116,7 +118,7 @@ class Error extends \SimpleSAML\Error\Exception \SAML2\Constants::STATUS_NO_PASSIVE, $exception->getMessage(), $exception - ); + ); // TODO: remove this branch in 2.0 } elseif ($exception instanceof \SimpleSAML\Error\ProxyCountExceeded) { $e = new self( @@ -131,7 +133,7 @@ class Error extends \SimpleSAML\Error\Exception null, get_class($exception).': '.$exception->getMessage(), $exception - ); + ); } return $e; @@ -163,7 +165,7 @@ class Error extends \SimpleSAML\Error\Exception ); break; } - break; + break; } if ($e === null) { diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php index a6d8ce0ed..15c3e56ba 100644 --- a/modules/saml/lib/IdP/SAML1.php +++ b/modules/saml/lib/IdP/SAML1.php @@ -27,8 +27,10 @@ class SAML1 $spMetadata = $state["SPMetadata"]; $spEntityId = $spMetadata['entityid']; - $spMetadata = \SimpleSAML\Configuration::loadFromArray($spMetadata, - '$metadata['.var_export($spEntityId, true).']'); + $spMetadata = \SimpleSAML\Configuration::loadFromArray( + $spMetadata, + '$metadata['.var_export($spEntityId, true).']' + ); \SimpleSAML\Logger::info('Sending SAML 1.1 Response to '.var_export($spEntityId, true)); @@ -96,7 +98,9 @@ class SAML1 $target = null; } - \SimpleSAML\Logger::info('Shib1.3 - IdP.SSOService: Got incoming Shib authnRequest from '.var_export($spEntityId, true).'.'); + \SimpleSAML\Logger::info( + 'Shib1.3 - IdP.SSOService: Got incoming Shib authnRequest from '.var_export($spEntityId, true).'.' + ); $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $spMetadata = $metadata->getMetaDataConfig($spEntityId, 'shib13-sp-remote'); @@ -113,18 +117,23 @@ class SAML1 break; } if (!$found) { - throw new \Exception('Invalid AssertionConsumerService for SP '. - var_export($spEntityId, true).': '.var_export($shire, true)); + throw new \Exception( + 'Invalid AssertionConsumerService for SP '.var_export($spEntityId, true).': '.var_export($shire, true) + ); } - \SimpleSAML\Stats::log('saml:idp:AuthnRequest', array( - 'spEntityID' => $spEntityId, - 'protocol' => 'saml1', - )); + \SimpleSAML\Stats::log( + 'saml:idp:AuthnRequest', + array( + 'spEntityID' => $spEntityId, + 'protocol' => 'saml1', + ) + ); $sessionLostURL = HTTP::addURLParameters( HTTP::getSelfURL(), - array('cookieTime' => time())); + array('cookieTime' => time()) + ); $state = array( 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML1', 'sendResponse'), diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 6dae8c4ca..3fde4ad4e 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -414,9 +414,12 @@ class SAML2 ); $state = array( - 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML2', 'sendResponse'), - \SimpleSAML\Auth\State::EXCEPTION_HANDLER_FUNC => array('\SimpleSAML\Module\saml\IdP\SAML2', 'handleAuthError'), - \SimpleSAML\Auth\State::RESTART => $sessionLostURL, + 'Responder' => array('\SimpleSAML\Module\saml\IdP\SAML2', 'sendResponse'), + \SimpleSAML\Auth\State::EXCEPTION_HANDLER_FUNC => array( + '\SimpleSAML\Module\saml\IdP\SAML2', + 'handleAuthError' + ), + \SimpleSAML\Auth\State::RESTART => $sessionLostURL, 'SPMetadata' => $spMetadata->toArray(), 'saml:RelayState' => $relayState, diff --git a/modules/saml/lib/IdP/SQLNameID.php b/modules/saml/lib/IdP/SQLNameID.php index f07ff36e2..0df0a9607 100644 --- a/modules/saml/lib/IdP/SQLNameID.php +++ b/modules/saml/lib/IdP/SQLNameID.php @@ -30,7 +30,8 @@ class SQLNameID )'; $store->pdo->exec($query); - $query = 'CREATE INDEX '.$store->prefix.'_saml_PersistentNameID_idp_sp ON '.$store->prefix.'_saml_PersistentNameID (_idp, _sp)'; + $query = 'CREATE INDEX '.$store->prefix.'_saml_PersistentNameID_idp_sp ON '; + $query .= $store->prefix.'_saml_PersistentNameID (_idp, _sp)'; $store->pdo->exec($query); $store->setTableVersion('saml_PersistentNameID', 1); @@ -48,7 +49,9 @@ class SQLNameID { $store = \SimpleSAML\Store::getInstance(); if (!($store instanceof \SimpleSAML\Store\SQL)) { - throw new \SimpleSAML\Error\Exception('SQL NameID store requires SimpleSAMLphp to be configured with a SQL datastore.'); + throw new \SimpleSAML\Error\Exception( + 'SQL NameID store requires SimpleSAMLphp to be configured with a SQL datastore.' + ); } self::createTable($store); @@ -82,7 +85,8 @@ class SQLNameID '_value' => $value, ); - $query = 'INSERT INTO '.$store->prefix.'_saml_PersistentNameID (_idp, _sp, _user, _value) VALUES(:_idp, :_sp, :_user, :_value)'; + $query = 'INSERT INTO '.$store->prefix; + $query .= '_saml_PersistentNameID (_idp, _sp, _user, _value) VALUES(:_idp, :_sp, :_user, :_value)'; $query = $store->pdo->prepare($query); $query->execute($params); } @@ -110,7 +114,8 @@ class SQLNameID '_user' => $user, ); - $query = 'SELECT _value FROM '.$store->prefix.'_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; + $query = 'SELECT _value FROM '.$store->prefix; + $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; $query = $store->pdo->prepare($query); $query->execute($params); @@ -145,7 +150,8 @@ class SQLNameID '_user' => $user, ); - $query = 'DELETE FROM '.$store->prefix.'_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; + $query = 'DELETE FROM '.$store->prefix; + $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp AND _user = :_user'; $query = $store->pdo->prepare($query); $query->execute($params); } @@ -170,7 +176,8 @@ class SQLNameID '_sp' => $spEntityId, ); - $query = 'SELECT _user, _value FROM '.$store->prefix.'_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp'; + $query = 'SELECT _user, _value FROM '.$store->prefix; + $query .= '_saml_PersistentNameID WHERE _idp = :_idp AND _sp = :_sp'; $query = $store->pdo->prepare($query); $query->execute($params); diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index b3db87991..641c24604 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -25,10 +25,12 @@ class LogoutStore switch ($store->driver) { case 'pgsql': // This does not affect the NOT NULL constraint - $query = 'ALTER TABLE '.$store->prefix.'_saml_LogoutStore ALTER COLUMN _authSource TYPE VARCHAR(255)'; + $query = 'ALTER TABLE '.$store->prefix. + '_saml_LogoutStore ALTER COLUMN _authSource TYPE VARCHAR(255)'; break; default: - $query = 'ALTER TABLE '.$store->prefix.'_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL'; + $query = 'ALTER TABLE '.$store->prefix. + '_saml_LogoutStore MODIFY _authSource VARCHAR(255) NOT NULL'; break; } @@ -52,10 +54,12 @@ class LogoutStore )'; $store->pdo->exec($query); - $query = 'CREATE INDEX '.$store->prefix.'_saml_LogoutStore_expire ON '.$store->prefix.'_saml_LogoutStore (_expire)'; + $query = 'CREATE INDEX '.$store->prefix.'_saml_LogoutStore_expire ON '; + $query .= $store->prefix.'_saml_LogoutStore (_expire)'; $store->pdo->exec($query); - $query = 'CREATE INDEX '.$store->prefix.'_saml_LogoutStore_nameId ON '.$store->prefix.'_saml_LogoutStore (_authSource, _nameId)'; + $query = 'CREATE INDEX '.$store->prefix.'_saml_LogoutStore_nameId ON '; + $query .= $store->prefix.'_saml_LogoutStore (_authSource, _nameId)'; $store->pdo->exec($query); $store->setTableVersion('saml_LogoutStore', 2); @@ -87,8 +91,14 @@ class LogoutStore * @param string $nameId The hash of the users NameID. * @param string $sessionIndex The SessionIndex of the user. */ - private static function addSessionSQL(\SimpleSAML\Store\SQL $store, $authId, $nameId, $sessionIndex, $expire, $sessionId) - { + private static function addSessionSQL( + \SimpleSAML\Store\SQL $store, + $authId, + $nameId, + $sessionIndex, + $expire, + $sessionId + ) { assert(is_string($authId)); assert(is_string($nameId)); assert(is_string($sessionIndex)); @@ -108,7 +118,11 @@ class LogoutStore '_expire' => gmdate('Y-m-d H:i:s', $expire), '_sessionId' => $sessionId, ); - $store->insertOrUpdate($store->prefix.'_saml_LogoutStore', array('_authSource', '_nameId', '_sessionIndex'), $data); + $store->insertOrUpdate( + $store->prefix.'_saml_LogoutStore', + array('_authSource', '_nameId', '_sessionIndex'), + $data + ); } @@ -134,8 +148,8 @@ class LogoutStore ); // We request the columns in lowercase in order to be compatible with PostgreSQL - $query = 'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM '.$store->prefix.'_saml_LogoutStore'. - ' WHERE _authSource = :_authSource AND _nameId = :_nameId AND _expire >= :now'; + $query = 'SELECT _sessionIndex AS _sessionindex, _sessionId AS _sessionid FROM '.$store->prefix; + $query .= '_saml_LogoutStore'.' WHERE _authSource = :_authSource AND _nameId = :_nameId AND _expire >= :now'; $query = $store->pdo->prepare($query); $query->execute($params); @@ -267,7 +281,9 @@ class LogoutStore $sessionIndex = sha1($sessionIndex); } } - unset($sessionIndex); // Remove reference + + // Remove reference + unset($sessionIndex); if ($store instanceof \SimpleSAML\Store\SQL) { $sessions = self::getSessionsSQL($store, $authId, $strNameId); @@ -277,7 +293,6 @@ class LogoutStore } else { /** @var \SimpleSAML\Store $sessions At this point the store cannot be false */ $sessions = self::getSessionsStore($store, $authId, $strNameId, $sessionIndexes); - } if (empty($sessionIndexes)) { @@ -300,11 +315,15 @@ class LogoutStore } if (!$session->isValid($authId)) { - \SimpleSAML\Logger::info('saml.LogoutStore: Skipping logout of session because it isn\'t authenticated.'); + \SimpleSAML\Logger::info( + 'saml.LogoutStore: Skipping logout of session because it isn\'t authenticated.' + ); continue; } - \SimpleSAML\Logger::info('saml.LogoutStore: Logging out of session with trackId ['.$session->getTrackID().'].'); + \SimpleSAML\Logger::info( + 'saml.LogoutStore: Logging out of session with trackId ['.$session->getTrackID().'].' + ); $session->doLogout($authId); $numLoggedOut += 1; } diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php index 7ed92b3c3..abc914092 100644 --- a/modules/saml/www/sp/metadata.php +++ b/modules/saml/www/sp/metadata.php @@ -15,8 +15,10 @@ if ($source === null) { } if (!($source instanceof \SimpleSAML\Module\saml\Auth\Source\SP)) { - throw new \SimpleSAML\Error\AuthSource($sourceId, - 'The authentication source is not a SAML Service Provider.'); + throw new \SimpleSAML\Error\AuthSource( + $sourceId, + 'The authentication source is not a SAML Service Provider.' + ); } $entityId = $source->getEntityId(); @@ -61,7 +63,6 @@ $index = 0; $eps = array(); $supported_protocols = array(); foreach ($assertionsconsumerservices as $services) { - $acsArray = array('index' => $index); switch ($services) { case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST': @@ -260,7 +261,6 @@ if (isset($metaArray20['attributes']) && is_array($metaArray20['attributes'])) { $xml = \SimpleSAML\Metadata\Signer::sign($xml, $spconfig->toArray(), 'SAML 2 SP'); if (array_key_exists('output', $_REQUEST) && $_REQUEST['output'] == 'xhtml') { - $t = new \SimpleSAML\XHTML\Template($config, 'metadata.php', 'admin'); $t->data['clipboard.js'] = true; diff --git a/modules/saml/www/sp/saml1-acs.php b/modules/saml/www/sp/saml1-acs.php index c6be5c701..66392f4ce 100644 --- a/modules/saml/www/sp/saml1-acs.php +++ b/modules/saml/www/sp/saml1-acs.php @@ -37,10 +37,12 @@ if (preg_match('@^https?://@i', $target)) { } else { $state = \SimpleSAML\Auth\State::loadState($_REQUEST['TARGET'], 'saml:sp:sso'); - // Check that the authentication source is correct. + // Check that the authentication source is correct assert(array_key_exists('saml:sp:AuthId', $state)); if ($state['saml:sp:AuthId'] !== $sourceId) { - throw new \SimpleSAML\Error\Exception('The authentication source id in the URL does not match the authentication source which sent the request.'); + throw new \SimpleSAML\Error\Exception( + 'The authentication source id in the URL does not match the authentication source which sent the request.' + ); } assert(isset($state['saml:idp'])); @@ -50,8 +52,10 @@ $spMetadata = $source->getMetadata(); if (array_key_exists('SAMLart', $_REQUEST)) { if (!isset($state['saml:idp'])) { - /* Unsolicited response. */ - throw new \SimpleSAML\Error\Exception('IdP initiated authentication not supported with the SAML 1.1 SAMLart protocol.'); + // Unsolicited response + throw new \SimpleSAML\Error\Exception( + 'IdP initiated authentication not supported with the SAML 1.1 SAMLart protocol.' + ); } $idpMetadata = $source->getIdPMetadata($state['saml:idp']); diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php index 859c28783..75504252d 100644 --- a/modules/saml/www/sp/saml2-acs.php +++ b/modules/saml/www/sp/saml2-acs.php @@ -143,7 +143,6 @@ $expire = null; $attributes = array(); $foundAuthnStatement = false; foreach ($assertions as $assertion) { - // check for duplicate assertion (replay attack) $store = \SimpleSAML\Store::getInstance(); if ($store !== false) { diff --git a/modules/saml/www/sp/saml2-logout.php b/modules/saml/www/sp/saml2-logout.php index 8b9cc250f..710966efd 100644 --- a/modules/saml/www/sp/saml2-logout.php +++ b/modules/saml/www/sp/saml2-logout.php @@ -54,7 +54,6 @@ if ($destination !== null && $destination !== \SimpleSAML\Utils\HTTP::getSelfURL } if ($message instanceof \SAML2\LogoutResponse) { - $relayState = $message->getRelayState(); if ($relayState === null) { // Somehow, our RelayState has been lost. @@ -62,15 +61,15 @@ if ($message instanceof \SAML2\LogoutResponse) { } if (!$message->isSuccess()) { - \SimpleSAML\Logger::warning('Unsuccessful logout. Status was: '.\SimpleSAML\Module\saml\Message::getResponseError($message)); + \SimpleSAML\Logger::warning( + 'Unsuccessful logout. Status was: '.\SimpleSAML\Module\saml\Message::getResponseError($message) + ); } $state = \SimpleSAML\Auth\State::loadState($relayState, 'saml:slosent'); $state['saml:sp:LogoutStatus'] = $message->getStatus(); \SimpleSAML\Auth\Source::completeLogout($state); - } elseif ($message instanceof \SAML2\LogoutRequest) { - \SimpleSAML\Logger::debug('module/saml2/sp/logout: Request from '.$idpEntityId); \SimpleSAML\Logger::stats('saml20-idp-SLO idpinit '.$spEntityId.' '.$idpEntityId); @@ -119,9 +118,12 @@ if ($message instanceof \SAML2\LogoutResponse) { \SimpleSAML\Logger::warning('Logged out of '.$numLoggedOut.' of '.count($sessionIndexes).' sessions.'); } - $dst = $idpMetadata->getEndpointPrioritizedByBinding('SingleLogoutService', array( - \SAML2\Constants::BINDING_HTTP_REDIRECT, - \SAML2\Constants::BINDING_HTTP_POST) + $dst = $idpMetadata->getEndpointPrioritizedByBinding( + 'SingleLogoutService', + array( + \SAML2\Constants::BINDING_HTTP_REDIRECT, + \SAML2\Constants::BINDING_HTTP_POST + ) ); if (!$binding instanceof \SAML2\SOAP) { diff --git a/modules/sanitycheck/config-templates/config-sanitycheck.php b/modules/sanitycheck/config-templates/config-sanitycheck.php index 7ba3199e3..543ebbba9 100644 --- a/modules/sanitycheck/config-templates/config-sanitycheck.php +++ b/modules/sanitycheck/config-templates/config-sanitycheck.php @@ -1,5 +1,5 @@ <?php -/* +/* * The configuration of SimpleSAMLphp sanitycheck package */ diff --git a/modules/sanitycheck/hooks/hook_cron.php b/modules/sanitycheck/hooks/hook_cron.php index ae85a1a20..dcea2adef 100644 --- a/modules/sanitycheck/hooks/hook_cron.php +++ b/modules/sanitycheck/hooks/hook_cron.php @@ -35,7 +35,6 @@ function sanitycheck_hook_cron(&$croninfo) $croninfo['summary'][] = 'Sanitycheck error: '.$err; } } - } catch (Exception $e) { $croninfo['summary'][] = 'Error executing sanity check: '.$e->getMessage(); } diff --git a/modules/sanitycheck/templates/check.tpl.php b/modules/sanitycheck/templates/check.tpl.php index cf34bff61..ba9f69ada 100644 --- a/modules/sanitycheck/templates/check.tpl.php +++ b/modules/sanitycheck/templates/check.tpl.php @@ -2,44 +2,28 @@ $this->data['header'] = 'Sanity check'; $this->includeAtTemplateBase('includes/header.php'); -?> - -<h2><?php echo($this->data['header']); ?></h2> - -<?php +echo '<h2>'.$this->data['header'].'</h2>'; if (count($this->data['errors']) > 0) { -?> -<div style="border: 1px solid #800; background: #caa; margin: 1em; padding: .5em"> -<p><?php echo '<img class="float-r" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/delete.png" alt="Failed" />'; ?> -These checks failed:</p> -<?php - - echo '<ul>'; - foreach ($this->data['errors'] AS $err) { - echo '<li>' . $err . '</li>'; - } - echo '</ul>'; - -echo '</div>'; + echo '<div style="border: 1px solid #800; background: #caa; margin: 1em; padding: .5em">'; + echo '<p><img class="float-r" src="/'.$this->data['baseurlpath']. + 'resources/icons/silk/delete.png" alt="Failed" />These checks failed:</p>'; + echo '<ul>'; + foreach ($this->data['errors'] as $err) { + echo '<li>'.$err.'</li>'; + } } ?> - + </ul> +</div> <?php if (count($this->data['info']) > 0) { -?> -<div style="border: 1px solid #ccc; background: #eee; margin: 1em; padding: .5em"> -<p><?php echo '<img class="float-r" src="/' . $this->data['baseurlpath'] . 'resources/icons/silk/accept.png" alt="OK" />'; ?> -These checks succeeded:</p> -<?php - echo '<ul>'; - foreach ($this->data['info'] AS $i) { - echo '<li>' . $i . '</li>'; - } - echo '</ul>'; - - -echo '</div>'; + echo '<div style="border: 1px solid #ccc; background: #eee; margin: 1em; padding: .5em">'; + echo '<p><img class="float-r" src="/'.$this->data['baseurlpath']. + 'resources/icons/silk/accept.png" alt="OK" />These checks succeeded:</p>'; + echo '<ul>'; + foreach ($this->data['info'] as $i) { + echo '<li>'.$i.'</li>'; + } } -?> - -<?php $this->includeAtTemplateBase('includes/footer.php'); ?> \ No newline at end of file +echo '</ul></div>'; +$this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/sanitycheck/www/index.php b/modules/sanitycheck/www/index.php index d7302529e..ccfd7daec 100644 --- a/modules/sanitycheck/www/index.php +++ b/modules/sanitycheck/www/index.php @@ -11,7 +11,6 @@ $hookinfo = array( \SimpleSAML\Module::callHooks('sanitycheck', $hookinfo); if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'text') { - if (count($errors) === 0) { echo 'OK'; } else { diff --git a/modules/smartattributes/lib/Auth/Process/SmartID.php b/modules/smartattributes/lib/Auth/Process/SmartID.php index 2dbde82f9..ed94d4cd3 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartID.php +++ b/modules/smartattributes/lib/Auth/Process/SmartID.php @@ -11,7 +11,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter * 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. */ - private $_candidates = array( + private $candidates = array( 'eduPersonTargetedID', 'eduPersonPrincipalName', 'openid', @@ -24,18 +24,18 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter /** * The name of the generated ID attribute. */ - private $_id_attribute = 'smart_id'; + private $id_attribute = 'smart_id'; /** * Whether to append the AuthenticatingAuthority, separated by '!' * This only works when SSP is used as a gateway. */ - private $_add_authority = true; + private $add_authority = true; /** * Whether to prepend the CandidateID, separated by ':' */ - private $_add_candidate = true; + private $add_candidate = true; /** * Attributes which should be added/appended. @@ -52,29 +52,29 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter assert(is_array($config)); if (array_key_exists('candidates', $config)) { - $this->_candidates = $config['candidates']; - if (!is_array($this->_candidates)) { + $this->candidates = $config['candidates']; + if (!is_array($this->candidates)) { throw new \Exception('SmartID authproc configuration error: \'candidates\' should be an array.'); } } if (array_key_exists('id_attribute', $config)) { - $this->_id_attribute = $config['id_attribute']; - if (!is_string($this->_id_attribute)) { + $this->id_attribute = $config['id_attribute']; + if (!is_string($this->id_attribute)) { throw new \Exception('SmartID authproc configuration error: \'id_attribute\' should be a string.'); } } if (array_key_exists('add_authority', $config)) { - $this->_add_authority = $config['add_authority']; - if (!is_bool($this->_add_authority)) { + $this->add_authority = $config['add_authority']; + if (!is_bool($this->add_authority)) { throw new \Exception('SmartID authproc configuration error: \'add_authority\' should be a boolean.'); } } if (array_key_exists('add_candidate', $config)) { - $this->_add_candidate = $config['add_candidate']; - if (!is_bool($this->_add_candidate)) { + $this->add_candidate = $config['add_candidate']; + if (!is_bool($this->add_candidate)) { throw new \Exception('SmartID authproc configuration error: \'add_candidate\' should be a boolean.'); } } @@ -83,12 +83,13 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter private function addID($attributes, $request) { $state = $request['saml:sp:State']; - foreach ($this->_candidates as $idCandidate) { + foreach ($this->candidates as $idCandidate) { if (isset($attributes[$idCandidate][0])) { - if (($this->_add_authority) && (isset($state['saml:AuthenticatingAuthority'][0]))) { - return ($this->_add_candidate ? $idCandidate.':' : '').$attributes[$idCandidate][0].'!'.$state['saml:AuthenticatingAuthority'][0]; + if (($this->add_authority) && (isset($state['saml:AuthenticatingAuthority'][0]))) { + return ($this->add_candidate ? $idCandidate.':' : '').$attributes[$idCandidate][0].'!'. + $state['saml:AuthenticatingAuthority'][0]; } else { - return ($this->_add_candidate ? $idCandidate.':' : '').$attributes[$idCandidate][0]; + return ($this->add_candidate ? $idCandidate.':' : '').$attributes[$idCandidate][0]; } } } @@ -96,7 +97,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter * At this stage no usable id_candidate has been detected. */ throw new \SimpleSAML\Error\Exception('This service needs at least one of the following - attributes to identity users: '.implode(', ', $this->_candidates).'. Unfortunately not + attributes to identity users: '.implode(', ', $this->candidates).'. Unfortunately not one of them was detected. Please ask your institution administrator to release one of them, or try using another identity provider.'); } @@ -116,7 +117,7 @@ class SmartID extends \SimpleSAML\Auth\ProcessingFilter $id = $this->addID($request['Attributes'], $request); if (isset($id)) { - $request['Attributes'][$this->_id_attribute] = array($id); + $request['Attributes'][$this->id_attribute] = array($id); } } } diff --git a/modules/smartattributes/lib/Auth/Process/SmartName.php b/modules/smartattributes/lib/Auth/Process/SmartName.php index 388ffe5c3..4ed5af036 100644 --- a/modules/smartattributes/lib/Auth/Process/SmartName.php +++ b/modules/smartattributes/lib/Auth/Process/SmartName.php @@ -52,7 +52,7 @@ class SmartName extends \SimpleSAML\Auth\ProcessingFilter if (isset($localname)) { return $localname; } - } + } return null; } diff --git a/modules/sqlauth/lib/Auth/Source/SQL.php b/modules/sqlauth/lib/Auth/Source/SQL.php index f968dbc9c..2ec835f9a 100644 --- a/modules/sqlauth/lib/Auth/Source/SQL.php +++ b/modules/sqlauth/lib/Auth/Source/SQL.php @@ -172,7 +172,6 @@ class SQL extends \SimpleSAML\Module\core\Auth\UserPassBase $attributes = array(); foreach ($data as $row) { foreach ($row as $name => $value) { - if ($value === null) { continue; } diff --git a/modules/statistics/bin/loganalyzer.php b/modules/statistics/bin/loganalyzer.php index 52f5842ea..0f0f7bfbf 100755 --- a/modules/statistics/bin/loganalyzer.php +++ b/modules/statistics/bin/loganalyzer.php @@ -85,6 +85,4 @@ Options: -d, --debug Used when configuring the log file syntax. See doc. --dry-run Aggregate but do not store the results. END; - } - diff --git a/modules/statistics/bin/logcleaner.php b/modules/statistics/bin/logcleaner.php index 071318124..440780d02 100755 --- a/modules/statistics/bin/logcleaner.php +++ b/modules/statistics/bin/logcleaner.php @@ -90,4 +90,3 @@ Options: END; } - diff --git a/modules/statistics/config-templates/module_statistics.php b/modules/statistics/config-templates/module_statistics.php index 16a21cdd1..eb582159f 100644 --- a/modules/statistics/config-templates/module_statistics.php +++ b/modules/statistics/config-templates/module_statistics.php @@ -1,5 +1,5 @@ <?php -/* +/* * The configuration of SimpleSAMLphp statistics package */ @@ -24,19 +24,19 @@ $config = array( 'statdir' => '/tmp/stats/', 'inputfile' => '/var/log/simplesamlphp.stat', 'offset' => 60 * 60 * 2 + 60 * 60 * 24 * 3, // Two hours offset to match epoch and norwegian winter time. - + 'datestart' => 1, 'datelength' => 15, 'offsetspan' => 21, - + // Dimensions on graph from Google Charts in pixels... 'dimension.x' => 800, 'dimension.y' => 350, - + /* * Do you want to generate statistics using the cron module? If so, specify which cron tag to use. * Examples: daily, weekly - * To not run statistics in cron, set value to + * To not run statistics in cron, set value to * 'cron_tag' => null, */ 'cron_tag' => 'daily', @@ -48,31 +48,31 @@ $config = array( * CGI timeout function. Both default to 300 seconds. */ 'time_limit' => 300, - + 'timeres' => array( 'day' => array( 'name' => 'Day', 'slot' => 60 * 15, // Slots of 15 minutes 'fileslot' => 60 * 60 * 24, // One day (24 hours) file slots - 'axislabelint' => 6 * 4, // Number of slots per label. 4 per hour *6 = 6 hours - 'dateformat-period' => 'j. M', // 4. Mars - 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 + 'axislabelint' => 6 * 4, // Number of slots per label. 4 per hour *6 = 6 hours + 'dateformat-period' => 'j. M', // 4. Mars + 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 ), 'week' => array( 'name' => 'Week', 'slot' => 60 * 60, // Slots of one hour 'fileslot' => 60 * 60 * 24 * 7, // 7 days of data in each file 'axislabelint' => 24, // Number of slots per label. 24 is one each day - 'dateformat-period' => 'j. M', // 4. Mars - 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 + 'dateformat-period' => 'j. M', // 4. Mars + 'dateformat-intra' => 'j. M H:i', // 4. Mars 12:30 ), 'month' => array( 'name' => 'Month', 'slot' => 60 * 60 * 24, // Slots of one day 'fileslot' => 60 * 60 * 24 * 30, // 30 days of data in each file 'axislabelint' => 7, // Number of slots per label. 7 days => 1 week - 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 - 'dateformat-intra' => 'j. M', // 4. Mars + 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 + 'dateformat-intra' => 'j. M', // 4. Mars ), 'monthaligned' => array( 'name' => 'AlignedMonth', @@ -80,8 +80,8 @@ $config = array( 'fileslot' => null, // 30 days of data in each file 'customDateHandler' => 'month', 'axislabelint' => 7, // Number of slots per label. 7 days => 1 week - 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 - 'dateformat-intra' => 'j. M', // 4. Mars + 'dateformat-period' => 'j. M Y H:i', // 4. Mars 12:30 + 'dateformat-intra' => 'j. M', // 4. Mars ), 'days180' => array( 'name' => '180 days', @@ -96,7 +96,8 @@ $config = array( 'statrules' => array( 'sloratio' => array( 'name' => 'SLO to SSO ratio', - 'descr' => 'Comparison of the number of Single Log-Out compared to Single Sign-On. Graph shows how many logouts where initiated for each Single Sign-On.', + 'descr' => 'Comparison of the number of Single Log-Out compared to Single Sign-On.'. + ' Graph shows how many logouts where initiated for each Single Sign-On.', 'type' => 'calculated', 'presenter' => 'statistics:Ratio', 'ref' => array('slo', 'sso'), @@ -107,7 +108,8 @@ $config = array( ), 'ssomulti' => array( 'name' => 'Requests per session', - 'descr' => 'Number of SSO request pairs exchanged between IdP and SP within the same IdP session. A high number indicates that the session at the SP is timing out faster than at the IdP.', + 'descr' => 'Number of SSO request pairs exchanged between IdP and SP within the same IdP session.'. + ' A high number indicates that the session at the SP is timing out faster than at the IdP.', 'type' => 'calculated', 'presenter' => 'statistics:Ratio', 'ref' => array('sso', 'ssofirst'), @@ -148,7 +150,8 @@ $config = array( ), 'consent' => array( 'name' => 'Consent', - 'descr' => 'Consent statistics. Everytime a user logs in to a service an entry is logged for one of three states: consent was found, consent was not found or consent storage was not available.', + 'descr' => 'Consent statistics. Everytime a user logs in to a service an entry is logged for'. + ' one of three states: consent was found, consent was not found or consent storage was not available.', 'action' => 'consent', 'col' => 6, 'fieldPresentation' => array( @@ -158,7 +161,8 @@ $config = array( ), 'consentresponse' => array( 'name' => 'Consent response', - 'descr' => 'Consent response statistics. Everytime a user accepts consent, it is logged whether the user selected to remember the consent to next time.', + 'descr' => 'Consent response statistics. Everytime a user accepts consent,'. + ' it is logged whether the user selected to remember the consent to next time.', 'action' => 'consentResponse', 'col' => 6, 'fieldPresentation' => array( diff --git a/modules/statistics/hooks/hook_cron.php b/modules/statistics/hooks/hook_cron.php index b86b480d3..a3ee4952c 100644 --- a/modules/statistics/hooks/hook_cron.php +++ b/modules/statistics/hooks/hook_cron.php @@ -13,19 +13,19 @@ function statistics_hook_cron(&$croninfo) assert(array_key_exists('tag', $croninfo)); $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php'); - + if (is_null($statconfig->getValue('cron_tag', null))) { return; } if ($statconfig->getValue('cron_tag', null) !== $croninfo['tag']) { return; } - + $maxtime = $statconfig->getInteger('time_limit', null); if ($maxtime) { set_time_limit($maxtime); } - + try { $aggregator = new \SimpleSAML\Module\statistics\Aggregator(); $results = $aggregator->aggregate(); diff --git a/modules/statistics/hooks/hook_sanitycheck.php b/modules/statistics/hooks/hook_sanitycheck.php index 85117477c..879ee3ee7 100644 --- a/modules/statistics/hooks/hook_sanitycheck.php +++ b/modules/statistics/hooks/hook_sanitycheck.php @@ -13,7 +13,8 @@ function statistics_hook_sanitycheck(&$hookinfo) try { $statconfig = \SimpleSAML\Configuration::getConfig('module_statistics.php'); } catch (Exception $e) { - $hookinfo['errors'][] = '[statistics] Could not get configuration: '.$e->getMessage(); return; + $hookinfo['errors'][] = '[statistics] Could not get configuration: '.$e->getMessage(); + return; } $statdir = $statconfig->getValue('statdir'); diff --git a/modules/statistics/lib/AccessCheck.php b/modules/statistics/lib/AccessCheck.php index a4a003abb..750a5d052 100644 --- a/modules/statistics/lib/AccessCheck.php +++ b/modules/statistics/lib/AccessCheck.php @@ -61,10 +61,14 @@ class AccessCheck // Check if userid is allowed access.. if (in_array($attributes[$useridattr][0], $allowedusers, true)) { - \SimpleSAML\Logger::debug('Statistics auth - User granted access by user ID ['.$attributes[$useridattr][0].']'); + \SimpleSAML\Logger::debug( + 'Statistics auth - User granted access by user ID ['.$attributes[$useridattr][0].']' + ); return; } - \SimpleSAML\Logger::debug('Statistics auth - User denied access by user ID ['.$attributes[$useridattr][0].']'); + \SimpleSAML\Logger::debug( + 'Statistics auth - User denied access by user ID ['.$attributes[$useridattr][0].']' + ); } else { \SimpleSAML\Logger::debug('Statistics auth - no allowedUsers list.'); } diff --git a/modules/statistics/lib/Aggregator.php b/modules/statistics/lib/Aggregator.php index 9a022e341..dbdba27e6 100644 --- a/modules/statistics/lib/Aggregator.php +++ b/modules/statistics/lib/Aggregator.php @@ -93,7 +93,9 @@ class Aggregator } $logparser = new LogParser( - $this->statconfig->getValue('datestart', 0), $this->statconfig->getValue('datelength', 15), $this->statconfig->getValue('offsetspan', 44) + $this->statconfig->getValue('datestart', 0), + $this->statconfig->getValue('datelength', 15), + $this->statconfig->getValue('offsetspan', 44) ); $datehandler = array( 'default' => new DateHandler($this->offset), @@ -109,7 +111,7 @@ class Aggregator $lastlinehash = $this->metadata['lastlinehash']; } - $lastlogline = 'sdfsdf'; + $lastlogline = 'sdfsdf'; $lastlineflip = false; $results = array(); @@ -138,7 +140,8 @@ class Aggregator if ($debug) { echo "----------------------------------------\n"; echo 'Log line: '.$logline."\n"; - echo 'Date parse ['.substr($logline, 0, $this->statconfig->getValue('datelength', 15)).'] to ['.date(DATE_RFC822, $epoch).']'."\n"; + echo 'Date parse ['.substr($logline, 0, $this->statconfig->getValue('datelength', 15)). + '] to ['.date(DATE_RFC822, $epoch).']'."\n"; echo htmlentities(print_r($content, true)); if ($i >= 13) { exit; @@ -270,11 +273,11 @@ class Aggregator // Get start and end slot number within the file, based on the fileslot. $start = (int) $datehandler['default']->toSlot( - $datehandler[$dh]->fromSlot($fileno, $this->timeres[$tres]['fileslot']), + $datehandler[$dh]->fromSlot($fileno, $this->timeres[$tres]['fileslot']), $this->timeres[$tres]['slot'] ); $end = (int) $datehandler['default']->toSlot( - $datehandler[$dh]->fromSlot($fileno + 1, $this->timeres[$tres]['fileslot']), + $datehandler[$dh]->fromSlot($fileno + 1, $this->timeres[$tres]['fileslot']), $this->timeres[$tres]['slot'] ); @@ -295,7 +298,7 @@ class Aggregator $filename = $this->statdir.'/'.$rulename.'-'.$tres.'-'.$fileno.'.stat'; if (file_exists($filename)) { $previousData = unserialize(file_get_contents($filename)); - $filledresult = $this->cummulateData($previousData, $filledresult); + $filledresult = $this->cummulateData($previousData, $filledresult); } // store file diff --git a/modules/statistics/lib/DateHandler.php b/modules/statistics/lib/DateHandler.php index b62cfb624..ae9807df9 100644 --- a/modules/statistics/lib/DateHandler.php +++ b/modules/statistics/lib/DateHandler.php @@ -14,7 +14,7 @@ class DateHandler /** * Constructor * - * @param array $offset Date offset + * @param array $offset Date offset */ public function __construct($offset) { diff --git a/modules/statistics/lib/DateHandlerMonth.php b/modules/statistics/lib/DateHandlerMonth.php index 78209d03e..061af6e62 100644 --- a/modules/statistics/lib/DateHandlerMonth.php +++ b/modules/statistics/lib/DateHandlerMonth.php @@ -12,7 +12,7 @@ class DateHandlerMonth extends DateHandler /** * Constructor * - * @param integer $offset Date offset + * @param integer $offset Date offset */ public function __construct($offset) { diff --git a/modules/statistics/lib/Graph/GoogleCharts.php b/modules/statistics/lib/Graph/GoogleCharts.php index 072ef33b7..087dffcb2 100644 --- a/modules/statistics/lib/Graph/GoogleCharts.php +++ b/modules/statistics/lib/Graph/GoogleCharts.php @@ -4,7 +4,7 @@ namespace SimpleSAML\Module\statistics\Graph; /* * \SimpleSAML\Module\statistics\Graph\GoogleCharts will help you to create a Google Chart - * using the Google Charts API. + * using the Google Charts API. * * @author Andreas Ă…kre Solberg <andreas.solberg@uninett.no> * @package SimpleSAMLphp @@ -64,15 +64,15 @@ class GoogleCharts $second = substr($extended_table, intval(($delta * $v / 100) % $size), 1); $chardata .= "$first$second"; } else { - $chardata .= '__'; // Value out of max range; - } + $chardata .= '__'; // Value out of max range; + } } - return $chardata; + return $chardata; } /** * Generate a Google Charts URL which points to a generated image. - * More documentation on Google Charts here: + * More documentation on Google Charts here: * http://code.google.com/apis/chart/ * * @param string $axis Axis @@ -137,12 +137,14 @@ class GoogleCharts * * Here is some test code: * <code> - * $foo = array(0, 2, 2.3, 2.6, 6, 10, 15, 98, 198, 256, 487, 563, 763, 801, 899, 999, 987, 198234.485, 283746); - * foreach ($foo AS $f) { - * echo '<p>' . $f . ' => ' . \SimpleSAML\Module\statistics\Graph\GoogleCharts::roof($f); - * } + * $foo = array( + * 0, 2, 2.3, 2.6, 6, 10, 15, 98, 198, 256, 487, 563, 763, 801, 899, 999, 987, 198234.485, 283746 + * ); + * foreach ($foo as $f) { + * echo '<p>'.$f.' => '.\SimpleSAML\Module\statistics\Graph\GoogleCharts::roof($f); + * } * </code> - * + * * @param integer $max Input value. */ public static function roof($max) diff --git a/modules/statistics/lib/LogCleaner.php b/modules/statistics/lib/LogCleaner.php index d04204df9..ac172a28e 100644 --- a/modules/statistics/lib/LogCleaner.php +++ b/modules/statistics/lib/LogCleaner.php @@ -60,7 +60,9 @@ class LogCleaner $file = fopen($this->inputfile, 'r'); $logparser = new LogParser( - $this->statconfig->getValue('datestart', 0), $this->statconfig->getValue('datelength', 15), $this->statconfig->getValue('offsetspan', 44) + $this->statconfig->getValue('datestart', 0), + $this->statconfig->getValue('datelength', 15), + $this->statconfig->getValue('offsetspan', 44) ); $sessioncounter = array(); @@ -94,7 +96,8 @@ class LogCleaner if ($debug) { echo "----------------------------------------\n"; echo 'Log line: '.$logline."\n"; - echo 'Date parse ['.substr($logline, 0, $this->statconfig->getValue('datelength', 15)).'] to ['.date(DATE_RFC822, $epoch).']'."\n"; + echo 'Date parse ['.substr($logline, 0, $this->statconfig->getValue('datelength', 15)). + '] to ['.date(DATE_RFC822, $epoch).']'."\n"; echo htmlentities(print_r($content, true)); if ($i >= 13) { exit; @@ -149,7 +152,9 @@ class LogCleaner $outfile = fopen($outputfile, 'x'); // Create the output file $logparser = new LogParser( - $this->statconfig->getValue('datestart', 0), $this->statconfig->getValue('datelength', 15), $this->statconfig->getValue('offsetspan', 44) + $this->statconfig->getValue('datestart', 0), + $this->statconfig->getValue('datelength', 15), + $this->statconfig->getValue('offsetspan', 44) ); $i = 0; diff --git a/modules/statistics/lib/RatioDataset.php b/modules/statistics/lib/RatioDataset.php index fcb7377fd..0abd90416 100644 --- a/modules/statistics/lib/RatioDataset.php +++ b/modules/statistics/lib/RatioDataset.php @@ -14,7 +14,7 @@ class RatioDataset extends StatDataset /** * Aggregate summary table from dataset. To be used in the table view. */ - $this->summary = array(); + $this->summary = array(); $noofvalues = array(); foreach ($this->results as $slot => $res) { foreach ($res as $key => $value) { @@ -65,7 +65,7 @@ class RatioDataset extends StatDataset foreach ($result2 as $tick => $val) { $combined[$tick] = array(); foreach ($val as $index => $num) { - $combined[$tick][$index] = $this->divide( + $combined[$tick][$index] = $this->divide( $this->ag($index, $result1[$tick]), $this->ag($index, $result2[$tick]) ); @@ -79,4 +79,3 @@ class RatioDataset extends StatDataset return null; } } - diff --git a/modules/statistics/lib/Ruleset.php b/modules/statistics/lib/Ruleset.php index d94ee7c03..5b7b85d94 100644 --- a/modules/statistics/lib/Ruleset.php +++ b/modules/statistics/lib/Ruleset.php @@ -91,9 +91,11 @@ class Ruleset $statrulesConfig = $this->statconfig->getConfigItem('statrules'); $statruleConfig = $statrulesConfig->getConfigItem($rule); - $presenterClass = \SimpleSAML\Module::resolveClass($statruleConfig->getValue('presenter', 'statistics:BaseRule'), 'Statistics_Rulesets'); + $presenterClass = \SimpleSAML\Module::resolveClass( + $statruleConfig->getValue('presenter', 'statistics:BaseRule'), + 'Statistics_Rulesets' + ); $statrule = new $presenterClass($this->statconfig, $statruleConfig, $rule, $this->available); return $statrule; } } - diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php index 7d890848c..cc8fed149 100644 --- a/modules/statistics/lib/StatDataset.php +++ b/modules/statistics/lib/StatDataset.php @@ -306,4 +306,3 @@ class StatDataset $this->results = $combined; } } - diff --git a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php index 5ceca8590..469bec780 100644 --- a/modules/statistics/lib/Statistics/Rulesets/BaseRule.php +++ b/modules/statistics/lib/Statistics/Rulesets/BaseRule.php @@ -27,7 +27,7 @@ class BaseRule $this->available = null; if (array_key_exists($ruleid, $available)) { - $this->available = $available[$ruleid]; + $this->available = $available[$ruleid]; } } @@ -39,7 +39,7 @@ class BaseRule public function availableTimeRes() { $timeresConfigs = $this->statconfig->getValue('timeres'); - $available_times = array(); + $available_times = array(); foreach ($timeresConfigs as $tres => $tresconfig) { if (array_key_exists($tres, $this->available)) { $available_times[$tres] = $tresconfig['name']; @@ -62,9 +62,14 @@ class BaseRule /* * Get list of avaiable times in current file (rule) */ - $available_times = array(); + $available_times = array(); foreach ($this->available[$timeres] as $slot) { - $available_times[$slot] = $datehandler->prettyHeader($slot, $slot + 1, $timeresConfig['fileslot'], $timeresConfig['dateformat-period']); + $available_times[$slot] = $datehandler->prettyHeader( + $slot, + $slot + 1, + $timeresConfig['fileslot'], + $timeresConfig['dateformat-period'] + ); } return $available_times; } @@ -117,8 +122,13 @@ class BaseRule { $timeres = $this->resolveTimeRes($preferTimeRes); $fileslot = $this->resolveFileSlot($timeres, $preferTime); - $dataset = new \SimpleSAML\Module\statistics\StatDataset($this->statconfig, $this->ruleconfig, $this->ruleid, $timeres, $fileslot); + $dataset = new \SimpleSAML\Module\statistics\StatDataset( + $this->statconfig, + $this->ruleconfig, + $this->ruleid, + $timeres, + $fileslot + ); return $dataset; } } - diff --git a/modules/statistics/lib/Statistics/Rulesets/Ratio.php b/modules/statistics/lib/Statistics/Rulesets/Ratio.php index 89d9f1c78..1f76f6b47 100644 --- a/modules/statistics/lib/Statistics/Rulesets/Ratio.php +++ b/modules/statistics/lib/Statistics/Rulesets/Ratio.php @@ -65,8 +65,13 @@ class Ratio extends BaseRule $refNames = $this->ruleconfig->getArray('ref'); - $dataset = new \SimpleSAML\Module\statistics\RatioDataset($this->statconfig, $this->ruleconfig, $refNames, $timeres, $fileslot); + $dataset = new \SimpleSAML\Module\statistics\RatioDataset( + $this->statconfig, + $this->ruleconfig, + $refNames, + $timeres, + $fileslot + ); return $dataset; } } - diff --git a/modules/statistics/templates/statistics.tpl.php b/modules/statistics/templates/statistics.tpl.php index 9aefda7ef..11e72e99a 100644 --- a/modules/statistics/templates/statistics.tpl.php +++ b/modules/statistics/templates/statistics.tpl.php @@ -3,33 +3,36 @@ $this->data['header'] = 'SimpleSAMLphp Statistics'; $this->data['jquery'] = array('core' => true, 'ui' => true, 'css' => true); -$this->data['head'] = '<link rel="stylesheet" type="text/css" href="'.SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css").'" />'."\n"; -$this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("statistics/assets/js/statistics.js").'"></script>'."\n"; +$this->data['head'] = '<link rel="stylesheet" type="text/css" href="'. + SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css").'" />'."\n"; +$this->data['head'] .= '<script type="text/javascript" src="'. + SimpleSAML\Module::getModuleURL("statistics/assets/js/statistics.js").'"></script>'."\n"; $this->includeAtTemplateBase('includes/header.php'); -echo '<h1>'. $this->data['available.rules'][$this->data['selected.rule']]['name'] . '</h1>'; -echo '<p>' . $this->data['available.rules'][$this->data['selected.rule']]['descr'] . '</p>'; +echo '<h1>'.$this->data['available.rules'][$this->data['selected.rule']]['name'].'</h1>'; +echo '<p>'.$this->data['available.rules'][$this->data['selected.rule']]['descr'].'</p>'; // Report settings echo '<table class="selecttime">'; -echo '<tr><td class="selecttime_icon"><img src="' . SimpleSAML\Utils\HTTP::getBaseUrl() . 'resources/icons/crystal_project/kchart.32x32.png" alt="Report settings" /></td>'; +echo '<tr><td class="selecttime_icon"><img src="'.SimpleSAML\Utils\HTTP::getBaseUrl(). + 'resources/icons/crystal_project/kchart.32x32.png" alt="Report settings" /></td>'; // Select report echo '<td>'; echo '<form action="#">'; foreach ($this->data['post_rule'] as $k => $v) { - echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n"; + echo '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'" />'."\n"; } if (!empty($this->data['available_rules'])) { echo '<select onchange="submit();" name="rule">'; foreach ($this->data['available_rules'] as $key => $rule) { if ($key === $this->data['selected_rule']) { - echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>'; + echo '<option selected="selected" value="'.$key.'">'.$rule['name'].'</option>'; } else { - echo '<option value="' . $key . '">' . $rule['name'] . '</option>'; + echo '<option value="'.$key.'">'.$rule['name'].'</option>'; } } echo '</select>'; @@ -40,8 +43,8 @@ echo '</form></td>'; echo '<td class="td_right">'; echo '<form action="#">'; -foreach($this->data['post_d'] as $k => $v) { - echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n"; +foreach ($this->data['post_d'] as $k => $v) { + echo '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'" />'."\n"; } if (!empty($this->data['availdelimiters'])) { @@ -55,9 +58,10 @@ if (!empty($this->data['availdelimiters'])) { if ($key == '_') { echo '<option value="_">Total</option>'; } elseif (isset($_REQUEST['d']) && $delim == $_REQUEST['d']) { - echo '<option selected="selected" value="' . htmlspecialchars($delim) . '">' . htmlspecialchars($delimName) . '</option>'; + echo '<option selected="selected" value="'.htmlspecialchars($delim).'">'. + htmlspecialchars($delimName).'</option>'; } else { - echo '<option value="' . htmlspecialchars($delim) . '">' . htmlspecialchars($delimName) . '</option>'; + echo '<option value="'.htmlspecialchars($delim).'">'.htmlspecialchars($delimName).'</option>'; } } echo '</select>'; @@ -71,10 +75,11 @@ echo '</table>'; // Select time and date echo '<table class="selecttime">'; -echo '<tr><td class="selecttime_icon"><img src="' . SimpleSAML\Utils\HTTP::getBaseUrl() . 'resources/icons/crystal_project/date.32x32.png" alt="Select date and time" /></td>'; +echo '<tr><td class="selecttime_icon"><img src="'.SimpleSAML\Utils\HTTP::getBaseUrl(). + 'resources/icons/crystal_project/date.32x32.png" alt="Select date and time" /></td>'; if (isset($this->data['available.times.prev'])) { - echo '<td><a href="' . $this->data['get_times_prev'] . '">« Previous</a></td>'; + echo '<td><a href="'.$this->data['get_times_prev'].'">« Previous</a></td>'; } else { echo '<td class="selecttime_link_grey">« Previous</td>'; } @@ -83,16 +88,16 @@ echo '<td class="td_right">'; echo '<form action="#">'; foreach ($this->data['post_res'] as $k => $v) { - echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n"; + echo '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'" />'."\n"; } if (!empty($this->data['available.timeres'])) { echo '<select onchange="submit();" name="res">'; foreach ($this->data['available.timeres'] as $key => $timeresname) { if ($key == $this->data['selected.timeres']) { - echo '<option selected="selected" value="' . $key . '">' . $timeresname . '</option>'; + echo '<option selected="selected" value="'.$key.'">'.$timeresname.'</option>'; } else { - echo '<option value="' . $key . '">' . $timeresname . '</option>'; + echo '<option value="'.$key.'">'.$timeresname.'</option>'; } } echo '</select>'; @@ -103,16 +108,16 @@ echo '<td class="td_left">'; echo '<form action="#">'; foreach ($this->data['post_time'] as $k => $v) { - echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n"; + echo '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'" />'."\n"; } if (!empty($this->data['available.times'])) { echo '<select onchange="submit();" name="time">'; foreach ($this->data['available.times'] as $key => $timedescr) { if ($key == $this->data['selected.time']) { - echo '<option selected="selected" value="' . $key . '">' . $timedescr . '</option>'; + echo '<option selected="selected" value="'.$key.'">'.$timedescr.'</option>'; } else { - echo '<option value="' . $key . '">' . $timedescr . '</option>'; + echo '<option value="'.$key.'">'.$timedescr.'</option>'; } } echo '</select>'; @@ -120,14 +125,14 @@ if (!empty($this->data['available.times'])) { echo '</form></td>'; if (isset($this->data['available.times.next'])) { - echo '<td class="td_right td_next_right"><a href="' . $this->data['get_times_next'] . '">Next »</a></td>'; + echo '<td class="td_right td_next_right"><a href="'.$this->data['get_times_next'].'">Next »</a></td>'; } else { echo '<td class="td_right selecttime_link_grey td_next_right">Next »</td>'; } echo '</tr></table>'; echo '<div id="tabdiv">'; -if (!empty($this->data['results'])){ +if (!empty($this->data['results'])) { echo '<ul class="tabset_tabs"> <li><a href="#graph">Graph</a></li> <li><a href="#table">Summary table</a></li> @@ -137,22 +142,22 @@ if (!empty($this->data['results'])){ <div id="graph" class="tabset_content">'; - echo '<img src="' . htmlspecialchars($this->data['imgurl']) . '" alt="Graph" />'; + echo '<img src="'.htmlspecialchars($this->data['imgurl']).'" alt="Graph" />'; echo '<form action="#">'; echo '<p class="p_right">Compare with total from this dataset '; foreach ($this->data['post_rule2'] as $k => $v) { - echo '<input type="hidden" name="' . $k . '" value="'. htmlspecialchars($v) . '" />' . "\n"; + echo '<input type="hidden" name="'.$k.'" value="'.htmlspecialchars($v).'" />'."\n"; } echo '<select onchange="submit();" name="rule2">'; echo ' <option value="_">None</option>'; foreach ($this->data['available_rules'] as $key => $rule) { if ($key === $this->data['selected.rule2']) { - echo '<option selected="selected" value="' . $key . '">' . $rule['name'] . '</option>'; + echo '<option selected="selected" value="'.$key.'">'.$rule['name'].'</option>'; } else { - echo '<option value="' . $key . '">' . $rule['name'] . '</option>'; + echo '<option value="'.$key.'">'.$rule['name'].'</option>'; } } echo '</select></p></form>'; @@ -160,13 +165,14 @@ if (!empty($this->data['results'])){ echo '</div>'; // end graph content. /** - * Handle table view - - - - - - + * Handle table view - - - - - - */ - $classint = array('odd', 'even'); $i = 0; + $classint = array('odd', 'even'); + $i = 0; echo '<div id="table" class="tabset_content">'; if (isset($this->data['pieimgurl'])) { - echo '<img src="' . $this->data['pieimgurl'] . '" alt="Pie chart" />'; + echo '<img src="'.$this->data['pieimgurl'].'" alt="Pie chart" />'; } echo '<table class="tableview"><tr><th class="value">Value</th><th class="category">Data range</th></tr>'; @@ -179,14 +185,16 @@ if (!empty($this->data['results'])){ } if ($key === '_') { - echo '<tr class="total ' . $clint . '"><td class="value">' . $value . '</td><td class="category">' . $keyName . '</td></tr>'; + echo '<tr class="total '.$clint.'"><td class="value">'. + $value.'</td><td class="category">'.$keyName.'</td></tr>'; } else { - echo '<tr class="' . $clint . '"><td class="value">' . $value . '</td><td class="category">' . $keyName . '</td></tr>'; + echo '<tr class="'.$clint.'"><td class="value">'.$value. + '</td><td class="category">'.$keyName.'</td></tr>'; } } echo '</table></div>'; - // - - - - - - - End table view - - - - - - - + // - - - - - - - End table view - - - - - - - echo '<div id="debug" >'; echo '<table class="timeseries">'; @@ -196,19 +204,19 @@ if (!empty($this->data['results'])){ if (array_key_exists($key, $this->data['delimiterPresentation'])) { $keyName = $this->data['delimiterPresentation'][$key]; } - echo'<th>' . $keyName . '</th>'; + echo'<th>'.$keyName.'</th>'; } echo '</tr>'; $i = 0; foreach ($this->data['debugdata'] as $slot => $dd) { - echo '<tr class="' . ((++$i % 2) == 0 ? 'odd' : 'even') . '">'; - echo '<td>' . $dd[0] . '</td>'; - echo '<td class="datacontent">' . $dd[1] . '</td>'; + echo '<tr class="'.((++$i % 2) == 0 ? 'odd' : 'even').'">'; + echo '<td>'.$dd[0].'</td>'; + echo '<td class="datacontent">'.$dd[1].'</td>'; foreach ($this->data['topdelimiters'] as $key) { - echo '<td class="datacontent">' . (array_key_exists($key, $this->data['results'][$slot]) ? - $this->data['results'][$slot][$key] : ' ') . '</td>'; + echo '<td class="datacontent">'.(array_key_exists($key, $this->data['results'][$slot]) ? + $this->data['results'][$slot][$key] : ' ').'</td>'; } echo '</tr>'; } diff --git a/modules/statistics/templates/statmeta.tpl.php b/modules/statistics/templates/statmeta.tpl.php index ddb72b4f5..324b4e0c5 100644 --- a/modules/statistics/templates/statmeta.tpl.php +++ b/modules/statistics/templates/statmeta.tpl.php @@ -1,6 +1,7 @@ <?php $this->data['header'] = 'SimpleSAMLphp Statistics Metadata'; -$this->data['head'] = '<link rel="stylesheet" type="text/css" href="' . SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css") . '" />'; +$this->data['head'] = '<link rel="stylesheet" type="text/css" href="'. + SimpleSAML\Module::getModuleURL("statistics/assets/css/statistics.css").'" />'; $this->includeAtTemplateBase('includes/header.php'); echo '<table id="statmeta">' ; @@ -9,34 +10,33 @@ if (isset($this->data['metadata'])) { $metadata = $this->data['metadata']; if (isset($metadata['lastrun'])) { - echo '<tr><td>Aggregator last run at</td><td>' . $metadata['lastrun'] . '</td></tr>'; + echo '<tr><td>Aggregator last run at</td><td>'.$metadata['lastrun'].'</td></tr>'; } if (isset($metadata['notBefore'])) { - echo '<tr><td>Aggregated data until</td><td>' . $metadata['notBefore'] . '</td></tr>'; + echo '<tr><td>Aggregated data until</td><td>'.$metadata['notBefore'].'</td></tr>'; } if (isset($metadata['memory'])) { - echo '<tr><td>Memory usage</td><td>' . $metadata['memory'] . ' MB' . '</td></tr>'; + echo '<tr><td>Memory usage</td><td>'.$metadata['memory'].' MB'.'</td></tr>'; } if (isset($metadata['time'])) { - echo '<tr><td>Execution time</td><td>' . $metadata['time'] . ' seconds' . '</td></tr>'; + echo '<tr><td>Execution time</td><td>'.$metadata['time'].' seconds'.'</td></tr>'; } - if (isset($metadata['lastlinehash'] )) { - echo '<tr><td>SHA1 of last processed logline</td><td>' . $metadata['lastlinehash'] . '</td></tr>'; + if (isset($metadata['lastlinehash'])) { + echo '<tr><td>SHA1 of last processed logline</td><td>'.$metadata['lastlinehash'].'</td></tr>'; } - if (isset($metadata['lastline'] )) { - echo '<tr><td>Last processed logline</td><td>' . $metadata['lastline'] . '</td></tr>'; + if (isset($metadata['lastline'])) { + echo '<tr><td>Last processed logline</td><td>'.$metadata['lastline'].'</td></tr>'; } } else { echo '<tr><td>No metadata found</td></tr>'; } echo '</table>'; -echo '<p>[ <a href="' . SimpleSAML\Module::getModuleURL("statistics/showstats.php") . '">Show statistics</a> ] </p>'; +echo '<p>[ <a href="'.SimpleSAML\Module::getModuleURL("statistics/showstats.php").'">Show statistics</a> ] </p>'; $this->includeAtTemplateBase('includes/footer.php'); - diff --git a/modules/statistics/www/assets/js/statistics.js b/modules/statistics/www/assets/js/statistics.js index d7faf312f..54a72551d 100644 --- a/modules/statistics/www/assets/js/statistics.js +++ b/modules/statistics/www/assets/js/statistics.js @@ -1,7 +1,7 @@ -$(document).ready(function() { +$(document).ready(function () { $("#tabdiv").tabs(); $('ul.tabset_tabs li').click( - function() { + function () { $("html, body").animate({ scrollTop: 0 }, "slow"); } ) diff --git a/modules/statistics/www/assets/statistics.js b/modules/statistics/www/assets/statistics.js index d7faf312f..54a72551d 100644 --- a/modules/statistics/www/assets/statistics.js +++ b/modules/statistics/www/assets/statistics.js @@ -1,7 +1,7 @@ -$(document).ready(function() { +$(document).ready(function () { $("#tabdiv").tabs(); $('ul.tabset_tabs li').click( - function() { + function () { $("html, body").animate({ scrollTop: 0 }, "slow"); } ) diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php index 4a38467ce..ac5968824 100644 --- a/modules/statistics/www/showstats.php +++ b/modules/statistics/www/showstats.php @@ -51,7 +51,7 @@ $t->data['selected_rule'] = $rule; $t->data['selected_rule2'] = $preferRule2; $t->data['post_d'] = getBaseURL($t, 'post', 'd'); - + try { $dataset = $statrule->getDataset($preferTimeRes, $preferTime); $dataset->setDelimiter($delimiter); @@ -69,7 +69,6 @@ try { } exit; } - } catch (\Exception $e) { $t->data['error'] = "No data available"; $t->show(); diff --git a/modules/statistics/www/statmeta.php b/modules/statistics/www/statmeta.php index 442723d0b..dd252bb26 100644 --- a/modules/statistics/www/statmeta.php +++ b/modules/statistics/www/statmeta.php @@ -25,4 +25,3 @@ if ($metadata !== null) { } $t->show(); - diff --git a/tests/modules/consent/lib/Auth/Process/ConsentTest.php b/tests/modules/consent/lib/Auth/Process/ConsentTest.php index 1e06862d3..4c7fc9196 100644 --- a/tests/modules/consent/lib/Auth/Process/ConsentTest.php +++ b/tests/modules/consent/lib/Auth/Process/ConsentTest.php @@ -185,7 +185,7 @@ class ConsentTest extends TestCase $reflection = new \ReflectionClass('\SimpleSAML\Module\consent\Auth\Process\Consent'); foreach (array( - '_includeValues', '_checked', '_focus', '_hiddenAttributes', '_noconsentattributes', '_showNoConsentAboutService' + 'includeValues', 'checked', 'focus', 'hiddenAttributes', 'noconsentattributes', 'showNoConsentAboutService' ) as $v) { $instanceVars[$v] = $reflection->getProperty($v); $instanceVars[$v]->setAccessible(true); @@ -203,15 +203,15 @@ class ConsentTest extends TestCase $testcase = $reflection->newInstance($config, null); - $this->assertEquals($instanceVars['_includeValues']->getValue($testcase), $config['includeValues']); - $this->assertEquals($instanceVars['_checked']->getValue($testcase), $config['checked']); - $this->assertEquals($instanceVars['_focus']->getValue($testcase), $config['focus']); - $this->assertEquals($instanceVars['_hiddenAttributes']->getValue($testcase), $config['hiddenAttributes']); - $this->assertEquals($instanceVars['_noconsentattributes']->getValue($testcase), $config['attributes.exclude']); - $this->assertEquals($instanceVars['_showNoConsentAboutService']->getValue($testcase), $config['showNoConsentAboutService']); + $this->assertEquals($instanceVars['includeValues']->getValue($testcase), $config['includeValues']); + $this->assertEquals($instanceVars['checked']->getValue($testcase), $config['checked']); + $this->assertEquals($instanceVars['focus']->getValue($testcase), $config['focus']); + $this->assertEquals($instanceVars['hiddenAttributes']->getValue($testcase), $config['hiddenAttributes']); + $this->assertEquals($instanceVars['noconsentattributes']->getValue($testcase), $config['attributes.exclude']); + $this->assertEquals($instanceVars['showNoConsentAboutService']->getValue($testcase), $config['showNoConsentAboutService']); $deprecated = $reflection->newInstance(array('noconsentattributes' => $config['attributes.exclude'],), null); - $this->assertEquals($instanceVars['_noconsentattributes']->getValue($deprecated), $config['attributes.exclude']); + $this->assertEquals($instanceVars['noconsentattributes']->getValue($deprecated), $config['attributes.exclude']); } } -- GitLab