diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index d1ca13da9c07fada4530dcdc63d4ae225cabbef7..9f57a7eb2d12d610a644eb2e38c3591fd9681a45 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -70,11 +70,11 @@ class LDAP ) { // Debug Logger::debug('Library - LDAP __construct(): Setup LDAP with '. - 'host=\''.$hostname. - '\', tls='.var_export($enable_tls, true). - ', debug='.var_export($debug, true). - ', timeout='.var_export($timeout, true). - ', referrals='.var_export($referrals, true)); + 'host=\''.$hostname. + '\', tls='.var_export($enable_tls, true). + ', debug='.var_export($debug, true). + ', timeout='.var_export($timeout, true). + ', referrals='.var_export($referrals, true)); /* * Set debug level before calling connect. Note that this passes @@ -92,21 +92,27 @@ class LDAP */ $resource = @ldap_connect($hostname, $port); if ($resource === false) { - throw $this->makeException('Library - LDAP __construct(): Unable to connect to \''. - $hostname.'\'', ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Unable to connect to \''.$hostname.'\'', + ERR_INTERNAL + ); } $this->ldap = $resource; // Enable LDAP protocol version 3 if (!@ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) { - throw $this->makeException('Library - LDAP __construct(): Failed to set LDAP Protocol'. - ' version (LDAP_OPT_PROTOCOL_VERSION) to 3', ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Failed to set LDAP Protocol version (LDAP_OPT_PROTOCOL_VERSION) to 3', + ERR_INTERNAL + ); } // Set referral option if (!@ldap_set_option($this->ldap, LDAP_OPT_REFERRALS, $referrals)) { - throw $this->makeException('Library - LDAP __construct(): Failed to set LDAP Referrals'. - ' (LDAP_OPT_REFERRALS) to '.$referrals, ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Failed to set LDAP Referrals (LDAP_OPT_REFERRALS) to '.$referrals, + ERR_INTERNAL + ); } // Set timeouts, if supported @@ -114,12 +120,14 @@ class LDAP $this->timeout = $timeout; if ($timeout > 0) { if (!@ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, $timeout)) { - Logger::warning('Library - LDAP __construct(): Unable to set timeouts'. - ' (LDAP_OPT_NETWORK_TIMEOUT) to '.$timeout); + Logger::warning( + 'Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_NETWORK_TIMEOUT) to '.$timeout + ); } if (!@ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, $timeout)) { - Logger::warning('Library - LDAP __construct(): Unable to set timeouts'. - ' (LDAP_OPT_TIMELIMIT) to '.$timeout); + Logger::warning( + 'Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_TIMELIMIT) to '.$timeout + ); } } @@ -254,8 +262,9 @@ class LDAP } if ($result === false) { - throw $this->makeException('Library - LDAP search(): Failed search on base \''. - $base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Failed search on base \''.$base.'\' for \''.$filter.'\'' + ); } // Sanity checks on search results @@ -264,25 +273,32 @@ class LDAP throw $this->makeException('Library - LDAP search(): Failed to get number of entries returned'); } elseif ($count > 1) { // More than one entry is found. External error - throw $this->makeException('Library - LDAP search(): Found '.$count.' entries searching base \''. - $base.'\' for \''.$filter.'\'', ERR_AS_DATA_INCONSIST); + throw $this->makeException( + 'Library - LDAP search(): Found '.$count.' entries searching base \''.$base.'\' for \''.$filter.'\'', + ERR_AS_DATA_INCONSIST + ); } elseif ($count === 0) { // No entry is fond => wrong username is given (or not registered in the catalogue). User error - throw $this->makeException('Library - LDAP search(): Found no entries searching base \''. - $base.'\' for \''.$filter.'\'', ERR_NO_USER); + throw $this->makeException( + 'Library - LDAP search(): Found no entries searching base \''.$base.'\' for \''.$filter.'\'', + ERR_NO_USER + ); } // Resolve the DN from the search result $entry = @ldap_first_entry($this->ldap, $result); if ($entry === false) { - throw $this->makeException('Library - LDAP search(): Unable to retrieve result after searching base \''. - $base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Unable to retrieve result after searching base \''. + $base.'\' for \''.$filter.'\'' + ); } $dn = @ldap_get_dn($this->ldap, $entry); if ($dn === false) { - throw $this->makeException('Library - LDAP search(): Unable to get DN after searching base \''. - $base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Unable to get DN after searching base \''.$base.'\' for \''.$filter.'\'' + ); } return $dn; } @@ -358,7 +374,8 @@ class LDAP * * @throws \Exception * @param string|array $bases - * @param string|array $filters Array of 'attribute' => 'values' to be combined into the filter, or a raw filter string + * @param string|array $filters Array of 'attribute' => 'values' to be combined into the filter, + * or a raw filter string * @param string|array $attributes Array of attributes requested from LDAP * @param bool $and If multiple filters defined, then either bind them with & or | * @param bool $escape Weather to escape the filter values or not @@ -407,7 +424,7 @@ class LDAP foreach ($bases as $base) { if ($scope === 'base') { $result = @ldap_read($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); - } else if ($scope === 'onelevel') { + } elseif ($scope === 'onelevel') { $result = @ldap_list($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); } else { $result = @ldap_search($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); @@ -606,7 +623,9 @@ class LDAP } $attributes = @ldap_get_attributes($this->ldap, $entry); // Recycling $attributes... Possibly bad practice. if ($attributes === false) { - throw $this->makeException('Library - LDAP getAttributes(): Could not get attributes of first entry from DN \''.$dn.'\''); + throw $this->makeException( + 'Library - LDAP getAttributes(): Could not get attributes of first entry from DN \''.$dn.'\'' + ); } // Parsing each found attribute into our result set @@ -629,7 +648,10 @@ class LDAP } // Base64 encode binary attributes - if (strtolower($name) === 'jpegphoto' || strtolower($name) === 'objectguid' || strtolower($name) === 'ms-ds-consistencyguid') { + if (strtolower($name) === 'jpegphoto' + || strtolower($name) === 'objectguid' + || strtolower($name) === 'ms-ds-consistencyguid' + ) { $values[] = base64_encode($value); } else { $values[] = $value; @@ -677,7 +699,9 @@ class LDAP // escape characters with a special meaning, also in the password $password = addcslashes($password, ',+"\\<>;*'); if (!$this->bind($dn, $password)) { - Logger::info('Library - LDAP validate(): Failed to authenticate \''.$username.'\' using DN \''.$dn.'\''); + Logger::info( + 'Library - LDAP validate(): Failed to authenticate \''.$username.'\' using DN \''.$dn.'\'' + ); return false; } } diff --git a/lib/SimpleSAML/AuthMemCookie.php b/lib/SimpleSAML/AuthMemCookie.php index da3b22f8f2f415778955641335361468919357f3..6b4455400c4a1709638da0f9747f1ed696c97362 100644 --- a/lib/SimpleSAML/AuthMemCookie.php +++ b/lib/SimpleSAML/AuthMemCookie.php @@ -120,8 +120,9 @@ class AuthMemCookie $class = class_exists('Memcache') ? '\Memcache' : (class_exists('Memcached') ? '\Memcached' : false); if (!$class) { - throw new \Exception('Missing Memcached implementation.'. - ' You must install either the Memcache or Memcached extension.'); + throw new \Exception( + 'Missing Memcached implementation. You must install either the Memcache or Memcached extension.' + ); } // Create the Memcache(d) object. diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index faf54518489e40a96af09db1fc55f327f672a8a5..bbf64ae6ac9f758a9eaa29709a19c851d737560e 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -23,47 +23,65 @@ class Localization /** * The default gettext domain. + * + * @var string */ const DEFAULT_DOMAIN = 'messages'; /** * Old internationalization backend included in SimpleSAMLphp. + * + * @var string */ const SSP_I18N_BACKEND = 'SimpleSAMLphp'; /** * An internationalization backend implemented purely in PHP. + * + * @var string */ const GETTEXT_I18N_BACKEND = 'gettext/gettext'; /** * The default locale directory + * + * @var string */ private $localeDir; /** * Where specific domains are stored + * + * @var array */ private $localeDomainMap = array(); /** * Pointer to currently active translator + * + * @var \Gettext\Translator */ private $translator; /** * Pointer to current Language + * + * @var Language */ private $language; /** * Language code representing the current Language + * + * @var string */ private $langcode; /** * The language backend to use + * + * @var string */ public $i18nBackend; @@ -85,6 +103,8 @@ class Localization /** * Dump the default locale directory + * + * @return string */ public function getLocaleDir() { @@ -96,6 +116,8 @@ class Localization * Get the default locale dir for a specific module aka. domain * * @param string $domain Name of module/domain + * + * @return string */ public function getDomainLocaleDir($domain) { @@ -139,6 +161,8 @@ class Localization * * @param string $domain Name of localization domain * @throws Exception If the path does not exist even for the default, fallback language + * + * @return string */ public function getLangPath($domain = self::DEFAULT_DOMAIN) { @@ -230,6 +254,8 @@ class Localization * Test to check if backend is set to default * * (if false: backend unset/there's an error) + * + * @return bool */ public function isI18NBackendDefault() { @@ -257,6 +283,8 @@ class Localization /** * Show which domains are registered + * + * @return array */ public function getRegisteredDomains() { diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index 0e52228a1deb6221acb4ad1c29f3aa3de40a6b6c..74d40c074688171daed8665dfeb26a6198304f72 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -19,15 +19,24 @@ class Translate */ private $configuration; + /** + * Associative array of languages. + * + * @var array + */ private $langtext = array(); /** * Associative array of dictionaries. + * + * @var array */ private $dictionaries = array(); /** * The default dictionary. + * + * @var string|null */ private $defaultDictionary = null; @@ -38,7 +47,6 @@ class Translate */ private $language; - /** * Constructor * @@ -66,7 +74,6 @@ class Translate } } - /** * Return the internal language object used by this translator. * @@ -77,7 +84,6 @@ class Translate return $this->language; } - /** * This method retrieves a dictionary with the name given. * @@ -107,7 +113,6 @@ class Translate return $this->dictionaries[$name]; } - /** * This method retrieves a tag as an array with language => string mappings. * @@ -145,7 +150,6 @@ class Translate return $dictionary[$tag]; } - /** * Retrieve the preferred translation of a given text. * @@ -186,7 +190,6 @@ class Translate throw new \Exception('Nothing to return from translation.'); } - /** * Translate the name of an attribute. * @@ -219,7 +222,6 @@ class Translate return $name; } - /** * Mark a string for translation without translating it. * @@ -232,7 +234,6 @@ class Translate return $tag; } - /** * Translate a tag into the current language, with a fallback to english. * @@ -321,7 +322,6 @@ class Translate return $translated; } - /** * Return the string that should be used when no translation was found. * @@ -340,7 +340,6 @@ class Translate } } - /** * Include a translation inline instead of putting translations in dictionaries. This function is recommended to be * used ONLY for variable data, or when the translation is already provided by an external source, as a database @@ -363,7 +362,6 @@ class Translate $this->langtext[$tag] = $translation; } - /** * Include a language file from the dictionaries directory. * @@ -386,7 +384,6 @@ class Translate $this->langtext = array_merge($this->langtext, $lang); } - /** * Read a dictionary file in JSON format. * @@ -419,7 +416,6 @@ class Translate return $lang; } - /** * Read a dictionary file in PHP format. * @@ -441,7 +437,6 @@ class Translate return array(); } - /** * Read a dictionary file. * @@ -471,7 +466,13 @@ class Translate return array(); } - + /** + * Translate a singular text. + * + * @param string $original The string before translation. + * + * @return string The translated string. + */ public static function translateSingularGettext($original) { $text = \Gettext\BaseTranslator::$current->gettext($original); @@ -485,7 +486,15 @@ class Translate return strtr($text, is_array($args[0]) ? $args[0] : $args); } - + /** + * Translate a plural text. + * + * @param string $original The string before translation. + * @param string $plural + * @param string $value + * + * @return string The translated string. + */ public static function translatePluralGettext($original, $plural, $value) { $text = \Gettext\BaseTranslator::$current->ngettext($original, $plural, $value); @@ -499,7 +508,6 @@ class Translate return strtr($text, is_array($args[0]) ? $args[0] : $args); } - /** * Pick a translation from a given array of translations for the current language. * diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index d0288d9f32c5e32d9921600ab968ecccf514563e..0d82d5e329d3355140348c457075a3c0609fb273 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -306,8 +306,9 @@ class Memcache { $class = class_exists('\Memcache') ? '\Memcache' : (class_exists('\Memcached') ? '\Memcached' : false); if (!$class) { - throw new \Exception('Missing Memcached implementation.'. - ' You must install either the Memcache or Memcached extension.'); + throw new \Exception( + 'Missing Memcached implementation. You must install either the Memcache or Memcached extension.' + ); } self::$extension = strtolower($class); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index c1c7e6853ea022802f14acdd5ee9002eba15b2c1..9adae2f0b471460424b2f85f7397fb09278b7cd2 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -130,8 +130,9 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource $dh = @opendir($dir); if ($dh === false) { - \SimpleSAML\Logger::warning('Serialize metadata handler: Unable to open directory: '. - var_export($dir, true)); + \SimpleSAML\Logger::warning( + 'Serialize metadata handler: Unable to open directory: '.var_export($dir, true) + ); return $ret; } diff --git a/lib/SimpleSAML/Metadata/Signer.php b/lib/SimpleSAML/Metadata/Signer.php index 195cb02c53b59ab1367159885d0b8987240f86fb..1cb042017596e56b6b0930292371652b7816243a 100644 --- a/lib/SimpleSAML/Metadata/Signer.php +++ b/lib/SimpleSAML/Metadata/Signer.php @@ -229,8 +229,9 @@ class Signer $keyFile = \SimpleSAML\Utils\Config::getCertPath($keyCertFiles['privatekey']); if (!file_exists($keyFile)) { - throw new \Exception('Could not find private key file ['. - $keyFile.'], which is needed to sign the metadata'); + throw new \Exception( + 'Could not find private key file ['.$keyFile.'], which is needed to sign the metadata' + ); } $keyData = file_get_contents($keyFile); diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 30c8cdf7b9a62d5d1c6b908c4c34e3a0e556dd62..b21a6e7103c4b6bdfd8d7e15381601909ce6bbad 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -48,7 +48,6 @@ class Session implements \Serializable */ private static $instance = null; - /** * The session ID of this session. * @@ -56,7 +55,6 @@ class Session implements \Serializable */ private $sessionId; - /** * Transient session flag. * @@ -64,7 +62,6 @@ class Session implements \Serializable */ private $transient = false; - /** * The track id is a new random unique identifier that is generated for each session. * This is used in the debug logs and error messages to easily track more information @@ -74,10 +71,11 @@ class Session implements \Serializable */ private $trackid = null; - + /** + * @var integer|null + */ private $rememberMeExpire = null; - /** * Marks a session as modified, and therefore needs to be saved before destroying * this object. @@ -86,7 +84,6 @@ class Session implements \Serializable */ private $dirty = false; - /** * Tells the session object that the save callback has been registered and there's no need to register it again. * @@ -94,7 +91,6 @@ class Session implements \Serializable */ private $callback_registered = false; - /** * This is an array of objects which will expire automatically after a set time. It is used * where one needs to store some information - for example a logout request, but doesn't @@ -107,7 +103,6 @@ class Session implements \Serializable */ private $dataStore = array(); - /** * The list of IdP-SP associations. * @@ -118,7 +113,6 @@ class Session implements \Serializable */ private $associations = array(); - /** * The authentication token. * @@ -128,7 +122,6 @@ class Session implements \Serializable */ private $authToken; - /** * Authentication data. * @@ -138,7 +131,6 @@ class Session implements \Serializable */ private $authData = array(); - /** * Private constructor that restricts instantiation to either getSessionFromRequest() for the current session or * getSession() for a specific one. @@ -191,7 +183,6 @@ class Session implements \Serializable } } - /** * Serialize this session object. * @@ -205,7 +196,6 @@ class Session implements \Serializable return $serialized; } - /** * Unserialize a session object and load it.. * @@ -239,7 +229,6 @@ class Session implements \Serializable } } - /** * Retrieves the current session. Creates a new session if there's not one. * @@ -381,7 +370,6 @@ class Session implements \Serializable return $session; } - /** * Load a given session as the current one. * @@ -457,7 +445,6 @@ class Session implements \Serializable } } - /** * Save the current session and clean any left overs that could interfere with the normal application behaviour. * @@ -473,7 +460,6 @@ class Session implements \Serializable } } - /** * Mark this session as dirty. * @@ -494,7 +480,6 @@ class Session implements \Serializable $this->callback_registered = header_register_callback(array($this, 'save')); } - /** * Destroy the session. * @@ -1013,7 +998,6 @@ class Session implements \Serializable return $this->authData[$authority]; } - /** * Check whether the session cookie is set. * @@ -1027,7 +1011,6 @@ class Session implements \Serializable return $sh->hasSessionCookie(); } - /** * Add an SP association for an IdP. * @@ -1055,7 +1038,6 @@ class Session implements \Serializable $this->markDirty(); } - /** * Retrieve the associations for an IdP. * @@ -1091,7 +1073,6 @@ class Session implements \Serializable return $this->associations[$idp]; } - /** * Remove an SP association for an IdP. * @@ -1118,7 +1099,6 @@ class Session implements \Serializable $this->markDirty(); } - /** * Retrieve authentication data. * @@ -1138,7 +1118,6 @@ class Session implements \Serializable return $this->authData[$authority][$name]; } - /** * Retrieve a list of authorities (authentication sources) that are currently valid within * this session. diff --git a/lib/SimpleSAML/XHTML/TemplateLoader.php b/lib/SimpleSAML/XHTML/TemplateLoader.php index 7c0ff97e902c4e6e971320c209db5627dbf4d1dc..1d21966c40c4405514a0981dbb4172ce81ab8a33 100644 --- a/lib/SimpleSAML/XHTML/TemplateLoader.php +++ b/lib/SimpleSAML/XHTML/TemplateLoader.php @@ -62,4 +62,3 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader return $templatedir; } } - diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index eaf530b643e9e46ebb2ced23471a0d148d1287a5..39287b2cb967edb1f4a0b7839a7860afb52f7cbb 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -52,8 +52,9 @@ class Parser $result = $this->simplexml->xpath($xpath); if (!is_array($result) || empty($result)) { if ($required) { - throw new \Exception('Could not get value from XML document'. - ' using the following XPath expression: '.$xpath); + throw new \Exception( + 'Could not get value from XML document using the following XPath expression: '.$xpath + ); } else { return null; } @@ -70,8 +71,9 @@ class Parser } } if ($required) { - throw new \Exception('Could not get value from XML document'. - ' using multiple alternative XPath expressions.'); + throw new \Exception( + 'Could not get value from XML document using multiple alternative XPath expressions.' + ); } else { return null; } diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index 6c8b7e62ffa3d106ceea865a8b1e0828097d172d..e6d1a20add1607f2015837ddb0391f8c8aece29a 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -119,8 +119,9 @@ class AuthnResponse // Validate against CA $this->validator->validateCA(Config::getCertPath($md->getString('caFile'))); } else { - throw new \SimpleSAML\Error\Exception('Missing certificate in Shibboleth 1.3'. - ' IdP Remote metadata for identity provider ['.$issuer.'].'); + throw new \SimpleSAML\Error\Exception( + 'Missing certificate in Shibboleth 1.3 IdP Remote metadata for identity provider ['.$issuer.'].' + ); } return true; @@ -362,7 +363,7 @@ class AuthnResponse $encodedattributes .= $subjectNode; foreach ($attributes as $name => $value) { - $encodedattributes .= $this->enc_attribute($name, $value, $base64, $scopedAttributes); + $encodedattributes .= $this->encAttribute($name, $value, $base64, $scopedAttributes); } $encodedattributes .= '</AttributeStatement>'; @@ -409,7 +410,7 @@ class AuthnResponse * @param array $scopedAttributes Array of attributes names which are scoped. * @return string The attribute encoded as an XML-string. */ - private function enc_attribute($name, $values, $base64, $scopedAttributes) + private function encAttribute($name, $values, $base64, $scopedAttributes) { assert(is_string($name)); assert(is_array($values)); diff --git a/modules/adfs/lib/IdP/ADFS.php b/modules/adfs/lib/IdP/ADFS.php index 8187aff89c12ad28206e9d0a22f1cba0e49e66c5..6e79f3e360e2754bfd77f39acef92b3d54d7c8c7 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,37 +128,29 @@ MSG; $objXMLSecDSig->add509Cert($public_cert, true); } $newSig = $responsedom->importNode($objXMLSecDSig->sigNode, true); - $firstassertionroot->appendChild($newSig); + $firstassertionroot->appendChild($newSig); return $responsedom->saveXML(); } private static function postResponse($url, $wresult, $wctx) { - $wresult = htmlspecialchars($wresult); - $wctx = htmlspecialchars($wctx); - - $post = <<<MSG - <body onload="document.forms[0].submit()"> - <form method="post" action="$url"> - <input type="hidden" name="wa" value="wsignin1.0"> - <input type="hidden" name="wresult" value="$wresult"> - <input type="hidden" name="wctx" value="$wctx"> - <noscript> - <input type="submit" value="Continue"> - </noscript> - </form> - </body> -MSG; - - echo $post; - exit; + $config = \SimpleSAML\Configuration::getInstance(); + $t = new \SimpleSAML\XHTML\Template($config, 'adfs:postResponse.twig'); + $t->data['baseurlpath'] = \SimpleSAML\Module::getModuleUrl('adfs'); + $t->data['url'] = $url; + $t->data['wresult'] = $wresult; + $t->data['wctx'] = $wctx; + $t->show(); } public static function sendResponse(array $state) { $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']; @@ -169,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'); @@ -204,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) @@ -220,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); @@ -231,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/templates/postResponse.twig b/modules/adfs/templates/postResponse.twig new file mode 100644 index 0000000000000000000000000000000000000000..857aa8d7ab6fcd28e21630ea84031a22452840a4 --- /dev/null +++ b/modules/adfs/templates/postResponse.twig @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html> + <head> + <script src="{{ baseurlpath }}/assets/js/postResponse.js"></script> + </head> + <body> + <form method="post" action="{{ url }}"> + <input type="hidden" name="wa" value="wsignin1.0"> + <input type="hidden" name="wresult" value="{{ wresult|escape('html') }}"> + <input type="hidden" name="wctx" value="{{ wctx|escape('html') }}"> + <noscript> + <input type="submit" value="Continue"> + </noscript> + </form> + </body> +</html> diff --git a/modules/adfs/www/assets/js/postReponse.js b/modules/adfs/www/assets/js/postReponse.js new file mode 100644 index 0000000000000000000000000000000000000000..a813b92cbec83b7ac265163431ac1f0d7d5f00e3 --- /dev/null +++ b/modules/adfs/www/assets/js/postReponse.js @@ -0,0 +1,3 @@ +document.addEventListener('DOMContentLoaded', function () { + document.forms[0].submit(); +}); diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index 652da7e2f8eb6efaa36ba3c405203e6f7c52b0d5..b7a0f972193892a4969d133f989c2ca769bb63b1 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 da86ec88fcb96ef79effa02e3df81cca93d0ed97..03a973b11656b4d2a020e79d0a4834c9ab8a265d 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 a5286c7bfd0e60663e9d1e1c4e8661e85b89cea5..6943e6dfd09a923626286f8c61cc9cd19b6ff2a4 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 3eb08fd13ff8d353ad6a41c4a9ada97f9ddb7c47..b7f8d42802a9a48e5923fd52e0d577909e409dd2 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/X509error.twig b/modules/authX509/templates/X509error.twig index c350ea53f1692b86911f6b9fa5a9ea3da0f5257a..becaebdb722c7d0067293661a350520a77df917a 100644 --- a/modules/authX509/templates/X509error.twig +++ b/modules/authX509/templates/X509error.twig @@ -4,8 +4,8 @@ {% if errorcode -%} <h2>{% trans 'Error' %}</h2> - <h3>{% trans errortitle %}</h3> - <p>{% trans errordescr %}</p> +<h3>{% trans errortitle %}</h3> +<p>{% trans errordescr %}</p> {% endif -%} <h2>{% trans 'X509 certificate authentication' %}</h2> diff --git a/modules/authX509/templates/X509warning.php b/modules/authX509/templates/X509warning.php index dfe69cbbec7e3aa9af856eb03dccfa950eb3e0c1..a3daa806463d6449fd76aa888f2f7d7d095746e4 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/authX509/templates/X509warning.twig b/modules/authX509/templates/X509warning.twig index 59a65f64f0f30f533aaaa64864fcc6d4047cfcaa..b75f7c370fd773ef4c52aa0a26114e7f5cb8893d 100644 --- a/modules/authX509/templates/X509warning.twig +++ b/modules/authX509/templates/X509warning.twig @@ -1,5 +1,3 @@ -{% set autofocus = 'proceedbutton' %} - {% extends "base.twig" %} {% block content %} @@ -8,7 +6,7 @@ <form action="{{ target | escape }}"> {% for name, value in data -%} - <input type="hidden" name="{{ name }}" value="{{ value }}" /> + <input type="hidden" name="{{ name }}" value="{{ value }}"> {%- endfor %} <p>{% trans %}Your certificate will expire in {{ daysleft }} days.{% endtrans %}</p> @@ -19,7 +17,7 @@ <p>{% trans 'Please renew your certificate in time.' %}</p> {% endif -%} - <p><input type="submit" name="proceed" id="proceedbutton" value="{% trans 'Proceed' %}" /></p> + <p><input type="submit" name="proceed" id="proceedbutton" value="{% trans 'Proceed' %}" autofocus></p> </form> diff --git a/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php b/modules/authYubiKey/lib/Auth/Process/OTP2YubiPrefix.php index 3a1c3175b126ffe392245a4105c16a12d7b0699d..98391a72e1f168fa09f38d69de22709908a7db30 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 b4377847369e6f3c06b3c9711f631b935b5f7919..23ace3a39744a0d8f3890c69c250038d6637774a 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 12d2d8b4de0d167ecc5c584d07ea5029391930c3..e9af3632295130e6e4b23a9b2a496e354868ed61 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 104941b7976fab1f01367f935c0546d97b797643..693e4c374c60eda7fa69608daef796e1a0f19927 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/authYubiKey/templates/yubikeylogin.twig b/modules/authYubiKey/templates/yubikeylogin.twig index 8c01c4cddc2ccf7dbd140827b25c881ea55713bc..e01432c0103afe8eb9b5ab9e94de38f97e366f51 100644 --- a/modules/authYubiKey/templates/yubikeylogin.twig +++ b/modules/authYubiKey/templates/yubikeylogin.twig @@ -2,7 +2,7 @@ {% extends "base.twig" %} {% block preload %} - <link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/yubikey.css" /> + <link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/yubikey.css"> {% endblock %} {% block postload %} @@ -19,15 +19,15 @@ </div> {% endif %} - <img style="float: right" src="{{ logoUrl }}" alt="" /> - <img style="clear: right; float: right" src="{{ devicepicUrl }}" alt="YubiKey" /> + <img style="float: right" src="{{ logoUrl }}" alt=""> + <img style="clear: right; float: right" src="{{ devicepicUrl }}" alt="YubiKey"> <h2>{{ '{authYubiKey:yubikey:header}'|trans }}</h2> <form action="?" method="post" name="f"> <p>{{ '{authYubiKey:yubikey:intro}'|trans }}</p> - <p><input id="otp" type="text" tabindex="2" name="otp" /></p> + <p><input id="otp" type="text" tabindex="2" name="otp" autofocus></p> {% for key, value in stateParams %} - <input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}"/> + <input type="hidden" name="{{ key|escape('html') }}" value="{{ value|escape('html') }}"> {% endfor %} </form> {% endblock %} diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index 09e2c2a10b714de4abeb3a60e03dcf16be318861..a536be64d1cefb5ff44fc36caff16d35d820f74a 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']; @@ -359,7 +359,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(), @@ -387,7 +387,8 @@ abstract class BaseFacebook $this->destroySession(); $this->setPersistentData( - 'access_token', $response_params['access_token'] + 'access_token', + $response_params['access_token'] ); } @@ -498,10 +499,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; @@ -600,11 +603,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 + ) + ); } /** @@ -708,8 +715,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'); @@ -797,10 +804,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) { self::errorLog($e->getMessage()); // most likely that user very recently revoked authorization. @@ -1036,8 +1046,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; @@ -1056,7 +1065,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(); @@ -1141,7 +1151,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 40d5438561501e9f3004ef64c2f95b107dd683d2..86d592458fefbf298dbb65193bb504c667f68e91 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 904b33ba26f1e7a56dd64524e4841105f03cc46f..6a24590194e4ec6a3e390386b5f937853fec4e86 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 91b0003de744fdbe37a2d81683ae4ac836494afe..672ef7f1555a3a655734edff822bf2ba4078d9db 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 bc2abdca47e5872c428442b91a679948035497f4..157525ab29b505ada5462f70bd368fb4b74495c8 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 63b5770125273c3c4c6ca6dc1ae8f8cc6efb018c..e546f341782ebd410d9d3c41b70b3d55662e8c7f 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 ee16d96a78b2bffb5ef237aa4e95ada165042659..43ab320336655dd097035b51c6e6c092ab40efb6 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 -if (isset($this->data['LogoutURL'])) { -?> -<p><a href="<?php echo htmlspecialchars($this->data['LogoutURL']); ?>"><?php echo $this->t('{status:logout}'); ?></a></p> -<?php + +echo '<h1>'.$this->data['403_header'].'</h1>'; +echo '<p>'.$this->data['403_text'].'</p>'; +if (isset($this->data['logoutURL'])) { + 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/templates/authorize_403.twig b/modules/authorize/templates/authorize_403.twig index 1a60813dc7ca1a832c0d4e9bfd00f6e84975baa8..3f6402e923d727e04a639f9a7c92686979574677 100644 --- a/modules/authorize/templates/authorize_403.twig +++ b/modules/authorize/templates/authorize_403.twig @@ -3,9 +3,9 @@ {% block content %} <h1>{{ '{authorize:Authorize:403_header}'|trans }}</h1> <p>{{ '{authorize:Authorize:403_text}'|trans }}</p> - {% if LogoutURL is defined %} + {% if logoutURL is defined %} <p> - <a href="{{ LogoutURL|escape('html') }}">{{ '{status:logout}'|trans }}</a> + <a href="{{ logoutURL|escape('html') }}">{{ '{status:logout}'|trans }}</a> </p> {% endif %} {% endblock%} diff --git a/modules/authorize/www/authorize_403.php b/modules/authorize/www/authorize_403.php index 158fe11a9bffdf51348937aa09427d8a77238e00..4fe73632e498b5191037b5eb91ec9edf6ec86dfc 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 3079d20ebcafea024a375dd6e44cfa4944aaba94..6b004b6fb0604a63b0aea82f43147e838acca5da 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 ebba693a4ac5d60d71a2c95e44802e8afbb60618..cbeed68a7be8028ae0e217cadb15d199948b56af 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 31637deb7578f4e357a54ff9d7c3a79c0dd00c6a..758bdd215f6b490ef11b8b554e1cf2914929595b 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 9ae671a76bfd3bf9ab562c92c0c18b5d154314e6..3ab8cfd7a967eb1043bd1e85a49b48d5fa7fb8cd 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 e547a9afeb0ff18cdba5fce89b282f96e891089c..366583c8a7e572099e66cfaad716faaa084f3788 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 4292ce53fee306a0a306f8c18e3a6e661be6144d..7414004b028332947d5445a88d672af3b0e1cb55 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 7dbacd4a6359f57494cd7d3a79ffcf462cc5a608..f19c2b20ef0d39d76c0ee08bbf1e00e1e6537145 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 52ea5f9520e238fb1d03f2ddf440acb7597c6d83..19ab9b4019d0b1e40ec9131899751fb5a588f8d8 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 35f438f16716c41004cd4d2f69620638262ec498..5f5f3b12642ae37976a8e7e160fce7bc09580d02 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/templates/consentform.php b/modules/consent/templates/consentform.php index 399fa6bedb37c2bcf9a4717c45bec0f99959ee8e..90907e0ed2812bd8654edfa8c10f1b54320b7670 100644 --- a/modules/consent/templates/consentform.php +++ b/modules/consent/templates/consentform.php @@ -19,7 +19,7 @@ $srcName = $this->data['srcName']; $this->data['header'] = $this->t('{consent:consent:consent_header}'); $this->data['head'] = '<link rel="stylesheet" type="text/css" href="'. - SimpleSAML\Module::getModuleURL("consent/assets/consent.css").'" />'."\n"; + SimpleSAML\Module::getModuleURL("consent/assets/css/consent.css").'" />'."\n"; $this->includeAtTemplateBase('includes/header.php'); ?> @@ -59,11 +59,7 @@ if ($this->data['sppp'] !== false) { echo "</p>"; } -echo '<h3 id="attributeheader">'. - $this->t( - '{consent:consent:consent_attributes_header}', - array('SPNAME' => $dstName, 'IDPNAME' => $srcName) - ).'</h3>'; +echo '<h3 id="attributeheader">'.$this->data['consent_attributes_header'].'</h3>'; echo $this->data['attributes_html']; diff --git a/modules/consent/templates/consentform.twig b/modules/consent/templates/consentform.twig index ca07f84f7e6c7e041370a354284aa4d8ef51ff3f..b1433046a9e07af6757ec0453c9b2c14c715f98b 100644 --- a/modules/consent/templates/consentform.twig +++ b/modules/consent/templates/consentform.twig @@ -2,7 +2,7 @@ {% extends "base.twig" %} {% block preload %} -<link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/consent.css" /> +<link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/consent.css" /> {% endblock %} {% block content %} @@ -19,12 +19,12 @@ {% endif %} <input type="hidden" name="StateId" value="{{ stateId }}" /> - <button type="submit" name="yes" class="btn" id="yesbutton">{{ '{consent:consent:yes}'|trans }}</button> + <button type="submit" name="yes" class="btn" id="yesbutton"{%- if autofocus == 'yesbutton' %} autofocus{% endif -%}>{{ '{consent:consent:yes}'|trans }}</button> </form> <form id="consent_no" action="{{ noTarget }}"> <input type="hidden" name="StateId" value="{{ stateId }}" /> - <button type="submit" class="btn" name="no" id="nobutton">{{ '{consent:consent:no}'|trans }}</button> + <button type="submit" class="btn" name="no" id="nobutton"{%- if autofocus == 'nobutton' %} autofocus{% endif -%}>{{ '{consent:consent:no}'|trans }}</button> </form> {% if sppp != false %} diff --git a/modules/consent/www/assets/css/consent.css b/modules/consent/www/assets/css/consent.css new file mode 100644 index 0000000000000000000000000000000000000000..33bef3d64a6c17123c12518e796453e5c1465dd4 --- /dev/null +++ b/modules/consent/www/assets/css/consent.css @@ -0,0 +1,54 @@ +fieldset { + padding: 0px; +} + +fieldset legend { + background: #eee; +} + +h3#attributeheader { + margin: 1.5em 0em 0.5em 0em; +} + +table#table_with_attributes .attrname { + text-align: right; + font-weight: bold; +} + +table#table_with_attributes .attrvalue { + padding-left: 1em; + margin: 0.5em 0em; +} + +table#table_with_attributes tr:last-child td { + border-bottom: none; +} + +table#table_with_attributes img { + border: 1px solid #777; + margin: 4px; +} + +table#table_with_attributes ul { + margin: 0px; + padding-left: 1em; +} + +form#consent_yes { + display: inline; + margin: 0px; + padding: 0px; +} + +form#consent_no { + display: inline; + margin-left: .5em; +} + +.hidden { + display: none; +} + +td.td_odd { + padding: 2em; +} diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 2bdfc82b8c4e66e1eb1b5ab02912980625a7223b..24fe3b52844a7c62a0317b62fb83a26800d678c5 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/dictionaries/consentadmin.definition.json b/modules/consentAdmin/dictionaries/consentadmin.definition.json index a887cf3b7681cb12db9758f1495e2e035b39a827..01a48eddb226ef703cd0a5699798c73772e27000 100644 --- a/modules/consentAdmin/dictionaries/consentadmin.definition.json +++ b/modules/consentAdmin/dictionaries/consentadmin.definition.json @@ -1,7 +1,4 @@ { - "sp_empty_name": { - "en": "(name not specified)" - }, "sp_empty_description": { "en": "(no description)" }, @@ -62,4 +59,4 @@ "consentadmin_purpose": { "en": "The purpose of the service is" } -} \ No newline at end of file +} diff --git a/modules/consentAdmin/dictionaries/consentadmin.translation.json b/modules/consentAdmin/dictionaries/consentadmin.translation.json index 7a874d0ac9cb77929c6f9d299ac999407680c0b2..18af923572217905c30575593f096aad44162623 100644 --- a/modules/consentAdmin/dictionaries/consentadmin.translation.json +++ b/modules/consentAdmin/dictionaries/consentadmin.translation.json @@ -1,34 +1,4 @@ { - "sp_empty_name": { - "da": "(navn ikke angivet)", - "no": "(navn ikke spesifisert)", - "de": "(Name nicht angegeben)", - "sl": "(brez naziva)", - "pt": "(nome n\u00e3o especificado)", - "sv": "(namn ej angivet)", - "fr": "(nom non indiqu\u00e9)", - "hr": "(naziv nije specificiran)", - "hu": "(nincs n\u00e9v)", - "it": "(nome non specificato)", - "es": "(nombre no especificado)", - "lt": "(pavadinimas nenurodytas)", - "nl": "(naam niet opgegeven)", - "ja": "(\u540d\u524d\u7121\u3057)", - "zh-tw": "(\u672a\u5b9a\u7fa9\u540d\u7a31)", - "nn": "(namn ikkje spesifisert)", - "et": "(nimi m\u00e4\u00e4ramata)", - "he": "(\u05dc\u05d0 \u05e0\u05d9\u05ea\u05df \u05e9\u05dd)", - "zh": "\uff08\u6ca1\u6709\u6307\u5b9a\u540d\u5b57\uff09", - "ar": "\u0627\u0644\u0627\u0633\u0645 \u063a\u064a\u0631 \u0645\u062d\u062f\u062f", - "lv": "(v\u0101rds nav nor\u0101d\u012bts)", - "id": "(Nama tidak diisi)", - "sr": "(ime nije specificirano)", - "ro": "(nu a fost specificat numele)", - "ru": "(\u0438\u043c\u044f \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043e)", - "cs": "(jm\u00e9no nespecifikov\u00e1no)", - "eu": "(izena ez da zehaztu)", - "el": "(\u03c7\u03c9\u03c1\u03af\u03c2 \u03cc\u03bd\u03bf\u03bc\u03b1)" - }, "sp_empty_description": { "da": "(ingen beskrivelse)", "no": "(ingen beskrivelse)", diff --git a/modules/consentAdmin/locales/ar/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/ar/LC_MESSAGES/consentAdmin.po index ed203049a1c3669f338dd9deeda66db2ace19d31..d778277bbbd973ea9b48e4d9d45be983a28cf369 100644 --- a/modules/consentAdmin/locales/ar/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/ar/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "لا يوجد وصÙ" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "مشغلي الخدمة Ù„" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "الاسم غير Ù…Øدد" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "Ù„Øذ٠مواÙقتك</h3>الغي صندوق مشغل الخدمة<h3>روابط</h3> <ul> <li><a " diff --git a/modules/consentAdmin/locales/cs/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/cs/LC_MESSAGES/consentAdmin.po index 7709b6911b51c29f44ac9425b9e81a8b0f749645..42b3f5277700f88d87b40fc7041f039fecf67bf0 100644 --- a/modules/consentAdmin/locales/cs/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/cs/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(žádný popis)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Poskytovatelé služeb pro" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(jméno nespecifikováno)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Jak smazat vaÅ¡e povolenÃ</h3> OdznaÄte polÃÄko odpovÃdajÃcà " diff --git a/modules/consentAdmin/locales/da/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/da/LC_MESSAGES/consentAdmin.po index 8961aba8256d658aec74a165ea31c0b1dfac5fb1..bdd2573a1065490cef72ee1eb106c9f952eb0ae2 100644 --- a/modules/consentAdmin/locales/da/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/da/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(ingen beskrivelse)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Service Providers for" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(navn ikke angivet)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>SÃ¥dan sletter du et samtykke</h3>Fjern fluebenet ud for tjenesten, " diff --git a/modules/consentAdmin/locales/de/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/de/LC_MESSAGES/consentAdmin.po index 2e53b5ce2cac6344e26fcd5942c89dcff33fddbb..72b0ae0fa94fba55e3b92e7b3a2c030c0b78de71 100644 --- a/modules/consentAdmin/locales/de/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/de/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(keine Beschreibung)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Diensteanbieter für" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(Name nicht angegeben)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Wie Sie Ihre Einverständniserklärung löschen</h3> Entfernen Sie das " diff --git a/modules/consentAdmin/locales/el/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/el/LC_MESSAGES/consentAdmin.po index 207fb949db09116809c6fb1aa71512d5679c445e..15e128a24f917975089837dc7d006911fafc8ed6 100644 --- a/modules/consentAdmin/locales/el/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/el/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(χωÏίς πεÏιγÏαφή)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "ΠάÏοχοι ΥπηÏεσιών για" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(χωÏίς όνομα)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Î ÏŽÏ‚ να αναιÏÎσετε τη συγκατάθεσή σας</h3>ΑποεπιλÎξτε το κουτί " diff --git a/modules/consentAdmin/locales/en/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/en/LC_MESSAGES/consentAdmin.po index 9d68f7f24ba110af81afb3da516e9db56563c63e..ea3d3207f8797a56112448c1a83f502544d8d7cd 100644 --- a/modules/consentAdmin/locales/en/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/en/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(no description)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Service Providers for" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(name not specified)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "\n" diff --git a/modules/consentAdmin/locales/es/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/es/LC_MESSAGES/consentAdmin.po index 8ddfa631c742ae1a76aebbe0c935da710a006a49..6d937dde8fbd11e3432a25e23aca819de8925cef 100644 --- a/modules/consentAdmin/locales/es/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/es/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(sin descripción)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Proveedores de servicio para" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nombre no especificado)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Como eliminar su consentimiento</h3> Desmarque la opción " diff --git a/modules/consentAdmin/locales/et/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/et/LC_MESSAGES/consentAdmin.po index 37219898d7f72962d99ed837c73fce14cdcc8dcd..4a815ad5bddb7ad81c3820f8965419c0b8a00233 100644 --- a/modules/consentAdmin/locales/et/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/et/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(kirjeldus puudub)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Teenusepakkujad" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nimi määramata)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Kuidas eemaldada nõusolekut</h3> Eemalda vastava teenusepakkuja " diff --git a/modules/consentAdmin/locales/eu/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/eu/LC_MESSAGES/consentAdmin.po index 6d67389b76bc15aaf17aaa0df8b9507cc3f4e8d1..adeb050e0426a80810a2b97c469529d8f224343a 100644 --- a/modules/consentAdmin/locales/eu/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/eu/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(deskribapenik gabe)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Zerbitzu hornitzaileak hontarako: " -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(izena ez da zehaztu)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Zure onespena nola ezabatu</h3> Zerbitzu hornitzaileari dagokion " diff --git a/modules/consentAdmin/locales/fr/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/fr/LC_MESSAGES/consentAdmin.po index ca3bde7f1215e6c84a940016d6e13c84c3aafe59..65abab4fd1a305ab9fa691c6799fbab8a4070d80 100644 --- a/modules/consentAdmin/locales/fr/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/fr/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(pas de description)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Fournisseurs de service pour" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nom non indiqué)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Comment révoquer un consentement</h3>Décochez la case correspondante " diff --git a/modules/consentAdmin/locales/he/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/he/LC_MESSAGES/consentAdmin.po index 30a632e9d8898500052c4420d0ddb5e778d66051..4cb1b7703ef9f872146d4b0046b6cc5c7401c04b 100644 --- a/modules/consentAdmin/locales/he/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/he/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(×ין תי×ור)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "ספקי שירות עבור" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(×œ× × ×™×ª×Ÿ ש×)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>×יך להסיר ×ת הסכמתך</h3> לחץ בתיבה המת×ימה לספק השירות " diff --git a/modules/consentAdmin/locales/hr/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/hr/LC_MESSAGES/consentAdmin.po index 46436725170845942314a291a4089488ddafaf94..b7be441fd7c5e13fc64e0b9d049fcd27d56e62c0 100644 --- a/modules/consentAdmin/locales/hr/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/hr/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(nema opisa)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Davatelji usluga za" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(naziv nije specificiran)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Kako obrisati dozvolu</h3> Maknite kvaÄicu iz polja koje se odnosi na" diff --git a/modules/consentAdmin/locales/hu/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/hu/LC_MESSAGES/consentAdmin.po index 78b785ca9b07bdf8827a759a2bdefd57d674e93f..51f0166a1313e3fe22cc6bc400707742668ca2be 100644 --- a/modules/consentAdmin/locales/hu/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/hu/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(nincs leÃrás)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Szolgáltató" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nincs név)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Hogyan kell visszavonni egy hozzájárulást?</h3> A szolgáltatóhoz " diff --git a/modules/consentAdmin/locales/id/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/id/LC_MESSAGES/consentAdmin.po index 04468f2620a739789bfd096cf0a00a1da6472808..64e517dbd6b58654d7a3738ace30fb8accd80089 100644 --- a/modules/consentAdmin/locales/id/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/id/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(Tidak ada penjelasan)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Service Provider untuk" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(Nama tidak diisi)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Bagaimana cara menghapus consent anda</h3> Hapus centak pada kotak " diff --git a/modules/consentAdmin/locales/it/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/it/LC_MESSAGES/consentAdmin.po index 6b4875d91ef234dbbf4cbd563febf38cb2dd171a..10b213d142448ecf0ffb5b63a0864c6e889bb019 100644 --- a/modules/consentAdmin/locales/it/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/it/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(nessuna descrizione)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Service provider per" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nome non specificato)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Come rimuovere il consenso></h3> Togliere il segno di spunta al " diff --git a/modules/consentAdmin/locales/ja/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/ja/LC_MESSAGES/consentAdmin.po index 6cf0c9dc019f10a1f4e00307000fa46134b10a61..5a26c6aa45459759d116c5feef45794524daa12c 100644 --- a/modules/consentAdmin/locales/ja/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/ja/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(記述無ã—)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "サービスプãƒãƒã‚¤ãƒ€ - " -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(åå‰ç„¡ã—)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>承èªã®å‰Šé™¤æ–¹æ³•</h3> 該当ã™ã‚‹ã‚µãƒ¼ãƒ“スプãƒãƒã‚¤ãƒ€ã®ãƒã‚§ãƒƒã‚¯ã‚’外ã—ã¾ã™ã€‚<h3>リンク</h3> <ul> <li><a " diff --git a/modules/consentAdmin/locales/lt/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/lt/LC_MESSAGES/consentAdmin.po index 41e8fb3b0d09f57a617bb267e417be9fe12e7b01..7596d5e822d2e09388136a49a82a403b06322d5f 100644 --- a/modules/consentAdmin/locales/lt/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/lt/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(apibÅ«dinimas nenurodytas)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Paslaugos tiekÄ—jai" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(pavadinimas nenurodytas)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Kaip paÅ¡alinti savo leidimÄ…</h3> Panaikinkite pažymÄ—jimÄ… ties " diff --git a/modules/consentAdmin/locales/lv/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/lv/LC_MESSAGES/consentAdmin.po index fea6d8bd60879d9a6b63aff98b4b3a1f2d30c3ec..6f5ff436fccd52f22f89e44860a9d7d03abf4a8c 100644 --- a/modules/consentAdmin/locales/lv/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/lv/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(nav apraksta)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Servisa piegÄdÄtÄji priekÅ¡" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(vÄrds nav norÄdÄ«ts)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>KÄ dzÄ“st noteikumus</h3> Izņemiet Ä·eksÄ«ti pie atbilstoÅ¡Ä servisa " diff --git a/modules/consentAdmin/locales/nb/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/nb/LC_MESSAGES/consentAdmin.po index c6d1c68b309c614fa525c5e00e8c16e8f3157547..d981bba9d2827e2f8b6cb04274cb75b6f7263237 100644 --- a/modules/consentAdmin/locales/nb/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/nb/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(ingen beskrivelse)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Tjenesteleverandører for" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(navn ikke spesifisert)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Hvordan trekke samtykke tilbake</h3> Fjern haken i boksen for gitte " diff --git a/modules/consentAdmin/locales/nl/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/nl/LC_MESSAGES/consentAdmin.po index e763eda1a8dbdb4decca76524ca3d70117c853a6..77c74edc95b9b1b5616238ff9dadb6133771a107 100644 --- a/modules/consentAdmin/locales/nl/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/nl/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(geen omschrijving)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Service Providers voor" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(naam niet opgegeven)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Hoe verwijdert u toestemmingen</h3> Vinkt u het vakje af dat " diff --git a/modules/consentAdmin/locales/nn/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/nn/LC_MESSAGES/consentAdmin.po index 35aba2cd0132416dc9132c35f2a68444877007c5..dcfd7cba639b552d509c9cf1116c7db5571215ad 100644 --- a/modules/consentAdmin/locales/nn/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/nn/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(mangler informasjon)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Tenesteleverandør for " -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(namn ikkje spesifisert)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Korleis dra tilbake samtykke</h3> Fjern haka i boksen for enkelte " diff --git a/modules/consentAdmin/locales/pt/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/pt/LC_MESSAGES/consentAdmin.po index 0673dcb7e9dd1c3eaaf247d63f1ca414429b80b0..85983c36f722c0a1222a87fc79261f044b969a1b 100644 --- a/modules/consentAdmin/locales/pt/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/pt/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(sem descrição)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Fornecedores de Serviços para" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nome não especificado)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Como remover o seu consentimento</h3> Retire a marca correspondente " diff --git a/modules/consentAdmin/locales/ro/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/ro/LC_MESSAGES/consentAdmin.po index e83dbf971376c429f7379b9fc77ae4919ba15f93..6c1943bfc757495f46d83fcf2e76732383d62b77 100644 --- a/modules/consentAdmin/locales/ro/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/ro/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(fără descriere)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Furnizori de servicii pentru" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(nu a fost specificat numele)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Cum poate fi anulat acordul dumneavoastră</h3>DebifaÈ›i căsuÈ›a " diff --git a/modules/consentAdmin/locales/ru/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/ru/LC_MESSAGES/consentAdmin.po index 9169cfd9130b0f950e37357b677c460e435cff4b..a641ee0e4cc58939b9aef9aea5f0da0a36d8cce7 100644 --- a/modules/consentAdmin/locales/ru/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/ru/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(опиÑание отÑутÑтвует)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Ð¡ÐµÑ€Ð²Ð¸Ñ Ð¿Ñ€Ð¾Ð²Ð°Ð¹Ð´ÐµÑ€Ñ‹ длÑ" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(Ð¸Ð¼Ñ Ð½Ðµ указано)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Как удалить ваше ÑоглаÑие</h3> Снимите выделение Ñ ÑÐµÑ€Ð²Ð¸Ñ Ð¿Ñ€Ð¾Ð²Ð°Ð¹Ð´ÐµÑ€Ð° " diff --git a/modules/consentAdmin/locales/sl/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/sl/LC_MESSAGES/consentAdmin.po index 7afe72a12de1174e0cd4acc94ccc563b8b1e32cb..915d1669df449f9c89a576b2a8e74040ad42808c 100644 --- a/modules/consentAdmin/locales/sl/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/sl/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(brez opisa)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Ponudniki storitev za" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(brez naziva)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Kako razveljavim dano privolitev?</h3> Odstranite kljukico pred " diff --git a/modules/consentAdmin/locales/sr/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/sr/LC_MESSAGES/consentAdmin.po index 5cd0b78871f939ea3419e2bbbec6906e409f6d5a..6099ce86fc2b0291084bfe30dc98fda6b3834e51 100644 --- a/modules/consentAdmin/locales/sr/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/sr/LC_MESSAGES/consentAdmin.po @@ -55,9 +55,6 @@ msgstr "(nema opisa)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Davaoci Servisa za" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(ime nije specificirano)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Kako obrisati dozvolu</h3> Uklonite kvaÄicu iz polja koje se odnosi " diff --git a/modules/consentAdmin/locales/sv/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/sv/LC_MESSAGES/consentAdmin.po index d825178b11084d6263753a422eb21332b9754a23..6777d22f6b70fbd554d3866d917683109ca50dea 100644 --- a/modules/consentAdmin/locales/sv/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/sv/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(ingen beskrivning)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "Tjänsteleverantörer för" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(namn ej angivet)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>Hur du tar bort ditt samtycke</h3> Ta bort markeringen i rutan " diff --git a/modules/consentAdmin/locales/zh-tw/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/zh-tw/LC_MESSAGES/consentAdmin.po index b7d2e43bea97dfd1f6777ed056b0f36662932f44..79766547053c53e48b0d5ad4390f0e4893e05be0 100644 --- a/modules/consentAdmin/locales/zh-tw/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/zh-tw/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(ç„¡æè¿°)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "æœå‹™æ供者的" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(未定義å稱)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>在這刪除您的授權</h3> å–消勾é¸æœå‹™æ供者å°æ‡‰çš„æ ¸å–方塊 <h3>連çµ</h3> <ul> <li><a " diff --git a/modules/consentAdmin/locales/zh/LC_MESSAGES/consentAdmin.po b/modules/consentAdmin/locales/zh/LC_MESSAGES/consentAdmin.po index 0a3b247785351bba5d0793d8c792aa76bcd5fbfa..ab6ab8d229baa7f56d50013f391ffb47c212f4e6 100644 --- a/modules/consentAdmin/locales/zh/LC_MESSAGES/consentAdmin.po +++ b/modules/consentAdmin/locales/zh/LC_MESSAGES/consentAdmin.po @@ -54,9 +54,6 @@ msgstr "(没有æ述)" msgid "{consentAdmin:consentadmin:service_providers_for}" msgstr "æœåŠ¡æ供商æœåŠ¡äºŽ" -msgid "{consentAdmin:consentadmin:sp_empty_name}" -msgstr "(没有指定åå—)" - msgid "{consentAdmin:consentadmin:consentadmin_description2}" msgstr "" "<h3>å¦‚ä½•åˆ é™¤ä½ çš„è®¸å¯</h3>å选相应的SP选择框<h3>Links</h3> <ul> <li><a " diff --git a/modules/consentAdmin/templates/consentadmin.php b/modules/consentAdmin/templates/consentadmin.php index b0a5b21bd5bdcb84961e9316b09c6748a6d00363..b9bc74667a0b53dbee2af90fee0fdf7126a7e7d1 100644 --- a/modules/consentAdmin/templates/consentadmin.php +++ b/modules/consentAdmin/templates/consentadmin.php @@ -1,7 +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>'; - $this->data['head'] .= '<script type="text/javascript" src="'.SimpleSAML\Module::getModuleURL("consentAdmin/assets/js/consentSimpleAjax.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'); ?> @@ -13,7 +14,7 @@ <table> <tr> <th width="80%"><?php echo $this->t('{consentAdmin:consentadmin:service_provider_header}') ?></th> - <th width="140"><?php echo $this->t('{consentAdmin:consentadmin:status_header}') ?></th> + <th><?php echo $this->t('{consentAdmin:consentadmin:status_header}') ?></th> </tr> <?php $spList = $this->data['spList']; @@ -22,14 +23,13 @@ $hide_text = $this->t('{consentAdmin:consentadmin:hide}'); $attributes_text = $this->t('{consentAdmin:consentadmin:attributes_text}'); foreach ($spList as $spName => $spValues) { - $this->getTranslator()->includeInlineTranslation('spname', $spValues['name']); - $this->getTranslator()->includeInlineTranslation('spdescription', $spValues['description']); if (!is_null($spValues['serviceurl'])) { - $htmlSpName = '<a href="'.$spValues['serviceurl'].'" style="color: black; font-weight: bold;">'.htmlspecialchars($this->t('spname', array(), false, true)).'</a>'; + $htmlSpName = '<a class="serviceUrl" href="'.$spValues['serviceurl'].'">'. + htmlspecialchars($spValues['name']).'</a>'; } else { - $htmlSpName = htmlspecialchars($this->t('spname', array(), false, true)); + $htmlSpName = htmlspecialchars($spValues['name']); } - $spDescription = htmlspecialchars($this->t('spdescription', array(), false, true)); + $spDescription = htmlspecialchars($spValues['description']); $checkedAttr = $spValues['consentStatus'] == 'ok' ? 'checked="checked"' : ''; $consentValue = $spValues['consentValue']; $consentText = $spValues['consentStatus'] == 'changed' ? "attributes has changed" : ""; @@ -38,8 +38,11 @@ <tr class="$row_class"> <td> <table> - <tr class="$row_class"><td><span class='caSPName'><span title='$spDescription'>$htmlSpName</span> <span style="font-size: 80%;"onclick="javascript:toggleShowAttributes('$show_spid');"><span id='showing_$show_spid'>$show_text</span><span id='hiding_$show_spid' style='display:none;'>$hide_text</span>$attributes_text</span></span></td></tr> - <tr><td colspan="2" class="caAttributes"><div id="attributes_$show_spid" style="display: none;"> + <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']; if ($this->data['showDescription']) { @@ -47,12 +50,7 @@ TRSTART; } echo "\n<ul>\n"; foreach ($attributes as $name => $value) { - - if (isset($this->data['attribute_'.htmlspecialchars(strtolower($name))])) { - $name = $this->data['attribute_'.htmlspecialchars(strtolower($name))]; - } - $name = $this->getTranslator()->getAttributeTranslation($name); // translate - 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"; @@ -68,7 +66,9 @@ TRSTART; </table> </td> -<td class='caAllowed'><input onclick="javascript:checkConsent(this.value, $show_spid, this.checked)" 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++; @@ -80,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/consentadmin.twig b/modules/consentAdmin/templates/consentadmin.twig new file mode 100644 index 0000000000000000000000000000000000000000..d27b8a63d399432c22585deb97e35d6aa7f54156 --- /dev/null +++ b/modules/consentAdmin/templates/consentadmin.twig @@ -0,0 +1,82 @@ +{% set pagetitle = '{consentAdmin:consentadmin:consentadmin_header}'|trans %} +{% extends "base.twig" %} + +{% block preload %} +<link rel="stylesheet" type="text/css" href="{{ basepathurl }}assets/css/consentAdmin.css" /> +{% endblock %} + +{% block postload %} +<script src="{{ baseurlpath }}assets/js/consentAdmin.js"></script> +{% endblock %} + +{% block content %} + +<h2>{{ '{consentAdmin:consentadmin:consentadmin_header}'|trans }}</h2> +<p>{{ '{consentAdmin:consentadmin:consentadmin_description1}'|trans }}</p> + +<table> + <tr> + <th colspan="2" width="80%">{{ '{consentAdmin:consentadmin:service_provider_header}'|trans }}</th> + <th width="140">{{ '{consentAdmin:consentadmin:status_header}'|trans }}</th> + </tr> + +{% for spName, spValues in spList %} + + {% if loop.index0 % 2 == 0 %} + {% set rowClass = 'row0' %} + {% else %} + {% set rowClass = 'row1' %} + {% endif %} + + <tr class="{{ rowClass }}"> + <td> + <span class='caSPName'> + <span title='{{ spValues.description|escape('html') }}'> + {% if spValues.serviceurl is defined %} + {{ spValues.name|escape('html') }} + {% else %} + <a class="serviceUrl" href="{{ spValues.serviceurl }}">{{ spValues.name|escape('html') }}</a> + {% endif %} + </span> + <span class="show_hide" id="show_hide_{{ loop.index0 }}"> + <span id="showing_{{ loop.index0 }}">{{ '{consentAdmin:consentadmin:show}'|trans }}</span> + <span id="hiding_{{ loop.index0 }}">{{ '{consentAdmin:consentadmin:hide}'|trans }}</span> + {{ '{consentAdmin:consentadmin:attributes_text}'|trans }} + </span> + </span> + </td> + <td class="caAttributes"> + <div id="attributes_{{ loop.index0 }}"> + {% if showDescription %} + <p>{{ '{consentAdmin:consentadmin:consentadmin_purpose}'|trans }}{{ spValues.description|escape('html') }}</p> + {% endif %} + <ul> + {% for attrName, attrValue in spValues.attributes_by_sp %} + {% if attrValue|length > 1 %} + <li>{{ attrName|escape('html') }}: + <ul> + {% for valKey, value in attrValue %} + <li>{{ value|escape('html') }}</li> + {% endfor %} + </ul> + </li> + {% else %} + <li>{{ attrName|escape('html') }}: {{ attrValue|first|escape('html') }}</li> + {% endif %} + {% endfor %} + </ul> + </div> + </td> + <td class="caAllowed"> + <input class="checkbox" id="checkbox_{{ loop.index0 }}" value='{{ spValues.consentValue }}' type='checkbox'{% if spValues.consentStatus == 'ok'%} checked="checked"{% endif %} /><span id="consentText_{{ loop.index0 }}">{% if spValues.consentStatus == 'changed' %}attributes has changed{% endif %}</span> + </td> + </tr> +{% endfor %} +</table> + +<p>{{ '{consentAdmin:consentadmin:consentadmin_description2}'|trans|raw }}</p> + +<h2>Logout</h2> +<p><a href="{{ baseurlpath }}consentAdmin.php?logout=1">Logout</a></p> + +{% endblock %} diff --git a/modules/consentAdmin/templates/consentadminajax.php b/modules/consentAdmin/templates/consentadminajax.php index f6d54c72dba3b5641842f0798d8cdd967714430c..c8520b085576ddfdde6850fd8920f5566a022d2d 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/css/consentAdmin.css b/modules/consentAdmin/www/assets/css/consentAdmin.css index 86735025420d0b54880d7d0971d430b12c6200a9..94c4a190c4c796224a8ad9a7c9ed4b6449552a9f 100644 --- a/modules/consentAdmin/www/assets/css/consentAdmin.css +++ b/modules/consentAdmin/www/assets/css/consentAdmin.css @@ -20,3 +20,20 @@ tr.row1 td { a.orange { color: #ffd633; } + +span.show_hide { + font-size: 80%; +} + +a.serviceUrl { + color: black; + font-weight: bold; +} + +span[id^='hiding_'], span[id*='hiding_'] { + display: none; +} + +div[id^='attributes_'], div[id*='attributes_'] { + display: none; +} diff --git a/modules/consentAdmin/www/assets/js/consentAdmin.js b/modules/consentAdmin/www/assets/js/consentAdmin.js index cfe0fb71ae4148f0e12cef49453901896b67d971..59cf4e17b4bbf471ed32249df7df163e45be1368 100644 --- a/modules/consentAdmin/www/assets/js/consentAdmin.js +++ b/modules/consentAdmin/www/assets/js/consentAdmin.js @@ -1,3 +1,79 @@ -function setConsentText(consentStatus, show_spid) { - document.getElementById("consentText" + show_spid).innerHTML = consentStatus; +var xmlHttp; + +function checkConsent() +{ + var show_spid = this.id.charAt(this.id.length-1); + var checkbox = document.getElementById("checkbox_"+show_spid); + + xmlHttp = GetXmlHttpObject() + if (xmlHttp == null) { + alert("Browser does not support HTTP Request") + return + } + + var url = "consentAdmin.php" + url = url+"?cv="+checkbox.value + url = url+"&action="+checkbox.checked + url = url+"&sid="+Math.random() + + xmlHttp.onreadystatechange = function () { + if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") { + document.getElementById("consentText_" + show_spid).innerHTML = xmlHttp.responseText; + } + } + + xmlHttp.open("GET", url, true) + xmlHttp.send(null) } + +// This function creates an XMLHttpRequest +function GetXmlHttpObject() +{ + var xmlHttp = null; + try { + // Firefox, Opera 8.0+, Safari + xmlHttp = new XMLHttpRequest(); + } catch (e) { + //Internet Explorer + try { + xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + } + return xmlHttp; +} + +function toggleShowAttributes() +{ + var show_spid = this.id.charAt(this.id.length-1); + + var disp = document.getElementById('attributes_' + show_spid); + var showing = document.getElementById('showing_' + show_spid); + var hiding = document.getElementById('hiding_' + show_spid); + + disp.style.display = (disp.style.display == 'none' ? 'block' : 'none'); + showing.style.display = (disp.style.display == 'none' ? 'inline' : 'none'); + hiding.style.display = (disp.style.display == 'none' ? 'none' : 'inline'); +} + +document.addEventListener( + 'DOMContentLoaded', + function () { + var show_hide = document.getElementsByClassName("show_hide"); + for (var i = 0; i < show_hide.length; i++) { + show_hide[i].addEventListener( + 'click', + toggleShowAttributes + ); + } + + var checkbox = document.getElementsByClassName("checkbox"); + for (var i = 0; i < checkbox.length; i++) { + checkbox[i].addEventListener( + 'click', + checkConsent + ); + } + } +); diff --git a/modules/consentAdmin/www/assets/js/consentSimpleAjax.js b/modules/consentAdmin/www/assets/js/consentSimpleAjax.js deleted file mode 100644 index 7ea896c630fa05a2f269330d63f7d70a4837232f..0000000000000000000000000000000000000000 --- a/modules/consentAdmin/www/assets/js/consentSimpleAjax.js +++ /dev/null @@ -1,70 +0,0 @@ -var xmlHttp; - -function checkConsent(consentValue, show_spid, checkAction) -{ - xmlHttp=GetXmlHttpObject() - if (xmlHttp==null) { - alert ("Browser does not support HTTP Request") - - return - } - - var url="consentAdmin.php" - url=url+"?cv="+consentValue - url=url+"&action="+checkAction - url=url+"&sid="+Math.random() - xmlHttp.onreadystatechange=function() { - if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") - { - setConsentText(xmlHttp.responseText, show_spid); - } -} - - xmlHttp.open("GET",url,true) - xmlHttp.send(null) -} - -// This function will be automaticly called when the Ajax call is done returning data -function stateChanged() { - if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") - { - //Alert("Status of consent:" + xmlHttp.responseText ); - } -} - -// This function creates an XMLHttpRequest -function GetXmlHttpObject() { - var xmlHttp=null; - try - { - // Firefox, Opera 8.0+, Safari - xmlHttp=new XMLHttpRequest(); - } - catch (e) - { - //Internet Explorer - try - { - xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); - } - catch (e) - { - xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); - } - } - - return xmlHttp; -} - -function toggleShowAttributes(show_spid) { - var disp = document.getElementById('attributes_' + show_spid); - //var showhide = document.getElementById('showhide_' + show_spid); - var showing = document.getElementById('showing_' + show_spid); - var hiding = document.getElementById('hiding_' + show_spid); - - disp.style.display = (disp.style.display == 'none' ? 'block' : 'none'); - //showhide.innerHTML = (disp.style.display == 'none' ? 'Show' : 'Hide') - showing.style.display = (disp.style.display == 'none' ? 'inline' : 'none'); - hiding.style.display = (disp.style.display == 'none' ? 'none' : 'inline'); - //alert('hiding display'+hiding.display); -} diff --git a/modules/consentAdmin/www/consentAdmin.php b/modules/consentAdmin/www/consentAdmin.php index 5477786c3951eba333d4cdf95f487259257f895a..8591a9c62cb9a2e1813c3161d48a1c644856769d 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]; @@ -150,7 +153,7 @@ if (!empty($_GET['action'])) { // Remove services, whitch have consent disabled if (isset($idp_metadata['consent.disable'])) { - foreach ($idp_metadata['consent.disable'] AS $disable) { + foreach ($idp_metadata['consent.disable'] as $disable) { if (array_key_exists($disable, $all_sp_metadata)) { unset($all_sp_metadata[$disable]); } @@ -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') { @@ -219,7 +234,7 @@ $template_sp_content = array(); $template = new \SimpleSAML\XHTML\Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin'); $translator = $template->getTranslator(); $translator->includeLanguageFile('attributes'); // attribute listings translated by this dictionary -$sp_empty_name = $translator->getTag('sp_empty_name'); + $sp_empty_description = $translator->getTag('sp_empty_description'); // Process consents for all SP @@ -228,8 +243,27 @@ 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) { + if (isset($template->data['attribute_'.htmlspecialchars(strtolower($orig_name))])) { + $old_name = $template->data['attribute_'.htmlspecialchars(strtolower($orig_name))]; + } + $name = $translator->getAttributeTranslation(strtolower($orig_name)); // translate + + $attributes_new[$name] = $value; + unset($attributes_new[$orig_name]); + } // Check if consent exists if (array_key_exists($targeted_id, $user_consent)) { @@ -255,7 +289,7 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { } elseif (isset($sp_values['OrganizationDisplayName']) && is_array($sp_values['OrganizationDisplayName'])) { $sp_name = $sp_metadata['OrganizationDisplayName']; } else { - $sp_name = $sp_empty_name; + $sp_name = $sp_entityid; } } @@ -269,6 +303,13 @@ foreach ($all_sp_metadata as $sp_entityid => $sp_values) { // Add a URL to the service if present in metadata $sp_service_url = isset($sp_metadata['ServiceURL']) ? $sp_metadata['ServiceURL'] : null; + // Translate SP name and description + $translator->includeInlineTranslation('spname', $sp_name); + $translator->includeInlineTranslation('spdescription', $sp_description); + + $sp_name = $translator->getPreferredTranslation($translator->getTag('spname')); + $sp_description = $translator->getPreferredTranslation($translator->getTag('spdescription')); + // Fill out array for the template $sp_list[$sp_entityid] = array( 'spentityid' => $sp_entityid, diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index 2f40c8cfe3a3b43e31feec5c5a6ef2bdc8f14bf6..1dd97a96cdcc7289eb224c0b30f19d21c4a9cd7e 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 aa67c31c5bdf4880e098a5f5f2274455ff09477e..558bf94795a622bd87a702f41c6d5b3feea3eab1 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 5672947c694497e26701c61b88df3489380e9ad1..d17c74d295466971f803037257a977b49630ddc6 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 44d3b71f00548e75fa1e460eab75985b3f274a55..127eafec6ad2d8d0ad22983ed24edded4325b958 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 6f85b8b393d4adc02c4278fc8f804c2f834695a3..204de7f6f4b06a1cba609e9fc5d5a938d5a115c7 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 be7707e597f9898e2e72523ede3b795c95eb8095..ce4b12aac38e058ab61477456ebf3380ebd90c26 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 4d28c5cf7f2ed7efddf68d05effa137f90bc9c23..92102262b572ee8d0b0bfb07e35ef011c106c9a8 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 12af86f803370ea8af16ff46b09269b5cf62f89c..c8069eb311df77dccc1ec8d8ea1a1dd7db7a7d58 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 7a538ec1bb3e3964371d7f8d748354039fb97d54..f3c9a293eefecbdca16227ea71724cbfcf827f92 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/Stats/Output/File.php b/modules/core/lib/Stats/Output/File.php index 1e6941c214f05b6809b74fe65a8f0c59bf6a7c18..cac817c83b784f5e7fca13d3a6dca81d0497ab18 100644 --- a/modules/core/lib/Stats/Output/File.php +++ b/modules/core/lib/Stats/Output/File.php @@ -18,7 +18,7 @@ class File extends \SimpleSAML\Stats\Output /** * The file handle for the current file. - * @var resource + * @var resource|null|false */ private $file = null; diff --git a/modules/core/lib/Storage/SQLPermanentStorage.php b/modules/core/lib/Storage/SQLPermanentStorage.php index 8b73c77a8e1e2d1c5ab95d2e4a9feac0a1279d2a..46da8682827afe5b5b8235f5ef85c93722ebb59a 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/_frontpage_menu.twig b/modules/core/templates/_frontpage_menu.twig index 7b363ffaf4a9178c234fb6e87bff8476e8a101d2..d19592356b007af61567b4ac8840f6efb5b7534f 100644 --- a/modules/core/templates/_frontpage_menu.twig +++ b/modules/core/templates/_frontpage_menu.twig @@ -1,25 +1,29 @@ <div class="pure-g frontpage-menu"> - <div class="pure-u-2-3"> - <div class="pure-menu pure-menu-horizontal"> - <ul class="pure-menu-list"> - <li class="pure-menu-item {% if frontpage_section == "welcome" %} pure-menu-selected{% endif %}"> - <a href="frontpage_welcome.php" class="pure-menu-link">Welcome</a></li> - <li class="pure-menu-item {% if frontpage_section == "config" %} pure-menu-selected{% endif %}"> - <a href="frontpage_config.php" class="pure-menu-link">Configuration</a></li> - <li class="pure-menu-item {% if frontpage_section == "auth" %} pure-menu-selected{% endif %}"> - <a href="frontpage_auth.php" class="pure-menu-link">Authentication</a></li> - <li class="pure-menu-item {% if frontpage_section == "federation" %} pure-menu-selected{% endif %}"> - <a href="frontpage_federation.php" class="pure-menu-link">Federation</a></li> - </ul> + <div class="pure-u-2-3"> + <div class="pure-menu pure-menu-horizontal"> + <ul class="pure-menu-list"> + <li class="pure-menu-item{% if frontpage_section == "welcome" %} pure-menu-selected{% endif %}"> + <a href="frontpage_welcome.php" class="pure-menu-link">Welcome</a> + </li> + <li class="pure-menu-item{% if frontpage_section == "config" %} pure-menu-selected{% endif %}"> + <a href="frontpage_config.php" class="pure-menu-link">Configuration</a> + </li> + <li class="pure-menu-item{% if frontpage_section == "auth" %} pure-menu-selected{% endif %}"> + <a href="frontpage_auth.php" class="pure-menu-link">Authentication</a> + </li> + <li class="pure-menu-item{% if frontpage_section == "federation" %} pure-menu-selected{% endif %}"> + <a href="frontpage_federation.php" class="pure-menu-link">Federation</a> + </li> + </ul> + </div> </div> - </div> - <div class="pure-u-1-3"> + <div class="pure-u-1-3"> {% if isadmin %} - <p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}</p> + <p class="float-r youareadmin">{{ '{core:frontpage:loggedin_as_admin}'|trans }}</p> {% else %} - <p class="float-r youareadmin"> - <a href="{{ loginurl }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a> - </p> + <p class="float-r youareadmin"> + <a href="{{ loginurl }}">{{ '{core:frontpage:login_as_admin}'|trans }}</a> + </p> {% endif %} - </div> + </div> </div> diff --git a/modules/core/templates/authsource_list.tpl.php b/modules/core/templates/authsource_list.tpl.php index db0a7cede05e88b30b82fdfbae85b4f616adfe82..20522518defa804e70e6e850a8f4ef9447c4b9d2 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/authsource_list.twig b/modules/core/templates/authsource_list.twig index acf0d57fa51de28382b6bd9c6760723772cf1121..c966180b7fb54b8ef8b304f65034ba1f7dfd1457 100644 --- a/modules/core/templates/authsource_list.twig +++ b/modules/core/templates/authsource_list.twig @@ -5,7 +5,7 @@ <h1>{{ header }}</h1> <ul> {% for key, name in sources %} - <li><a href="?as={{ name|escape('url') }}">{{ name|escape('html') }}</a></li> + <li><a href="?as={{ name|escape('url') }}">{{ name|escape('html') }}</a></li> {% endfor %} </ul> {% endblock %} diff --git a/modules/core/templates/base.twig b/modules/core/templates/base.twig index 47a732abda4e6ae049b5111bf0bd442861dc78f3..96fcc07baeb873b82c4f94a4e6a17a002a40b500 100644 --- a/modules/core/templates/base.twig +++ b/modules/core/templates/base.twig @@ -2,23 +2,24 @@ {% block contentwrapper %} {% if tabname %} <div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all"> -<ul class="tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"> -{% for name, link in links %} -{% if name == pageid %} -<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"> -<a href="#">{{ link.text|trans }}</a> -</li> -{% else %} -<li class="ui-state-default ui-corner-top"> -<a href="{{ link.href }}">{{ link.text|trans }}</a> -</li> -{% endif %} -{% endfor %} -</ul> -<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> + <ul class="tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all"> + {% for name, link in links %} + {% if name == pageid %} + <li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"> + <a href="#">{{ link.text|trans }}</a> + </li> + {% else %} + <li class="ui-state-default ui-corner-top"> + <a href="{{ link.href }}">{{ link.text|trans }}</a> + </li> + {% endif %} + {% endfor %} + </ul> + <div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom"> {% endif %} {{ block('content') }} {% if tabname %} -</div></div> + </div> +</div> {% endif %} {% endblock %} diff --git a/modules/core/templates/cardinality_error.tpl.php b/modules/core/templates/cardinality_error.tpl.php index dc75c540afc9b7f71a167a5d397188eca3cb3e47..036f06a675a570b72a2633381955d4b71ba53bc0 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 f0594948f1e2f19d7f067de38c526c2908108e0a..afb55b30d72452381c8e02b3f17f346d5ac046dc 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 3e4b52701732b1cc731bd0a0556a3ce1e49b9f45..10f7463cf305b6ceff462533f85f4c5140db68db 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 f6e1596c560a6e76e12f3e109bedcdaf0e51265d..2516c065a520eb446bcca15940dab780a52763d1 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 33d5ff25113874dd9ded7b920b7d94a7d5c8209d..ae9f923e7dd645eb22e5a2f17a62e3ef3aa62fde 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/login.twig b/modules/core/templates/login.twig index adf3f8426029a838847c170c28d8c70946067a9d..e1b342cc0a9ba9e71324930c7ff732f2e69f860e 100644 --- a/modules/core/templates/login.twig +++ b/modules/core/templates/login.twig @@ -2,7 +2,7 @@ {% extends "@core/base.twig" %} {% block content %} -<h1>{{ pagetitle|trans }}</h1> + <h1>{{ pagetitle|trans }}</h1> <p>Please choose one of the following authentication methods: </p> {% if sources is empty -%} @@ -17,4 +17,4 @@ </ul> </div> {% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/modules/core/templates/loginuserpass.php b/modules/core/templates/loginuserpass.php index 61b16608836684e80f3589483fbefe20d30ea8f5..9e0fc646a1829f9fc93ac02f9cb43ea78200f744 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,61 +123,62 @@ 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"> <td class="loginicon"></td><td></td> <td> - <button class="btn" - onclick="this.value='<?php echo $this->t('{login:processing}'); ?>'; - this.disabled=true; this.form.submit(); return true;" tabindex="6"> + <button id="submit_button" class="btn" tabindex="6"> <?php echo $this->t('{login:login_button}'); ?> </button> </td> </tr> </table> + <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> @@ -181,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/loginuserpass.twig b/modules/core/templates/loginuserpass.twig index 7f27bc186072f50cb616145daf0d596c4b12d79d..4ec8bb8352fa410bce6d8528b46db776cd649785 100644 --- a/modules/core/templates/loginuserpass.twig +++ b/modules/core/templates/loginuserpass.twig @@ -2,6 +2,10 @@ {% extends "@core/base.twig" %} +{% block postload %} + <script src="{{baseurlpath}}assets/js/loginuserpass.js"></script> +{% endblock %} + {% block content %} {% if errorcode -%} <div class="pure-g"> @@ -99,10 +103,10 @@ </div> <!-- form-align--> <br><br> - <button class="pure-button pure-button-red pure-input-1-2 pure-input-sm-1-1 right" type="submit" onclick="this.value='{{ 'Processing...'|trans }}';" tabindex="6"> + <button class="pure-button pure-button-red pure-input-1-2 pure-input-sm-1-1 right" id="submit_button" type="submit" tabindex="6"> {{ 'Login'|trans }} </button> - + <input type='hidden' id="processing_trans" value="{{ 'Processing...'|trans }}" /> {% for name, value in stateparams -%} <input type="hidden" name="{{ name }}" value="{{ value }}" /> {%- endfor %} diff --git a/modules/core/templates/logout-iframe.php b/modules/core/templates/logout-iframe.php index 634ed122da80247efe7fd85625758848c3338e7c..59e6ae770cbd24e7e1b366dee5deff94e9a6478e 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 d3b638b22542158ff7c6042c6433947291cb612c..a00f3ce911bd2bf97f7ab11dc6200e4a109dd015 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_metadata.twig b/modules/core/templates/no_metadata.twig index 818c08a8ca46d0a222f8f64c87b00f588ecbc23e..0f534fcdab94a9dbb9982ac1bfae1304c1c8e05c 100644 --- a/modules/core/templates/no_metadata.twig +++ b/modules/core/templates/no_metadata.twig @@ -1,7 +1,7 @@ -<p>{{ '{core:no_metadata:config_problem}' | trans }}</p> +<p>{{ '{core:no_metadata:config_problem}'|trans }}</p> <ul> - <li>{{ '{core:no_metadata:suggestion_user_link}' | trans }}</li> - <li>{{ '{core:no_metadata:suggestion_developer}' | trans }}</li> + <li>{{ '{core:no_metadata:suggestion_user_link}'|trans }}</li> + <li>{{ '{core:no_metadata:suggestion_developer}'|trans }}</li> </ul> diff --git a/modules/core/templates/no_state.tpl.php b/modules/core/templates/no_state.tpl.php index f86e346e0e8fdebe1360e384c0f941a7dee8a639..01ea6db789e94678cd97d8c384909037c5afdf71 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/no_state.twig b/modules/core/templates/no_state.twig index 9ae61fb5dcbc9316dfab58a2286b69698e6ec2d4..b811c102506c386e15a3606a3e796dc56bea93f9 100644 --- a/modules/core/templates/no_state.twig +++ b/modules/core/templates/no_state.twig @@ -1,12 +1,12 @@ -<h3>{{ '{core:no_state:suggestions}' | trans }}</h3> +<h3>{{ '{core:no_state:suggestions}'|trans }}</h3> <ul> - <li>{{ '{core:no_state:suggestion_goback}' | trans }}</li> - <li>{{ '{core:no_state:suggestion_closebrowser}' | trans }}</li> + <li>{{ '{core:no_state:suggestion_goback}'|trans }}</li> + <li>{{ '{core:no_state:suggestion_closebrowser}'|trans }}</li> </ul> -<h3>{{ '{core:no_state:causes}' | trans }}</h3> +<h3>{{ '{core:no_state:causes}'|trans }}</h3> <ul> - <li>{{ '{core:no_state:cause_backforward}' | trans }}</li> - <li>{{ '{core:no_state:cause_openbrowser}' | trans }}</li> - <li>{{ '{core:no_state:cause_nocookie}' | trans }}</li> + <li>{{ '{core:no_state:cause_backforward}'|trans }}</li> + <li>{{ '{core:no_state:cause_openbrowser}'|trans }}</li> + <li>{{ '{core:no_state:cause_nocookie}'|trans }}</li> </ul> diff --git a/modules/core/templates/short_sso_interval.php b/modules/core/templates/short_sso_interval.php index ac334a6c0d8ca6f47f9f5b9c37a8bd28dd16840d..2e305c2b9ddf1ac3a6a190c36a7fc626e3665040 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/templates/short_sso_interval.twig b/modules/core/templates/short_sso_interval.twig index 91288cd9f7d5cfe94ca5b20de621dcb4c51262ac..542e174c0a9315e54c873bafe4895e17dd5473f6 100644 --- a/modules/core/templates/short_sso_interval.twig +++ b/modules/core/templates/short_sso_interval.twig @@ -5,12 +5,12 @@ <h1>{{ header }}</h1> <form style="display: inline; margin: 0px; padding: 0px" action="{{ target|escape('html') }}"> {% for name, value in params %} - <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}" /> + <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}"> {% endfor %} <p>{{ '{core:short_sso_interval:warning}'|trans }}</p> <div class="trackidtext"> <p>{{ '{errors:report_trackid}'|trans }}<span class="trackid">{{ trackId }}</span></p> </div> - <input type="submit" name="continue" id="contbutton" value="'{core:short_sso_interval:retry}'|trans|escape('html') }}" /> + <input type="submit" name="continue" id="contbutton" value="'{core:short_sso_interval:retry}'|trans|escape('html') }}" autofocus> </form> {% endblock %} diff --git a/modules/core/www/assets/js/loginuserpass.js b/modules/core/www/assets/js/loginuserpass.js new file mode 100644 index 0000000000000000000000000000000000000000..e475e8ca6ec6a497dc7159695c82e2806d463906 --- /dev/null +++ b/modules/core/www/assets/js/loginuserpass.js @@ -0,0 +1,15 @@ +document.addEventListener( + 'DOMContentLoaded', + function () { + var button = document.getElementById("submit_button"); + button.addEventListener( + 'click', + function () { + var translation = document.getElementById("processing_trans"); + this.disabled = true; + this.innerHTML = translation.value; + return true; + } + ); + } +); diff --git a/modules/core/www/cardinality_error.php b/modules/core/www/cardinality_error.php index c73a4fee6da9746252c3a3b6b749c60ad6cef971..9c14a82157719bb60a15d71fa5583397ef76f798 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 8d134f7d758d1af750f14d844dbdf6f36b598cfb..afc794a0e3b366b3c83b3fdb1b9e2c8940fe1c34 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 0c9fb078777bb0e2b2c8645147e3f3eb755cec3e..3a89257de604ef8e37b0f9e4383554cb5d11d378 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 dc595db4739fe9c6ef5c2d6747539fd85cf89eb5..273a821a6704f66ac3fcb8e8c41b043c4c27405f 100644 --- a/modules/core/www/frontpage_config.php +++ b/modules/core/www/frontpage_config.php @@ -106,7 +106,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)'), ); @@ -119,7 +119,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', '>=') ); @@ -139,7 +139,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 ec0132ac8d00c3c6a9f3c8e0d95de609f4242c8a..d3d946fa357b1e9244bfe81b801ffb74a8584a38 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 6fc401070571c41ec845234551588333276da539..921c23cdfebd5acbd42369e5f571f509fcd0ab74 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/idp/logout-iframe.php b/modules/core/www/idp/logout-iframe.php index 4af3da1cdbd711fe79d12efeae787ae779903fb0..e844d558e3304c9d5158ea3a50f40e6395926322 100644 --- a/modules/core/www/idp/logout-iframe.php +++ b/modules/core/www/idp/logout-iframe.php @@ -113,22 +113,21 @@ foreach ($state['core:Logout-IFrame:Associations'] as $association) { } } -$id = \SimpleSAML\Auth\State::saveState($state, 'core:Logout-IFrame'); $globalConfig = \SimpleSAML\Configuration::getInstance(); - -$template_id = 'core:logout-iframe.php'; if ($type === 'nojs') { - $template_id = 'core:logout-iframe-wrapper.php'; + $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:logout-iframe-wrapper.php'); +} else { + $t = new \SimpleSAML\XHTML\Template($globalConfig, 'core:logout-iframe.php'); } -$t = new \SimpleSAML\XHTML\Template($globalConfig, $template_id); -$t->data['auth_state'] = $id; -$t->data['header'] = $t->getTranslator()->t('{logout:progress}'); - /** * @deprecated The "id" variable will be removed. Please use "auth_state" instead. */ +$id = \SimpleSAML\Auth\State::saveState($state, 'core:Logout-IFrame'); $t->data['id'] = $id; +$t->data['auth_state'] = $id; + +$t->data['header'] = $t->getTranslator()->t('{logout:progress}'); $t->data['type'] = $type; $t->data['terminated_service'] = $terminated; $t->data['remaining_services'] = $remaining; diff --git a/modules/core/www/login-admin.php b/modules/core/www/login-admin.php index 01ea86c93d41978b6503bafb5e8651602f9ebbe1..59246f6731c6db0c7cbc2bff6dba5f1e5a4e065e 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 f5211bb7fb808255bd6d66dd698af46efe65a62f..c9569dede90c7ee8d0ea7ade1de670edf8ef7798 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 4b293e2dc09fd40a82e6de39edcc113bc8109893..3b480699bfc8d79a57c94134f7c071b9973ff97a 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 abee18711383baa95d93f6c712f857b0d1ee8783..fe303c9b8d5518eefab4e55812eb808cc1726900 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 fecd11cdb19d6f183fd3236bee5e43cb73a8323a..8cecb58344ca539ae3dcc3c87214d23c6c376396 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 f6181f6cf3a4eb6dcaeec18e2ae4e928b4a3f16f..50efe15a1ec53e6ef527448cc4b3e72cb5aa13b8 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/cron/templates/croninfo.twig b/modules/cron/templates/croninfo.twig index a4deaaa7716c8e0412f5a2c9142eddd18f344129..b00b8905b8ab2107cb0c9d1980dc0a7fea539ea4 100644 --- a/modules/cron/templates/croninfo.twig +++ b/modules/cron/templates/croninfo.twig @@ -1,16 +1,20 @@ {% set pagetitle = 'Cron result page'|trans %} {% extends "base.twig" %} +{% block preload %} +<link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/cron.css"> +{% endblock %} + {% block content %} <h2>{{ 'Cron result page'|trans }}</h2> <p>{{ 'Cron is a way to run things regularly on unix systems.'|trans }}<br /><br /></p> <p>{{ 'Here is a suggestion for a crontab file:'|trans }}<br /><br /></p> <div class="code-box code-box-content"> - <code> + <code id="cronlist"> {% for url in urls %} - # {{ 'Run cron:'|trans }} [{{ url.tag }}]<br /> - {{ url.int }} curl --silent "{{ url.href }}" > /dev/null 2>&1<br /> + # {{ 'Run cron:'|trans }} [{{ url.tag }}]<br /> + {{ url.int }} curl --silent "{{ url.href }}" > /dev/null 2>&1<br /> {% endfor %} </code></div><br /> diff --git a/modules/cron/www/assets/css/cron.css b/modules/cron/www/assets/css/cron.css new file mode 100644 index 0000000000000000000000000000000000000000..459178ed6c2c31566f70bc580c763c100a3e3462 --- /dev/null +++ b/modules/cron/www/assets/css/cron.css @@ -0,0 +1,3 @@ +code#cronlist { + font-size: 0.8vw; +} diff --git a/modules/discopower/config-templates/module_discopower.php b/modules/discopower/config-templates/module_discopower.php index 4579f9d101fa2c2ceace1cd34582f7c98015c917..dfac2581765b9ee116b462ed6360e2aa8fe19e85 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 52ded4331b991bff8d2f2260ede635f53f79c730..4e7a3914975784d37877f5151811d1d21b92e61e 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 1ae62cabdf4ea088f853057a4ed52ce161cda85d..72cad52983d435d67bb21662502f37559ff616d5 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/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/js/jquery.livesearch.js') . '"></script>'; -$this->data['post'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleUrl('discopower/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/templates/disco.twig b/modules/discopower/templates/disco.twig index 3645cdb169a6b53dc3b78446236430b7b425ec87..8e7082304c16f598e75ada0fc0fb0274ef95ee15 100644 --- a/modules/discopower/templates/disco.twig +++ b/modules/discopower/templates/disco.twig @@ -26,28 +26,16 @@ <div id="tabdiv"> <ul class="tabset_tabs"> - {% set i = 1 %} {% for tab, idps in idplist %} {% if idps is not empty %} - {% if i == 1 %} - <li class="tab-link current" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li> - {% set i = 2 %} - {% else %} - <li class="tab-link" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li> - {% endif %} + <li class="tab-link{% if loop.first %}current{% endif %}" data-tab="{{ tab }}"><a href="#{{ tab }}"><span>{{ tabNames[tab]|trans }}</span></a></li> {% endif %} {% endfor %} </ul> - {% set i = 1 %} {% for tab, idps in idplist %} {% if idps is not empty %} - {% if i == 1 %} - <div id="{{ tab }}" class="tabset_content current"> - {% set i = 2 %} - {% else %} - <div id="{{ tab }}" class="tabset_content"> - {% endif %} + <div id="{{ tab }}" class="tabset_content{% if loop.first %} current{% endif %}"> <div class="inlinesearch"> <p>Incremental search...</p> <form id="idpselectform" method="get"> diff --git a/modules/discopower/www/style.css b/modules/discopower/www/assets/css/disco.css similarity index 95% rename from modules/discopower/www/style.css rename to modules/discopower/www/assets/css/disco.css index dddb03c2221ba40ca07a1783f20b0f1b345ed233..c270798321da61b199164d62918d58d3e952f184 100644 --- a/modules/discopower/www/style.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 new file mode 100644 index 0000000000000000000000000000000000000000..2b125ff951350ae8c49fd0de49442da48a7bc3f2 --- /dev/null +++ b/modules/discopower/www/assets/js/jquery.livesearch.js @@ -0,0 +1,43 @@ +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(); + + 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 new file mode 100644 index 0000000000000000000000000000000000000000..079ea87d5c2c03ec140396014394dbed08ad4dad --- /dev/null +++ b/modules/discopower/www/assets/js/quicksilver.js @@ -0,0 +1,102 @@ +// 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 +// +// Tested in Firefox 2 and Safari 3 +// +// The Quicksilver code is available here +// http://code.google.com/p/blacktree-alchemy/ +// 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 +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +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 + } + + 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; + } + + 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) + } + + 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; + 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 + } + } + return 0.0 +} diff --git a/modules/discopower/www/assets/js/suggest.js b/modules/discopower/www/assets/js/suggest.js new file mode 100644 index 0000000000000000000000000000000000000000..b404edd0a0509dad13cab4d2d6fab86feaa0c85b --- /dev/null +++ b/modules/discopower/www/assets/js/suggest.js @@ -0,0 +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; + + //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; +} diff --git a/modules/discopower/www/disco.php b/modules/discopower/www/disco.php index 29d4343f6d54aaec29939496c3b6e50631e609b8..963a9e17b602d08b9d03b4d30f73469b34bc11f0 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/discopower/www/js/jquery.livesearch.js b/modules/discopower/www/js/jquery.livesearch.js deleted file mode 100644 index 06c30437371ed145f78c5d27b085fae6c825a47c..0000000000000000000000000000000000000000 --- a/modules/discopower/www/js/jquery.livesearch.js +++ /dev/null @@ -1,37 +0,0 @@ -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(); - - 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/js/quicksilver.js b/modules/discopower/www/js/quicksilver.js deleted file mode 100644 index af29f732b48a5609bb09c6beb3c04f99610f2534..0000000000000000000000000000000000000000 --- a/modules/discopower/www/js/quicksilver.js +++ /dev/null @@ -1,95 +0,0 @@ -// 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 -// -// Tested in Firefox 2 and Safari 3 -// -// The Quicksilver code is available here -// http://code.google.com/p/blacktree-alchemy/ -// 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 -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -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 - - 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; - - 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) - - 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; - - 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 - } - } - return 0.0 -} \ No newline at end of file diff --git a/modules/discopower/www/js/suggest.js b/modules/discopower/www/js/suggest.js deleted file mode 100644 index 667b35ac944d2aead91124e72542bba5409e00e6..0000000000000000000000000000000000000000 --- a/modules/discopower/www/js/suggest.js +++ /dev/null @@ -1,23 +0,0 @@ -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; - - //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; -} diff --git a/modules/exampleauth/lib/Auth/Source/UserPass.php b/modules/exampleauth/lib/Auth/Source/UserPass.php index f1d6fcb042e6e9b1967b8c1aee0622c76ac877ca..633125c155089b318643533abe6f89100bcca798 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 f4fc5339d45e0dd253d04d508eb493d2c146bcab..e975d69860002c7825f5c2c1b29c40036bfdd56f 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 c41178c84023a3c8f31475260d66675fd23b3a1b..ca7d97308ae044eea12ac3448c98673df23a69ca 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 b3c538b2c843e0caeed35ae37369834c5d560c85..6b135f807f5eb1e5332e136dda9280efa50f8bbd 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/about2expire.twig b/modules/expirycheck/templates/about2expire.twig index c60788051a4a8339aeb5f86a986062dfb80b4360..1e1d5d427323c00833c54872611c890ee309f485 100644 --- a/modules/expirycheck/templates/about2expire.twig +++ b/modules/expirycheck/templates/about2expire.twig @@ -4,10 +4,10 @@ {% block content %} <form style="display: inline; margin: 0px; padding: 0px" action="{{ yesTarget|escape('html') }}"> {% for name, value in yesData %} - <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}" /> + <input type="hidden" name="{{ name|escape('html') }}" value="{{ value|escape('html') }}"> {% endfor %} <h3>{{ warning }}</h3> <p>{{ '{expirycheck:expwarning:expiry_date_text}'|trans }} {{ expireOnDate }}</p> - <input type="submit" name="yes" id="yesbutton" value="{{ '{expirycheck:expwarning:btn_continue}'|trans }}" /> + <input type="submit" name="yes" id="yesbutton" value="{{ '{expirycheck:expwarning:btn_continue}'|trans }}" autofocus> </form> {% endblock %} diff --git a/modules/expirycheck/templates/expired.php b/modules/expirycheck/templates/expired.php index dc4f54718acc90a3adef7e94d4fccf369db3acc0..ee1e73bda4290575a2665f58740bb39119b972bf 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 20ebfd33029a4fb0aab837b9500b4eade2a732ed..76d78fba8488ec95408ff3ce2c01971337bd97c2 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 60e9b70d9572fcd1a653387f88e79c0f8ad95116..42d5abb26d44bf0c1e87a67415eec5e007cf39ea 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 e3cbd9d52c1fe20d910e56fceebcf9c8970911c5..4757a3bb2502c999fd2927f89f7f300224aa402a 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 8025d44714df2d060db12565332e5267679548f8..88a575b742acd187b0b424e7385cbfff7d0f9686 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 3b03a0826512413e6c888c3ae5de4e19331dcbff..d4dcff33ad5084d1f8fdd08cca9bc1734cff91bf 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/templates/memcachestat.tpl.php b/modules/memcacheMonitor/templates/memcachestat.tpl.php index 9a9a3399d313d69f9331ac08a7903cc42e9ed9b0..e3815c72bd5551ae0d1b7badaacf7a014e3f919e 100644 --- a/modules/memcacheMonitor/templates/memcachestat.tpl.php +++ b/modules/memcacheMonitor/templates/memcachestat.tpl.php @@ -1,42 +1,19 @@ <?php -$this->data['head'] = '<style type="text/css"> - table.statustable td, table.statustable th { - border: 1px solid #eee; - padding: 2px 6px; - } - table.statustable { - border-collapse: collapse; - } - .bmax { - border: 1px solid #555; - background: #eee; - } - .bused { - border-right: 1px solid #555; - border-bottom: 1px solid #555; - color: white; - background: #833; - } -</style> -'; - - - +$this->data['head'] = '<link href="'.$this->data['baseurlpath'].'assets/css/memcacheMonitor.css" rel="stylesheet" />'; $this->includeAtTemplateBase('includes/header.php'); $title = $this->data['title']; $table = $this->data['table']; - // Identify column headings $column_titles = array(); -foreach($table as $row_title => $row_data) { - foreach($row_data as $ct => $foo) { - if(!in_array($ct, $column_titles, true)) { - $column_titles[] = $ct; - } - } +foreach ($table as $row_title => $row_data) { + foreach ($row_data as $ct => $foo) { + if (!in_array($ct, $column_titles, true)) { + $column_titles[] = $ct; + } + } } ?> @@ -48,28 +25,28 @@ foreach($table as $row_title => $row_data) { <tr> <th></th> <?php -foreach($column_titles as $ct) { - echo '<th>' . htmlspecialchars($ct) . '</th>' . "\n"; +foreach ($column_titles as $ct) { + echo '<th>'.htmlspecialchars($ct).'</th>'."\n"; } ?> </tr> <?php -foreach($table as $row_title => $row_data) { - echo '<tr>' . "\n"; - echo '<th class="rowtitle" style="text-align: right">' . $this->t($this->data['rowtitles'][$row_title]) . '</th>' . "\n"; +foreach ($table as $row_title => $row_data) { + echo '<tr>' . "\n"; + echo '<th class="rowtitle" style="text-align: right">'.$this->t($this->data['rowtitles'][$row_title]).'</th>'."\n"; - foreach($column_titles as $ct) { - echo '<td>'; + foreach ($column_titles as $ct) { + echo '<td>'; - if(array_key_exists($ct, $row_data)) { - echo htmlspecialchars($row_data[$ct]); - } + if (array_key_exists($ct, $row_data)) { + echo htmlspecialchars($row_data[$ct]); + } - echo '</td>' . "\n"; - } + echo '</td>' . "\n"; + } - echo '</tr>' . "\n"; + echo '</tr>' . "\n"; } ?> @@ -77,15 +54,14 @@ foreach($table as $row_title => $row_data) { <?php if (array_key_exists('bytes', $this->data['statsraw']) && array_key_exists('limit_maxbytes', $this->data['statsraw'])) { - foreach($this->data['statsraw']['bytes'] as $key => $row_data) { - echo ('<h3>Storage usage on [' . $key . ']</h3>'); - $maxpix = 400; - $pix = floor($this->data['statsraw']['bytes'][$key]*$maxpix / $this->data['statsraw']['limit_maxbytes'][$key]); - - echo('<div class="bmax" style="width: ' . $maxpix. 'px"><div class="bused" style="width: ' . $pix . 'px"> - Used: ' . $table['bytes'][$key] . ' - </div>Total available: ' . $table['limit_maxbytes'][$key] . '</div>'); - } + foreach ($this->data['statsraw']['bytes'] as $key => $row_data) { + echo ('<h3>Storage usage on ['.$key.']</h3>'); + $maxpix = 400; + $pix = floor($this->data['statsraw']['bytes'][$key]*$maxpix / $this->data['statsraw']['limit_maxbytes'][$key]); + + echo '<div class="bmax" style="width: '.$maxpix.'px"><div class="bused" style="width: '.$pix.'px">Used: '. + $table['bytes'][$key].'</div>Total available: '.$table['limit_maxbytes'][$key].'</div>'; + } } $this->includeAtTemplateBase('includes/footer.php'); diff --git a/modules/memcacheMonitor/templates/memcachestat.twig b/modules/memcacheMonitor/templates/memcachestat.twig index f3d4cbd013eb655c0c9bc986f06501d7f85be7f9..fdc4af4bd03a307ad28974a4c4463185ec4ab749 100644 --- a/modules/memcacheMonitor/templates/memcachestat.twig +++ b/modules/memcacheMonitor/templates/memcachestat.twig @@ -2,7 +2,7 @@ {% extends "base.twig" %} {% block preload %} - <link href="{{ baseurlpath }}style.css" rel="stylesheet" /> + <link href="{{ baseurlpath }}assets/css/memcacheMonitor.css" rel="stylesheet" /> {% endblock %} {% block content %} diff --git a/modules/memcacheMonitor/www/style.css b/modules/memcacheMonitor/www/assets/css/memcacheMonitor.css similarity index 100% rename from modules/memcacheMonitor/www/style.css rename to modules/memcacheMonitor/www/assets/css/memcacheMonitor.css diff --git a/modules/memcacheMonitor/www/memcachestat.php b/modules/memcacheMonitor/www/memcachestat.php index 3025afce4679b47f64263c84cb86869f5e312116..78bf44f56e8c811f14c4382099ebc8ce133a2acb 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 978170178fd3388b63687fde928be04688e37944..e86585c6a5b0232d2976dbd269dff3fd9028146c 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 8feee46ee642405a78d8c1dbf8237c39d97f146a..bb396b8a0ba41d75155fdfd64833386ba988f3b4 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 00ce469725b061ab9b8b91ae0210d4584b977cfe..c64ff3463f593c0ed0565b578e069eb70e7c43be 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 abdc371602e68ed81c2d4658175551a43eda7e8a..d9c92a02790cb9c78b32355a539861b2e13af250 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 780e98c894c86ca40c45cbddb8c8878c255ce83a..5a988ce74c1b4c3d03c188dc8956890a59a6e8b8 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 2a1bbc01fe715c83f4cfb1b1c63f1d57f00a3a99..0ecb548d0206fb7c1ca395e58fbe736fec3d21c4 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 ae3682f697b90dd6601047db89792d2fe18ff869..a0f9778a2ffdf8a5f505a19b01c616d3abb5f8d5 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/templates/selectsource.twig b/modules/multiauth/templates/selectsource.twig index d308d457afa092088005cea3e90f8199ac811efd..5d1e3793e93dc82d3752390d1ab24013aa6d560b 100644 --- a/modules/multiauth/templates/selectsource.twig +++ b/modules/multiauth/templates/selectsource.twig @@ -6,17 +6,13 @@ <p>{{ '{multiauth:multiauth:select_source_text}'| trans }}</p> <form action="{{ selfUrl|escape('html') }}" method="get"> - <input type="hidden" name="AuthState" value="{{ authstate|escape('html') }} " /> + <input type="hidden" name="AuthState" value="{{ authstate|escape('html') }} "> <ul> {% for key, source in sources %} {% set name = ('src-' ~ source.source64) %} {% set button = ('button-' ~ source.source) %} <li class="{{ source.css_class|escape('html') }} authsource"> - {% if source.source == preferred %} - <input type="submit" name="{{ name|escape('html') }}" autofocus="autofocus" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" /> - {% else %} - <input type="submit" name="{{ name|escape('html') }}" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}" /> - {% endif %} + <input type="submit" name="{{ name|escape('html') }}" id="{{ button|escape('html') }}" value="{{ source.text|escape('html') }}"{%- if source.source == preferred %} autofocus{% endif -%}> {% if source.help %} <p>{{ source.help|escape('html') }}</p> {% endif %} diff --git a/modules/multiauth/www/selectsource.php b/modules/multiauth/www/selectsource.php index 70c889d8a5646912ea17c0e2ebfcc647bb347167..287f7808eab880abd9749df3e665f90f4b836fac 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 8ec4aff777b46bbf6b00b9a30d7f023f139a300e..eaf32c44fcb6a63a3c7920817cb995599f76e4e6 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; } @@ -238,22 +239,19 @@ class Negotiate extends \SimpleSAML\Auth\Source */ protected function sendNegotiate($params) { + $config = \SimpleSAML\Configuration::getInstance(); + $url = htmlspecialchars(\SimpleSAML\Module::getModuleURL('negotiate/backend.php', $params)); $json_url = json_encode($url); header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: Negotiate', false); - echo <<<EOF -<html> - <head> - <script type="text/javascript">window.location = $json_url</script> - <title>Redirect to login</title> - </head> -<body> - <p>Your browser seems to have Javascript disabled. Please click <a href="$url">here</a>.</p> -</body> -</html> -EOF; + + $t = new \SimpleSAML\XHTML\Template($config, 'negotiate:redirect.twig'); + $t->data['baseurlpath'] = \SimpleSAML\Module::getModuleUrl('negotiate'); + $t->data['url'] = $url; + $t->data['json_url'] = $json_url; + $t->show(); } @@ -284,7 +282,7 @@ EOF; \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); } @@ -311,7 +309,7 @@ EOF; $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; } } @@ -327,13 +325,11 @@ EOF; // 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); } } @@ -352,7 +348,7 @@ EOF; 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/templates/redirect.twig b/modules/negotiate/templates/redirect.twig new file mode 100644 index 0000000000000000000000000000000000000000..3a69556eec3127cc60c5dec5ab09fac27d970857 --- /dev/null +++ b/modules/negotiate/templates/redirect.twig @@ -0,0 +1,11 @@ +<!DOCTYPE HTML> +<html lang="en-US"> + <head> + <script src="{{ baseurlpath }}/assets/js/redirect.js"></script> + <title>Redirect to login</title> + </head> + <body> + <p>Your browser seems to have Javascript disabled. Please click <a id="redirect" href="{{ url }}">here</a>.</p> + </body> +</html> + diff --git a/modules/negotiate/www/assets/js/redirect.js b/modules/negotiate/www/assets/js/redirect.js new file mode 100644 index 0000000000000000000000000000000000000000..3b829d111db9ff4fbbb28f36c7ccb8dc87ce0277 --- /dev/null +++ b/modules/negotiate/www/assets/js/redirect.js @@ -0,0 +1,3 @@ +document.addEventListener('DOMContentLoaded', function () { + window.location = document.querySelector('#redirect'); +}); diff --git a/modules/negotiate/www/backend.php b/modules/negotiate/www/backend.php index 07550c9e07337cc1d9cc2aef6bfd5c0aa47f0bdc..8a5222f26dd378995e108b38105ce3fb445615c8 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 390e712e42b339774fe719f29c5c658e2833522b..c4ffd87a52ee21a5553fcb6d5277f5a2066c1bbf 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 a99f2acf121553267045dedf33ee739d66f1521a..475acb3e24b900a45ac5a2df07780645facc67f5 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 634cf63eda6bd278f4174c24ece8330bbef85643..0f7b81bca12e803e3a516acf48d91129201d2498 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 5114fff1ff0ddca40b849e6cde55a75a8377c471..b6607e6feb6bfeb4372dd1c50462295f6325821d 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 5469dab2d3bfa0d114fceddf926ee49ad4666bf2..ee5725cb1276546407f04b9e43d984ccf496cc93 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 aea40cc86af0493e27c0389ced974b84ae71332e..984638b6fb98366ceee50d54f7b62d57812adf49 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 7ea0d8dfe4fcf0ba74082b707849564ebe885adf..994241b331a6dbd442be0012988f12d4fd7623ce 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 4c97f36f57300b845bbecb62620bff0241371cf9..58a58d0100c456c4e76c26b37de07c80fc334c8c 100644 --- a/modules/oauth/templates/registry.edit.tpl.php +++ b/modules/oauth/templates/registry.edit.tpl.php @@ -1,21 +1,18 @@ <?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/resources/style.css" />' . "\n"; -$this->data['head'] .= '<script type="text/javascript"> -$(document).ready(function() { - $("#tabdiv").tabs(); -}); -</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'); +echo '<h1>OAuth Client</h1>'; -echo('<h1>OAuth Client</h1>'); +echo $this->data['form']; -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.edit.twig b/modules/oauth/templates/registry.edit.twig index baa44d4f966634fc952e48ad96ad3b1aa21ee30e..ad9345d731a93a397528e1c6e2c0a05d7dd940f6 100644 --- a/modules/oauth/templates/registry.edit.twig +++ b/modules/oauth/templates/registry.edit.twig @@ -2,21 +2,11 @@ {% extends "base.twig" %} {% block preload %} - <link href="{{ baseurlpath }}resources/style.css" rel="stylesheet" /> + <link href="{{ baseurlpath }}assets/css/oauth.css" rel="stylesheet"> {% endblock %} {% block postload %} -<script type="text/javascript"> - $(document).ready(function() { - $("#tabdiv").tabs(); - $('ul.tabset_tabs li').click( - function() { - $("html, body").animate({ scrollTop: 0 }, "slow"); - } - ) - - }); -</script> + <script src="{{ baseurlpath}}assets/js/oauth.js"></script> {% endblock %} {% block content %} diff --git a/modules/oauth/templates/registry.list.php b/modules/oauth/templates/registry.list.php index e17329e52467e6c5da9271872b6ef5164b7dcab4..912f5a71ce43a86feac71e368b7f04dd9648d630 100644 --- a/modules/oauth/templates/registry.list.php +++ b/modules/oauth/templates/registry.list.php @@ -1,51 +1,47 @@ <?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/resources/style.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('<h2>Your clients</h2>'); -echo('<table class="metalist" style="width: 100%">'); -$i = 0; $rows = array('odd', 'even'); -foreach($this->data['entries']['mine'] AS $entryc ) { - $entry = $entryc['value']; - $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']) . '">edit</a> - <a href="registry.php?delete=' . urlencode($entry['key']) . '">delete</a> - </td></tr>'); +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 '<h2>Your clients</h2>'; +echo '<table class="metalist" style="width: 100%">'; +$i = 0; +$rows = array('odd', 'even'); +foreach ($this->data['entries']['mine'] as $entryc) { + $entry = $entryc['value']; + $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']). + '">edit</a><a href="registry.php?delete='.urlencode($entry['key']).'">delete</a></td></tr>'; } if ($i == 0) { - echo('<tr><td colspan="3">No entries registered</td></tr>'); + echo'<tr><td colspan="3">No entries registered</td></tr>'; } -echo('</table>'); - -echo('<p><a href="registry.edit.php">Add new client</a></p>'); - -echo('<h2>Other clients</h2>'); -echo('<table class="metalist" style="width: 100%">'); -$i = 0; $rows = array('odd', 'even'); -foreach($this->data['entries']['others'] AS $entryc ) { - $entry = $entryc['value']; - $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') . ' - </td></tr>'); +echo '</table>'; + +echo '<p><a href="registry.edit.php">Add new client</a></p>'; + +echo '<h2>Other clients</h2>'; +echo '<table class="metalist" style="width: 100%">'; +$i = 0; +$rows = array('odd', 'even'); +foreach ($this->data['entries']['others'] as $entryc) { + $entry = $entryc['value']; + $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'). + '</td></tr>'; } if ($i == 0) { - echo('<tr><td colspan="3">No entries registered</td></tr>'); + echo '<tr><td colspan="3">No entries registered</td></tr>'; } -echo('</table>'); +echo '</table>'; $this->includeAtTemplateBase('includes/footer.php'); - diff --git a/modules/oauth/templates/registry.list.twig b/modules/oauth/templates/registry.list.twig index e6ec234c6020d7623373ee2dd0de468033250f2a..86bc5a6792a26489a6d52ec13b65538ab764ca82 100644 --- a/modules/oauth/templates/registry.list.twig +++ b/modules/oauth/templates/registry.list.twig @@ -2,7 +2,7 @@ {% extends "base.twig" %} {% block preload %} - <link href="{{ baseurlpath }}style.css" rel="stylesheet" /> + <link href="{{ baseurlpath }}assets/css/oauth.css" rel="stylesheet" /> {% endblock %} {% block content %} @@ -12,7 +12,7 @@ <table class="metalist" style="width: 100%;"> {% for key, entryc in entries.mine %} - {% if loop.index0 % 2 == 0 %} + {% if loop.index0 is even %} {% set class = 'even' %} {% else %} {% set class = 'odd' %} @@ -36,7 +36,7 @@ <table class="metalist" style="width: 100%"> {% for key, entryc in entries.others %} - {% if loop.index0 % 2 == 0 %} + {% if loop.index0 is even %} {% set class = 'even' %} {% else %} {% set class = 'odd' %} diff --git a/modules/oauth/templates/registry.saved.php b/modules/oauth/templates/registry.saved.php index 0ff62eb50fb116c93272588995898d3b371b3299..2e4bd27a92a916384f614e8b55fd058803e9c199 100644 --- a/modules/oauth/templates/registry.saved.php +++ b/modules/oauth/templates/registry.saved.php @@ -1,15 +1,8 @@ <?php - - $this->includeAtTemplateBase('includes/header.php'); - -echo('<h1>OAuth Client saved</h1>'); - -echo('<p><a href="registry.php">Go back to OAuth client listing</a></p>'); - - +echo '<h1>OAuth Client saved</h1>'; +echo '<p><a href="registry.php">Go back to OAuth client listing</a></p>'; $this->includeAtTemplateBase('includes/footer.php'); - diff --git a/modules/oauth/www/resources/style.css b/modules/oauth/www/assets/css/oauth.css similarity index 71% rename from modules/oauth/www/resources/style.css rename to modules/oauth/www/assets/css/oauth.css index 4df7a79504106ad9102dfb88d797561b12f9a55b..7b8ad7e92cb2d9fcf4f6f57ecaf714898bd15fa3 100644 --- a/modules/oauth/www/resources/style.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/assets/js/oauth.js b/modules/oauth/www/assets/js/oauth.js new file mode 100644 index 0000000000000000000000000000000000000000..442c63effcc4101a5f3ca02b50fb522cb83fd229 --- /dev/null +++ b/modules/oauth/www/assets/js/oauth.js @@ -0,0 +1,3 @@ +document.addEventListener('DOMContentLoaded', function () { + $("#tabdiv").tabs(); +}); diff --git a/modules/oauth/www/getUserInfo.php b/modules/oauth/www/getUserInfo.php index d793ed97345b2131f77f69495fe027c536630d35..ad9f878c8b511be1eaa9c87a1ff7ac15120f7b22 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 053f7737f5096a972c4c2cc8fecd5f08aedb6431..b475e0aa98d0b3bc0c49f0a3a799d150556b9fc1 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 4fbdcd1ed4f75a928eaff29edbd5ae4f5dcee245..9f97762ac5bb30a51119345f0ff8d4d0c83c9f64 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 e390ce25052b7934265427d374f532bc93b8d612..99cdaf4f959b0c1d9b849d325073e759d0fa14e0 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 699837c0551a77df3b56b810f610d6b63436c454..5fffdf6087a68da043637a6d332ce2c22e506725 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 52d722c112f7f76929b34bf87a903d8e39283b9b..a27bb343da3535e552cae38ce91c10687fc6c7c1 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 41f2912d875219502a63b366ae7a1ecdfc886ef3..3d09fa9c33334cd53a9dd6d49b669fa50ddc0856 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/preprodwarning/templates/warning.twig b/modules/preprodwarning/templates/warning.twig index 9a86ffb69eab0654e68e8d54dba08e34dfa6e845..838dd072b1d946abb43b16c41846dc1cf7afc13f 100644 --- a/modules/preprodwarning/templates/warning.twig +++ b/modules/preprodwarning/templates/warning.twig @@ -7,11 +7,10 @@ <p>{% trans %}You are now accessing a pre-production system. This authentication setup is for testing and pre-production verification only. If someone sent you a link that pointed you here, and you are not <i>a tester</i> you probably got the wrong link, and should <b>not be here</b>.{% endtrans %}</p><br /> {% for name,value in yesData %} - <input type="hidden" name="{{ name }}" value="{{ value }}" /> + <input type="hidden" name="{{ name }}" value="{{ value }}"> {% endfor %} <p> - <input type="submit" name="yes" class="pure-button pure-button-red" value="{{'Yes, I know I am accessing a pre-production system'|trans}}" /> - + <input type="submit" name="yes" class="pure-button pure-button-red" value="{{'Yes, I know I am accessing a pre-production system'|trans}}" autofocus> </p> </form> diff --git a/modules/radius/lib/Auth/Source/Radius.php b/modules/radius/lib/Auth/Source/Radius.php index c37238e826973f2be3e0c1e674b33730832bb743..4709f3bec50b5fb339cfa3866d0665b5affb36b9 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 c7bc7e6f17d632af01b5f4c39f17d6508a6035c2..c42d2c313e75b66cb6855a2b353e7033e1ebdff9 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 25a70078156e207d741039d470fa2e483470ae6c..e1017175bcfef737ac6d6e586195fedb1fbe08d8 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 12115dc37dfb5769db9cdbeca9193c47c349f7f7..c5360854e7904bb1ba721eafd5d5937093f0080b 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 b288ef107e8d71cf6c6959452522ab3598270ab5..e45b846ff89c99987927d99907da775750c7a43d 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 a6d8ce0ed4b075b57fe443ee50d6b4d3e6e188b3..15c3e56ba049f7d3f64a8766585656289ab27d6b 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 42c63aa5c38e831c00d01ae5a95283d5355c3589..5309d081ef8b762973b47373bee5397ac45bcb43 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 f07ff36e2ff644f25cd969f4138fbe563f72b239..0df0a9607bef6c5c9d2c87734d4e7c30774001ce 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 b3db87991abdd11fb712c6bcc843c8c91b29f148..641c246048a16ce5230f518a4032be01beaa3c4a 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 7ed92b3c32c02401c7dcdbc7ae81e46f4985aac6..abc9140928310dd9770d68cc0f61734cde2a7bdc 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 c6be5c70149998fefed8fd312a71d14ed3d9f21a..66392f4ce3e07820d59899640cab0bbdb1ce4819 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 859c287832028318b9bd94b090ddd7f4fcb2acc1..75504252d5eeace1967ea6855b5479a46c74a728 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 8b9cc250f93412fe13dff9583d1197256eb43a5c..710966efdb5b53980cb8d8c718b4a561c375516e 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 7ba3199e33d86cfbe33551e06ad7713de1b3b053..543ebbba9c4c284bca626fc710f08d87b212a7d9 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 ae85a1a208d665098b62ce46e6d626649b35cf65..dcea2adefae82eb67b63a257157606b631f0dbb9 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 cf34bff6121205914565cc434813e7973b006db3..ba9f69ada602d490a9f01bf6593e81a123f02800 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 d7302529e7d3aa9437c2e13a7949f13e2f696e4e..ccfd7daecd514b6e5aff555aec99f92ecd4fdded 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 4a23cf7c6159edb7dc2bbbd8e2a05246c5bbfffc..d2aebb452c0c4039d2d2e2751f49392395cb50b5 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', 'pairwise-id', @@ -26,18 +26,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. @@ -54,29 +54,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.'); } } @@ -85,12 +85,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]; } } } @@ -98,7 +99,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.'); } @@ -118,7 +119,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 388ffe5c35e6503c1a1632dad3e1a2798d216e7c..4ed5af03638a745bf18ff6d8f1be44618e84aa64 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 f968dbc9c695d8be002de780289314e9d8a9e791..2ec835f9ad1129f6ba5e7c2ad5da877ec104d62a 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 52f5842ea907791a23fb8be53b27e59209b20613..0f0f7bfbf64d2b3e101580181b4791592be2c917 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 071318124d4b9fc002bbdb5a09445361973d20bb..440780d02230ca0bf7ed3a79b942a127b966d722 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 16a21cdd187033b0c131f6f9edfdfd621a00b884..eb582159f855e95967911ea68caf0cd852744b98 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 b86b480d3121d3c8dd8a6f8b7bda1a86332d0163..a3ee4952cc347d567d4d044f4bbd83b05b7a7b5d 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 85117477c9bdc3d11014f50899868f44dc50bb85..879ee3ee784c292f68cd979d66420799b6251085 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 a4a003abb90488cda913eb43949dfa8780b50d19..750a5d0526e0aa3aa494e6f0ffdba9dc70dbef6c 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 9a022e341194b820382c2e3a941c66a7b61f4b99..dbdba27e6f84bc04a32ddb4d6e8fcc32205d08b0 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 b62cfb62494ab703f3e82b3b2ff866a0f8ce85e1..ae9807df9ea6907992b4e25c7aad2921df49fcd2 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 78209d03e98880ab2a9c0accc076de53b47b397c..061af6e62c8029a3eeea32de3a221c4b811f496b 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 072ef33b7d92b867acf0854b9796273141bd10bd..087dffcb2376eb0e2c112c7e46a2e197f81c241d 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 d04204df951894a9a273d83bb63e8a0eb29e4e70..ac172a28e359e34c007ca8e86e0966afd5cabe46 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 fcb7377fd4a0aafdba04dec9d6f855617f8b857a..0abd90416cf158dcf7581ae9852e1e62d8e7d85f 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 d94ee7c03ce89f31f769e6f18bed9e22b602dc5f..5b7b85d943106c7758fe20e9fadff497dd5732c6 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 7d890848c81863672acff24e629a18121790f53b..cc8fed1497fc0f4660bc999fb3300bafb8494801 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 5ceca8590c7a6a7f8f278909ac25a4ddabfcd3e5..469bec780c88e611d8f57086060ebfd6ffff1382 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 89d9f1c78fbeaf796627e3e110b2150361f4d8b0..1f76f6b4709791447db69970aafcf7d666e02175 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 91cca855098d7deb8898e2f7c949dafde2e1e118..11e72e99a14aa2c2e013fb734b26abffa5490fba 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/statistics.css") . '" />' . "\n"; -$this->data['head'] .= '<script type="text/javascript" src="' . SimpleSAML\Module::getModuleURL("statistics/assets/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/statistics.twig b/modules/statistics/templates/statistics.twig index f3031f5c4cc8dead578cf072ae984582b21dd832..796e45310166cad01fc116f179c8665987da229a 100644 --- a/modules/statistics/templates/statistics.twig +++ b/modules/statistics/templates/statistics.twig @@ -2,11 +2,11 @@ {% extends "base.twig" %} {% block preload %} - <link href="{{ baseurlpath }}assets/statistics.css" rel="stylesheet" /> + <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" /> {% endblock %} {% block postload %} -<script type="text/javascript" src="{{ baseurlpath }}assets/statistics.js"></script> +<script type="text/javascript" src="{{ baseurlpath }}assets/js/statistics.js"></script> {% endblock %} {% block content %} @@ -154,7 +154,7 @@ <th class="category">Data range</th> </tr> {% for key, value in summaryDataset %} - {% if loop.index0 % 2 == 0 %} + {% if loop.index0 is even %} {% set class = 'even' %} {% else %} {% set class = 'odd' %} @@ -186,17 +186,16 @@ <th>Time</th> <th>Total</th> {% for key, value in topdelimiters %} - {% set keyName = key %} - {% if delimiterPresentation[key] is defined %} - {% set keyName = delimiterPresentation[key] %} + {% set keyName = value %} + {% if delimiterPresentation[value] is defined %} + {% set keyName = delimiterPresentation[value] %} {% endif %} <th>{{ keyName }}</th> {% endfor %} </tr> - {% set i = 0 %} {% for slot, dd in debugdata %} - {% if i % 2 == 0 %} + {% if loop.index0 is even %} {% set class = 'even' %} {% else %} {% set class = 'odd' %} @@ -206,8 +205,8 @@ <td>{{ dd[0] }}</td> <td class="datacontent">{{ dd[1] }}</td> {% for key, value in topdelimiters %} - {% if results.slot is defined %} - <td class="datacontent">{{ results.slot.key }}</td> + {% if results[slot] is defined %} + <td class="datacontent">{{ results[slot][value] }}</td> {% else %} <td class="datacontent"> </td> {% endif %} diff --git a/modules/statistics/templates/statmeta.tpl.php b/modules/statistics/templates/statmeta.tpl.php index 9af5a032ef3ce5b9caf74256de5bbb8c9ca6b885..324b4e0c5c2ad26a0abf5e3b3c2ee82d98ec3a0b 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/style.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/templates/statmeta.twig b/modules/statistics/templates/statmeta.twig index dd2c475c552376eb815c69729eef252f222ab9b4..09808e837a0d97818e143582d9915199cfe24d43 100644 --- a/modules/statistics/templates/statmeta.twig +++ b/modules/statistics/templates/statmeta.twig @@ -2,7 +2,7 @@ {% extends "base.twig" %} {% block preload %} - <link href="{{ baseurlpath }}style.css" rel="stylesheet" /> + <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" /> {% endblock %} {% block content %} diff --git a/modules/statistics/www/assets/css/statistics.css b/modules/statistics/www/assets/css/statistics.css new file mode 100644 index 0000000000000000000000000000000000000000..4d0d163d600681ffe26fa34cee7cd7cbd9505bc4 --- /dev/null +++ b/modules/statistics/www/assets/css/statistics.css @@ -0,0 +1,127 @@ +@media all { + div#content { + margin: .4em ! important; + } + + .tableview { + border-collapse: collapse; + border: 1px solid #ccc; + margin: 1em; + width: 80%; + } + + .tableview th, .tableview td { + border: 1px solid #ccc; + padding: 0px 5px; + } + + .tableview th { + background: #e5e5e5; + } + + .tableview tr.total td { + color: #500; font-weight: bold; + } + + .tableview tr.even td { + background: #f5f5f5; + border-top: 1px solid #e0e0e0; + border-bottom: 1px solid #e0e0e0; + } + + .tableview th.value, .tableview td.value { + text-align: right; + } + + table.timeseries tr.odd td { + background-color: #f4f4f4; + } + + table.timeseries td { + padding-right: 2em; border: 1px solid #ccc + } + + td.datacontent { + text-align: right; + } + + table.selecttime { + width: 100%; + border: 1px solid #ccc; + background: #eee; + margin: 1px 0px; padding: 0px; + } + + td.selecttime_icon { + width: 50px; + padding: 0px; + } + + td.selecttime_icon img { + margin: 0px; + } + + td.selecttime_link_grey { + color: #ccc; + } + + td.td_right { + text-align: right; + } + td.td_next_right { + padding-right: 4px; + } + td.td_left { + text-align: left; + } + + p.p_right { + text-align: right; + } + + form { + display: inline; + } + + table#statmeta { + width: 100%; + } + + ul.tabset_tabs { + margin: 0px; + padding: 0px; + list-style: none; + } + + ul.tabset_tabs li { + background: none; + color: #222; + display: inline-block; + padding: 10px 15px; + cursor: pointer; + } + + ul.tabset_tabs li.current { + background: #ededed; + color: #222; + } + + .tabset_content { + display: none; + background: #ededed; + padding: 15px; + } + + .tabset_content.current { + display: inherit; + } + + #graph img { + max-width: 77%; + height: auto; + } + #table img { + max-width: 77%; + height: auto; + } +} diff --git a/modules/statistics/www/assets/js/statistics.js b/modules/statistics/www/assets/js/statistics.js new file mode 100644 index 0000000000000000000000000000000000000000..54a72551d90bc1b501e5c2d01f0b83879af7efcc --- /dev/null +++ b/modules/statistics/www/assets/js/statistics.js @@ -0,0 +1,8 @@ +$(document).ready(function () { + $("#tabdiv").tabs(); + $('ul.tabset_tabs li').click( + function () { + $("html, body").animate({ scrollTop: 0 }, "slow"); + } + ) +}); diff --git a/modules/statistics/www/assets/statistics.js b/modules/statistics/www/assets/statistics.js index d7faf312f3381f85c80dce9ff96bdf2c9ddbc982..54a72551d90bc1b501e5c2d01f0b83879af7efcc 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 4a38467cec9d475cae7eab87bf81aaff96443d00..ac59688242ba423aa112792b431320e1dcd7d3c0 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 442723d0bd8961c0ab94b85bc2db59167fed57a8..dd252bb26e1b66f21b21e5c63ca3b9067be4c8c3 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/templates/_table.twig b/templates/_table.twig index 5d8d4aff6fc954ecbfe1d78978f958a739c55095..6af434995d808f3d2ca72ff0f279d6a94b91fcd5 100644 --- a/templates/_table.twig +++ b/templates/_table.twig @@ -1,5 +1,5 @@ -<table id="table_with_attributes" class="attributes pure-table pure-table-striped pure-table-attributes" summary="attribute overview"> +<table id="table_with_attributes" class="attributes pure-table pure-table-striped pure-table-attributes" summary="attribute overview"> {% for name, values in items %} <tr class="{{ cycle(['odd', 'even'], loop.index0) }}"> @@ -21,4 +21,4 @@ </td> </tr> {% endfor %} -</table><br> \ No newline at end of file +</table><br> diff --git a/templates/base.twig b/templates/base.twig index 02fdc60d3ee36f425bbf099c470092c9f282a638..e366f37522b22418abf8947615ba2f587e22dfa3 100644 --- a/templates/base.twig +++ b/templates/base.twig @@ -12,7 +12,7 @@ {% if jquery and jquery.css %} <link rel="stylesheet" media="screen" type="text/css" href="/{{ baseurlpath }}resources/uitheme1.8/jquery-ui.css" /> {% endif %} - {% if isRTL %}<link rel="stylesheet" type="text/css" href="/{{ baseurlpath }}assets/css/src/default-rtl.css" />{% endif %} + {%- if isRTL %}<link rel="stylesheet" type="text/css" href="/{{ baseurlpath }}assets/css/src/default-rtl.css" />{% endif -%} <meta name="robots" content="noindex, nofollow"> {% block preload %}{% endblock %} </head> diff --git a/templates/includes/header.php b/templates/includes/header.php index d79b006e1b5c76aae12633d2e5bcef35d81e8faf..82c894fb9246bfd994e7f177a9499993eeccd1fd 100644 --- a/templates/includes/header.php +++ b/templates/includes/header.php @@ -1,7 +1,5 @@ <?php - - /** * Support the htmlinject hook, which allows modules to change header, pre and post body on all pages. */ @@ -11,7 +9,6 @@ $this->data['htmlinject'] = [ 'htmlContentHead' => [], ]; - $jquery = []; if (array_key_exists('jquery', $this->data)) { $jquery = $this->data['jquery']; @@ -68,23 +65,22 @@ if (!empty($jquery)) { if ($version == '1.8') { if (isset($jquery['core']) && $jquery['core']) { - echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery-1.8.js"></script>' . "\n"); + echo '<script type="text/javascript" src="/'.$this->data['baseurlpath'].'resources/jquery-1.8.js"></script>'."\n"; } if (isset($jquery['ui']) && $jquery['ui']) { - echo('<script type="text/javascript" src="/' . $this->data['baseurlpath'] . 'resources/jquery-ui-1.8.js"></script>' . "\n"); + echo '<script type="text/javascript" src="/'.$this->data['baseurlpath'].'resources/jquery-ui-1.8.js"></script>'."\n"; } if (isset($jquery['css']) && $jquery['css']) { - echo('<link rel="stylesheet" media="screen" type="text/css" href="/' . $this->data['baseurlpath'] . - 'resources/uitheme1.8/jquery-ui.css" />' . "\n"); + echo '<link rel="stylesheet" media="screen" type="text/css" href="/'.$this->data['baseurlpath']. + 'resources/uitheme1.8/jquery-ui.css" />'."\n"; } } } if (isset($this->data['clipboard.js'])) { - echo '<script type="text/javascript" src="/' . $this->data['baseurlpath'] . - 'resources/clipboard.min.js"></script>' . "\n"; + echo '<script type="text/javascript" src="/'.$this->data['baseurlpath'].'resources/clipboard.min.js"></script>'."\n"; } if (!empty($this->data['htmlinject']['htmlContentHead'])) { @@ -93,37 +89,24 @@ if (!empty($this->data['htmlinject']['htmlContentHead'])) { } } - - - if ($this->isLanguageRTL()) { ?> <link rel="stylesheet" type="text/css" href="/<?php echo $this->data['baseurlpath']; ?>resources/default-rtl.css" /> <?php } ?> - - <meta name="robots" content="noindex, nofollow" /> - <?php if (array_key_exists('head', $this->data)) { - echo '<!-- head -->' . $this->data['head'] . '<!-- /head -->'; + echo '<!-- head -->'.$this->data['head'].'<!-- /head -->'; } ?> </head> <?php $onLoad = ''; if (array_key_exists('autofocus', $this->data)) { - $onLoad .= 'SimpleSAML_focus(\'' . $this->data['autofocus'] . '\');'; -} -if (isset($this->data['onLoad'])) { - $onLoad .= $this->data['onLoad']; -} - -if ($onLoad !== '') { - $onLoad = ' onload="' . $onLoad . '"'; + $onLoad .= ' onload="SimpleSAML_focus(\''.$this->data['autofocus'].'\');"'; } ?> <body<?php echo $onLoad; ?>> @@ -198,13 +181,12 @@ if ($onLoad !== '') { if ($current) { $textarray[] = $langnames[$lang]; } else { - $textarray[] = '<a href="' . htmlspecialchars( + $textarray[] = '<a href="'.htmlspecialchars( \SimpleSAML\Utils\HTTP::addURLParameters( \SimpleSAML\Utils\HTTP::getSelfURL(), [$this->getTranslator()->getLanguage()->getLanguageParameterName() => $lang] ) - ) . '">' . - $langnames[$lang] . '</a>'; + ).'">'.$langnames[$lang].'</a>'; } } echo join(' | ', $textarray); @@ -212,13 +194,9 @@ if ($onLoad !== '') { } } - - ?> <div id="content"> - - <?php if (!empty($this->data['htmlinject']['htmlContentPre'])) { diff --git a/tests/modules/consent/lib/Auth/Process/ConsentTest.php b/tests/modules/consent/lib/Auth/Process/ConsentTest.php index cf8e0a098f0521486ab61f4380915f909c0fd111..c74696d7cc873de35a8c726bed747744c108cba5 100644 --- a/tests/modules/consent/lib/Auth/Process/ConsentTest.php +++ b/tests/modules/consent/lib/Auth/Process/ConsentTest.php @@ -186,7 +186,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); @@ -204,15 +204,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']); } } diff --git a/tests/www/TemplateTest.php b/tests/www/TemplateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..dda326a62788f6639985dfe2fca869f6a3155589 --- /dev/null +++ b/tests/www/TemplateTest.php @@ -0,0 +1,66 @@ +<?php +/** + * Simple test for syntax-checking Twig-templates. + * + * @author Tim van Dijen <tvdijen@gmail.com> + * @package SimpleSAMLphp + */ + +namespace SimpleSAML\Test\Web; + +use PHPUnit\Framework\TestCase; + +use \SimpleSAML\Configuration; +use \SimpleSAML\XHTML\Template; +use \SimpleSAML\Module; + +class TemplateTest extends TestCase +{ + public function testSyntax() + { + $config = Configuration::loadFromArray([ + 'language.i18n.backend' => 'gettext/gettext', + 'module.enable' => array_fill_keys(Module::getModules(), true), + ]); + Configuration::setPreLoadedConfig($config); + + $basedir = dirname(dirname(dirname(__FILE__))).DIRECTORY_SEPARATOR.'templates'; + + // Base templates + $files = array_diff(scandir($basedir), array('.', '..')); + foreach ($files as $file) { + if (preg_match('/.twig$/', $file)) { + $t = new Template($config, $file); + ob_start(); + try { + $t->show(); + $this->addToAssertionCount(1); + } catch (\Twig_Error_Syntax $e) { + $this->fail($e->getMessage().' in '.$e->getFile().':'.$e->getLine()); + } + ob_end_clean(); + } + } + + // Module templates + foreach (Module::getModules() as $module) { + $basedir = Module::getModuleDir($module).DIRECTORY_SEPARATOR.'templates'; + if (file_exists($basedir)) { + $files = array_diff(scandir($basedir), array('.', '..')); + foreach ($files as $file) { + if (preg_match('/.twig$/', $file)) { + $t = new Template($config, $module.':'.$file); + ob_start(); + try { + $t->show(); + $this->addToAssertionCount(1); + } catch (\Twig_Error_Syntax $e) { + $this->fail($e->getMessage().' in '.$e->getFile().':'.$e->getLine()); + } + ob_end_clean(); + } + } + } + } + } +}