diff --git a/composer.json b/composer.json index 154d8568d62037d2911e706de41a7c798414d4a8..aa32bf7b33f07d44f740021e188edf4705e3514c 100644 --- a/composer.json +++ b/composer.json @@ -44,6 +44,7 @@ "ext-mbstring": "*", "gettext/gettext": "^4.6", "phpmailer/phpmailer": "^6.1", + "simplesamlphp/assert": "0.0.10", "simplesamlphp/saml2": "^4.1", "simplesamlphp/twig-configurable-i18n": "^2.1", "symfony/cache": "^4.0", @@ -57,8 +58,7 @@ "symfony/routing": "^4.0", "symfony/var-exporter": "^5.0", "symfony/yaml": "^4.0", - "twig/twig": "~2.0", - "webmozart/assert": "~1.7" + "twig/twig": "~2.0" }, "require-dev": { "ext-curl": "*", diff --git a/composer.lock b/composer.lock index 39aa366b6c718f8cea75e34f9806720c794fd1a6..a6717441774900fc42fe0694bf68051a6de3b861 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7918f96090daaec62106ab652c53210c", + "content-hash": "aaeb90faf72b11d0e427a3a375364c60", "packages": [ { "name": "gettext/gettext", @@ -377,6 +377,56 @@ ], "time": "2020-04-22T17:19:51+00:00" }, + { + "name": "simplesamlphp/assert", + "version": "v0.0.10", + "source": { + "type": "git", + "url": "https://github.com/simplesamlphp/assert.git", + "reference": "4b002bd83ea15717908c7fb26a23771d62ba41f2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/simplesamlphp/assert/zipball/4b002bd83ea15717908c7fb26a23771d62ba41f2", + "reference": "4b002bd83ea15717908c7fb26a23771d62ba41f2", + "shasum": "" + }, + "require": { + "ext-spl": "*", + "php": "^5.6 || ^7.0", + "webmozart/assert": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^8.5", + "sensiolabs/security-checker": "~6.0", + "simplesamlphp/simplesamlphp-test-framework": "^0.1.9", + "squizlabs/php_codesniffer": "~3.5", + "vimeo/psalm": "~3.11" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "v0.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "SimpleSAML\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Tim van Dijen", + "email": "tvdijen@gmail.com" + } + ], + "description": "A wrapper around webmozart/assert to make it useful beyond checking method arguments", + "time": "2020-06-12T15:40:57+00:00" + }, { "name": "simplesamlphp/saml2", "version": "v4.1.7", @@ -5202,8 +5252,5 @@ "platform-dev": { "ext-curl": "*" }, - "platform-overrides": { - "php": "7.2.31" - }, "plugin-api-version": "1.1.0" } diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index fb7dddee4b7842eb46e3d9abc33d0d6281bbad4d..a19b4878e0ee7541359cf2cf614e5f60f630afa3 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Auth; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Class for implementing authentication processing chains for IdPs. diff --git a/lib/SimpleSAML/Auth/ProcessingFilter.php b/lib/SimpleSAML/Auth/ProcessingFilter.php index 8e0e4db7f9d072c1bc16ab0ec40616fbd17a2e5a..be5c2fc5ce7de5b1c554ba80b8b7e1c043d93374 100644 --- a/lib/SimpleSAML/Auth/ProcessingFilter.php +++ b/lib/SimpleSAML/Auth/ProcessingFilter.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Auth; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Base class for authentication processing filters. diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php index 2c14c8ffb859fa0fa766da43e97f5c6bdfe47c48..f41e30c4c98e0fd3dd5e8abf928413a7b82ebffd 100644 --- a/lib/SimpleSAML/Auth/Simple.php +++ b/lib/SimpleSAML/Auth/Simple.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Auth; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Module; use SimpleSAML\Session; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Helper class for simple authentication applications. diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index 0e260d277e688de420d55e8b9d6e83bb57dfd92d..691d1fcbe92cfeffb6a39268a1b055c93fc3556c 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -4,13 +4,13 @@ declare(strict_types=1); namespace SimpleSAML\Auth; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Session; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This class defines a base class for authentication source. diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index e06cd88b051f4529ca8872f0b2e759f6a34ff140..accfc8285ce81e8b4dd1a7c7e02c5cadb0a86e57 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Auth; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Session; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This is a helper class for saving and loading state information. diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index fb2008abeed5bef1420179ba747e46be769617b1..e41303f318cb3ea0905c9bcb1266927c12916168 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -5,9 +5,9 @@ declare(strict_types=1); namespace SimpleSAML; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Configuration of SimpleSAMLphp diff --git a/lib/SimpleSAML/Error/Assertion.php b/lib/SimpleSAML/Error/Assertion.php index bf16f5b32fc4c9715eef53b3446869ccfe31c875..ff957ddd6b94347aee6a4f53686c6e6d9321891c 100644 --- a/lib/SimpleSAML/Error/Assertion.php +++ b/lib/SimpleSAML/Error/Assertion.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Error; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Class for creating exceptions from assertion failures. diff --git a/lib/SimpleSAML/Error/AuthSource.php b/lib/SimpleSAML/Error/AuthSource.php index b42ab25d0d85e6a6c4eab9dd45c65d19ea8575e9..0824f3e2bbfee0456ab6fb71161838eb719e7b3c 100644 --- a/lib/SimpleSAML/Error/AuthSource.php +++ b/lib/SimpleSAML/Error/AuthSource.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Error; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Baseclass for auth source exceptions. diff --git a/lib/SimpleSAML/Error/BadRequest.php b/lib/SimpleSAML/Error/BadRequest.php index 272cee3570192ff45b510aae7499158f9577caa8..0f50939bf5a6f04ba961c42d906d72fd316215da 100644 --- a/lib/SimpleSAML/Error/BadRequest.php +++ b/lib/SimpleSAML/Error/BadRequest.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Error; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Exception which will show a 400 Bad Request error page. diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index 46edc480872f9a929eb2a840d075ea8c7e3faca4..4e69e8e27ddf753bfa15e8fa7993d2b076b022fe 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Error; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Session; use SimpleSAML\Utils; use SimpleSAML\XHTML\Template; -use Webmozart\Assert\Assert; /** * Class that wraps SimpleSAMLphp errors in exceptions. diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index 943e9122f34db5d7abaf62323b47714fa020c263..edf708b169e806916c52eadeecd383a4b1473b32 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Error; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Base class for SimpleSAMLphp Exceptions diff --git a/lib/SimpleSAML/Error/MetadataNotFound.php b/lib/SimpleSAML/Error/MetadataNotFound.php index fe730ff388d25020a5aebf4fa166866dd5320d46..0c18067601e0198e47a7b05a93e77111a5fd17a5 100644 --- a/lib/SimpleSAML/Error/MetadataNotFound.php +++ b/lib/SimpleSAML/Error/MetadataNotFound.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Error; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Error for missing metadata. diff --git a/lib/SimpleSAML/Error/NotFound.php b/lib/SimpleSAML/Error/NotFound.php index 216f007b9eec94ee3acca17dfdfdab37381a0cc2..02b65ac325c24c53db73eb263f350dbb52df3d94 100644 --- a/lib/SimpleSAML/Error/NotFound.php +++ b/lib/SimpleSAML/Error/NotFound.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace SimpleSAML\Error; +use SimpleSAML\Assert\Assert; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Exception which will show a 404 Not Found error page. diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php index 430eb37b30bd04ebb23117c864fdd4cf9a2abb49..94f767289144c60e6fe49f75e6e75555149790e3 100644 --- a/lib/SimpleSAML/IdP.php +++ b/lib/SimpleSAML/IdP.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SimpleSAML; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\IdP\IFrameLogoutHandler; use SimpleSAML\IdP\LogoutHandlerInterface; @@ -13,7 +14,6 @@ use SimpleSAML\Error; use SimpleSAML\Metadata\MetaDataStorageHandler; use SimpleSAML\Module\saml\Error\NoPassive; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * IdP class. diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index 7ec89343fd755e92e2c82b7bb90b4b17800ba2f4..12d2601cb200d5ac62200ddc232241908f7d02e3 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\IdP; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; @@ -11,7 +12,6 @@ use SimpleSAML\IdP; use SimpleSAML\Module; use SimpleSAML\Utils; use SimpleSAML\XHTML\Template; -use Webmozart\Assert\Assert; /** * Class that handles iframe logout. diff --git a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php index 9c9705ff794e0e5ed72ee8d1ba3cb3c36ad7f407..2a555cdc321e5fe88ba4f6742eb3fb026952d1a3 100644 --- a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php +++ b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\IdP; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\IdP; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Class that handles traditional logout. diff --git a/lib/SimpleSAML/Locale/Language.php b/lib/SimpleSAML/Locale/Language.php index c457378dd78cd9746f3b90116d97e561769f6072..ac9ae56fc6b3ade533eeab279a64dc4435aea1de 100644 --- a/lib/SimpleSAML/Locale/Language.php +++ b/lib/SimpleSAML/Locale/Language.php @@ -12,10 +12,10 @@ declare(strict_types=1); namespace SimpleSAML\Locale; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; class Language { diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index 0d1188c98de445ce543433270ac822664e54421e..107020d0a7701466b391e22023560dbb0aaf2e12 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -13,10 +13,10 @@ declare(strict_types=1); namespace SimpleSAML\Locale; use Gettext\BaseTranslator; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Module; -use Webmozart\Assert\Assert; class Translate { diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 374b62f2d616603b6928d7440a881538861c8a55..10f237837cc768fb4db8b1f5b2d7c108762d33bb 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -5,12 +5,12 @@ declare(strict_types=1); namespace SimpleSAML; use Exception; +use SimpleSAML\Assert\Assert; use SimpleSAML\Logger\ErrorLogLoggingHandler; use SimpleSAML\Logger\FileLoggingHandler; use SimpleSAML\Logger\LoggingHandlerInterface; use SimpleSAML\Logger\StandardErrorLoggingHandler; use SimpleSAML\Logger\SyslogLoggingHandler; -use Webmozart\Assert\Assert; /** * The main logger class for SimpleSAMLphp. diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index e4a88e189edef243107c90a68e653cd8d7341ee3..b93f8d7b6760ccaf337798034de6d63ca96297b4 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -6,13 +6,13 @@ namespace SimpleSAML\Metadata; use SAML2\Constants; use SAML2\XML\saml\Issuer; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Utils; use SimpleSAML\Error\MetadataNotFound; use SimpleSAML\Utils\ClearableState; -use Webmozart\Assert\Assert; /** * This file defines a class for metadata handling. @@ -21,7 +21,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class MetaDataStorageHandler implements \SimpleSAML\Utils\ClearableState +class MetaDataStorageHandler implements ClearableState { /** * This static variable contains a reference to the current diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php index 36a1b894bf7099051dbf28146037486f6bd20fa4..ed0a4e2671a2f10b7927d8dde6f9aa64ceeef752 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace SimpleSAML\Metadata; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; -use Webmozart\Assert\Assert; /** * This file defines a flat file metadata source. diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php index 2ab95ddba1a730313eb2e68bc0372664a86fe78b..7d88000e10e0703fe1d7d12dd2382609b113c337 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Metadata; +use SimpleSAML\Assert\Assert; use SimpleSAML\Database; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Class for handling metadata files stored in a database. diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index 0a4af9c8309048915ded047f874260e78a302e14..08d75d427404c8e6477d9fc14d0505cd0bf0492f 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Metadata; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Class for handling metadata files in serialized format. diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index 875a488ccc731832006cb969a24282024e885e02..a48191f7e68b6c50c9a36d7e72004a52cc85bd53 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Metadata; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This abstract class defines an interface for metadata storage sources. diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 82ea3f8915edff3a9101de980e10e8c9d51b1564..1ea0a5e122f033f8d8f957c88c791219fe6ecd74 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -25,11 +25,11 @@ use SAML2\XML\mdui\UIInfo; use SAML2\XML\saml\Attribute; use SAML2\XML\saml\AttributeValue; use SAML2\XML\shibmd\Scope; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Module\adfs\SAML2\XML\fed\SecurityTokenServiceType; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Class for generating SAML 2.0 metadata from SimpleSAMLphp metadata arrays. diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index f1b0a1c850267389be7fb90a8d0b16bd7931d836..61f783e80fa9fa426265a0195df66347dcffd47b 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -35,9 +35,9 @@ use SAML2\XML\mdui\Logo; use SAML2\XML\mdui\UIInfo; use SAML2\XML\saml\Attribute; use SAML2\XML\shibmd\Scope; +use SimpleSAML\Assert\Assert; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This is class for parsing of SAML 2.0 metadata. diff --git a/lib/SimpleSAML/Metadata/Sources/MDQ.php b/lib/SimpleSAML/Metadata/Sources/MDQ.php index 10db837b9866dfbca25bfb21b042eca26fc26c52..8714d70c51bd47486f3f3456224ae103282e3e6b 100644 --- a/lib/SimpleSAML/Metadata/Sources/MDQ.php +++ b/lib/SimpleSAML/Metadata/Sources/MDQ.php @@ -5,12 +5,12 @@ declare(strict_types=1); namespace SimpleSAML\Metadata\Sources; use RobRichards\XMLSecLibs\XMLSecurityDSig; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Metadata\SAMLParser; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This class implements SAML Metadata Query Protocol diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index 2402f66d6f19a00c8d10f67c3ed6e22eb5f34665..0851b23ce11f4025a10978b764363a0074045acd 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML; +use SimpleSAML\Assert\Assert; use SimpleSAML\Kernel; use SimpleSAML\Utils; use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException; @@ -13,7 +14,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; -use Webmozart\Assert\Assert; /** * Helper class for accessing information about modules. diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 9ec54c936a0a0efbe228559ef6e9bc7a1094602e..58081d72b3ab0ac1e21e7e611224352c8dbfab27 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -5,9 +5,10 @@ declare(strict_types=1); namespace SimpleSAML; use SAML2\XML\saml\AttributeValue; +use Serializable; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * The Session class holds information about a user session, and everything attached to it. @@ -27,7 +28,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class Session implements \Serializable, Utils\ClearableState +class Session implements Serializable, Utils\ClearableState { /** * This is a timeout value for setData, which indicates that the data diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php index ef114976e048a23367cdcf19390b7b123b8a52d3..7384544c6cd1086ddbd5c03ab14c3b6243d3c8d0 100644 --- a/lib/SimpleSAML/SessionHandlerCookie.php +++ b/lib/SimpleSAML/SessionHandlerCookie.php @@ -15,8 +15,8 @@ declare(strict_types=1); namespace SimpleSAML; +use SimpleSAML\Assert\Assert; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; abstract class SessionHandlerCookie extends SessionHandler { diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index b81b58e45b1848cab8b61c26ecf0c5e0799d665e..634435cb54d7b98d6376f236539dd7e47233e6d5 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -13,9 +13,9 @@ declare(strict_types=1); namespace SimpleSAML; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; class SessionHandlerPHP extends SessionHandler { diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php index 4c565d7bc9239d0ba0e3b1893b2af898c36141f7..09f08c05d3b3a69453e1b872390b726bbbda7579 100644 --- a/lib/SimpleSAML/SessionHandlerStore.php +++ b/lib/SimpleSAML/SessionHandlerStore.php @@ -10,7 +10,7 @@ declare(strict_types=1); namespace SimpleSAML; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; class SessionHandlerStore extends SessionHandlerCookie { diff --git a/lib/SimpleSAML/Stats.php b/lib/SimpleSAML/Stats.php index 252ab2bb8ae60602588e3bd73ad7cd04fd0e6cf7..f50227bbc2e87a465c6630779a152844ebd9f52f 100644 --- a/lib/SimpleSAML/Stats.php +++ b/lib/SimpleSAML/Stats.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace SimpleSAML; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Statistics handler class. diff --git a/lib/SimpleSAML/Store/Memcache.php b/lib/SimpleSAML/Store/Memcache.php index cff7bbc9442928076f90586e84f0a129adfc0784..02049476e7819c35fb139a08cc5212b934303a1a 100644 --- a/lib/SimpleSAML/Store/Memcache.php +++ b/lib/SimpleSAML/Store/Memcache.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Store; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Store; -use Webmozart\Assert\Assert; /** * A memcache based data store. diff --git a/lib/SimpleSAML/Store/Redis.php b/lib/SimpleSAML/Store/Redis.php index cb242e3a7625d8416c4e8d33d4099ce7ce17bbee..a176c4334208fb5bf3638f04260a4615a59e95e9 100644 --- a/lib/SimpleSAML/Store/Redis.php +++ b/lib/SimpleSAML/Store/Redis.php @@ -5,10 +5,10 @@ declare(strict_types=1); namespace SimpleSAML\Store; use Predis\Client; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Store; -use Webmozart\Assert\Assert; /** * A data store using Redis to keep the data. diff --git a/lib/SimpleSAML/Store/SQL.php b/lib/SimpleSAML/Store/SQL.php index c15cf4804f60cfd050e2e8204dc32aceafb13eb1..d6d472677773b6249484d4402dbc013e02833d09 100644 --- a/lib/SimpleSAML/Store/SQL.php +++ b/lib/SimpleSAML/Store/SQL.php @@ -6,10 +6,10 @@ namespace SimpleSAML\Store; use PDO; use PDOException; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Store; -use Webmozart\Assert\Assert; /** * A data store using a RDBMS to keep the data. diff --git a/lib/SimpleSAML/Utils/Crypto.php b/lib/SimpleSAML/Utils/Crypto.php index 9f104139c88f28413bfd94d04cf303519dcd8696..c8089aab53959d312e706d4f91850dc6feec7a58 100644 --- a/lib/SimpleSAML/Utils/Crypto.php +++ b/lib/SimpleSAML/Utils/Crypto.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Utils; +use SimpleSAML\Assert\Assert; use InvalidArgumentException; use SimpleSAML\Configuration; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * A class for cryptography-related functions. diff --git a/lib/SimpleSAML/Utils/EMail.php b/lib/SimpleSAML/Utils/EMail.php index d21c8ded1f82d0c1c6c1100cbeb83c04ee9a1e67..b3cc4663177bb15b1853f2d6d2f7c572cda0f7d2 100644 --- a/lib/SimpleSAML/Utils/EMail.php +++ b/lib/SimpleSAML/Utils/EMail.php @@ -5,10 +5,10 @@ declare(strict_types=1); namespace SimpleSAML\Utils; use PHPMailer\PHPMailer\PHPMailer; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\XHTML\Template; -use Webmozart\Assert\Assert; /** * E-mailer class that can generate a formatted e-mail from array diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 3822e5facf138362a117c71190c2e8ac1a0d373f..b976626b059260ef5021efda36d2b8006f2b8915 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -16,11 +16,11 @@ use DOMElement; use DOMNode; use DOMText; use SAML2\DOMDocumentFactory; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\XML\Errors; -use Webmozart\Assert\Assert; class XML { diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 6fa300240da245a83ff7a8383e1ef92a5f1bdaf4..19417c8abed6b4d17682188c2bb34e7ce62b3ab6 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\XHTML; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Metadata\MetaDataStorageHandler; use SimpleSAML\Session; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * This class implements a generic IdP discovery service, for use in various IdP diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 41567c5f5947c78c4f42c0b8a67216e4b925bfbe..02b66313187b173bd599a3c9ce7d027b1ef779cd 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -11,6 +11,7 @@ declare(strict_types=1); namespace SimpleSAML\XHTML; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Locale\Language; use SimpleSAML\Locale\Localization; @@ -24,7 +25,6 @@ use Symfony\Component\HttpFoundation\Response; use Twig\Loader\FilesystemLoader; use Twig\TwigFilter; use Twig\TwigFunction; -use Webmozart\Assert\Assert; /** * The content-property is set upstream, but this is not recognized by Psalm diff --git a/lib/SimpleSAML/XML/Errors.php b/lib/SimpleSAML/XML/Errors.php index 5f000349c45bea4a17e286bd594c950fe3f0939c..c4bf02ec99be855b7e357f8ac4f47e9627924a96 100644 --- a/lib/SimpleSAML/XML/Errors.php +++ b/lib/SimpleSAML/XML/Errors.php @@ -15,7 +15,7 @@ declare(strict_types=1); namespace SimpleSAML\XML; use LibXMLError; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; class Errors { diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php index f4c9716bcb744e5f486376df09e517cf6ab7729c..cd08ae2c1d8666d86b51e72fffd068b3d030c426 100644 --- a/lib/SimpleSAML/XML/Signer.php +++ b/lib/SimpleSAML/XML/Signer.php @@ -18,8 +18,8 @@ use DOMElement; use DOMText; use RobRichards\XMLSecLibs\XMLSecurityDSig; use RobRichards\XMLSecLibs\XMLSecurityKey; +use SimpleSAML\Assert\Assert; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; class Signer { diff --git a/lib/SimpleSAML/XML/Validator.php b/lib/SimpleSAML/XML/Validator.php index 91cbbe5812722807c1ac97ba0e63c8d85410eb9d..793df2b52add216efcfc4bd4a5dc89213f6886b4 100644 --- a/lib/SimpleSAML/XML/Validator.php +++ b/lib/SimpleSAML/XML/Validator.php @@ -15,8 +15,8 @@ use DOMNode; use DOMDocument; use RobRichards\XMLSecLibs\XMLSecEnc; use RobRichards\XMLSecLibs\XMLSecurityDSig; +use SimpleSAML\Assert\Assert; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; class Validator { diff --git a/modules/admin/lib/Controller/Federation.php b/modules/admin/lib/Controller/Federation.php index cd1ed6fde9eba3b9c33612da2ec0bc37d1aa28af..d0e1ead676cb4bfce07f8bced91b651c9708b2b9 100644 --- a/modules/admin/lib/Controller/Federation.php +++ b/modules/admin/lib/Controller/Federation.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace SimpleSAML\Module\admin\Controller; use Exception; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\HTTP\RunnableResponse; @@ -24,7 +25,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\ResponseHeaderBag; use Symfony\Component\VarExporter\VarExporter; -use Webmozart\Assert\Assert; /** * Controller class for the admin module. diff --git a/modules/admin/lib/Controller/Menu.php b/modules/admin/lib/Controller/Menu.php index 4892a1fd794f10de5d3a73a3df98045c63244cc2..5b6c4416167ac532b84c3cea16ca6137a82f725e 100644 --- a/modules/admin/lib/Controller/Menu.php +++ b/modules/admin/lib/Controller/Menu.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\admin\Controller; +use SimpleSAML\Assert\Assert; use SimpleSAML\Locale\Translate; use SimpleSAML\Module; use SimpleSAML\XHTML\Template; -use Webmozart\Assert\Assert; /** * A class to handle the menu in admin pages. diff --git a/modules/admin/lib/Controller/Test.php b/modules/admin/lib/Controller/Test.php index 75dd3d1ce6196e69f59405012e6ebdb471225d22..16ac227195e8af82c9bea6933698a57871ad747e 100644 --- a/modules/admin/lib/Controller/Test.php +++ b/modules/admin/lib/Controller/Test.php @@ -6,6 +6,7 @@ namespace SimpleSAML\Module\admin\Controller; use SAML2\Constants; use SAML2\XML\saml\NameID; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\HTTP\RunnableResponse; @@ -16,7 +17,6 @@ use SimpleSAML\Utils; use SimpleSAML\XHTML\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Webmozart\Assert\Assert; /** * Controller class for the admin module. diff --git a/modules/core/hooks/hook_sanitycheck.php b/modules/core/hooks/hook_sanitycheck.php index d37d6c62b43fa4e81a7906215058575f85cdc103..d51d4db76307accb68f5e3f048a64f6d6287c4aa 100644 --- a/modules/core/hooks/hook_sanitycheck.php +++ b/modules/core/hooks/hook_sanitycheck.php @@ -2,7 +2,9 @@ declare(strict_types=1); -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Configuration; +use SimpleSAML\Module; /** * Hook to do sanitycheck @@ -15,7 +17,7 @@ function core_hook_sanitycheck(array &$hookinfo): void Assert::keyExists($hookinfo, 'errors'); Assert::keyExists($hookinfo, 'info'); - $config = \SimpleSAML\Configuration::getInstance(); + $config = Configuration::getInstance(); if ($config->getString('auth.adminpassword', '123') === '123') { $hookinfo['errors'][] = '[core] Password in config.php is not set properly'; @@ -40,8 +42,8 @@ function core_hook_sanitycheck(array &$hookinfo): void $mihookinfo = [ 'info' => &$info, ]; - $availmodules = SimpleSAML\Module::getModules(); - SimpleSAML\Module::callHooks('moduleinfo', $mihookinfo); + $availmodules = Module::getModules(); + Module::callHooks('moduleinfo', $mihookinfo); foreach ($info as $mi => $i) { if (isset($i['dependencies']) && is_array($i['dependencies'])) { foreach ($i['dependencies'] as $dep) { diff --git a/modules/core/lib/Auth/Process/AttributeAdd.php b/modules/core/lib/Auth/Process/AttributeAdd.php index d9b1ffd4c736afad6e8cead6929ef9b481dfd17b..5a1ff5e993547be9582c67de53d253bb239b15f9 100644 --- a/modules/core/lib/Auth/Process/AttributeAdd.php +++ b/modules/core/lib/Auth/Process/AttributeAdd.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; -use Webmozart\Assert\Assert; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; /** * Filter to add attributes. @@ -14,7 +16,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter +class AttributeAdd extends Auth\ProcessingFilter { /** * Flag which indicates wheter this filter should append new values or replace old values. @@ -46,7 +48,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter if ($values === '%replace') { $this->replace = true; } else { - throw new \Exception('Unknown flag: ' . var_export($values, true)); + throw new Exception('Unknown flag: ' . var_export($values, true)); } continue; } @@ -56,7 +58,7 @@ class AttributeAdd extends \SimpleSAML\Auth\ProcessingFilter } foreach ($values as $value) { if (!is_string($value)) { - throw new \Exception( + throw new Exception( 'Invalid value for attribute ' . $name . ': ' . var_export($values, true) ); } diff --git a/modules/core/lib/Auth/Process/AttributeAlter.php b/modules/core/lib/Auth/Process/AttributeAlter.php index 01970de301d28d0c45be9a56dfa39afff910c5a9..b9a0b3875960391d6116355c80a0086601df3602 100644 --- a/modules/core/lib/Auth/Process/AttributeAlter.php +++ b/modules/core/lib/Auth/Process/AttributeAlter.php @@ -4,8 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Filter to modify attributes using regular expressions @@ -15,7 +16,7 @@ use Webmozart\Assert\Assert; * @author Jacob Christiansen, WAYF * @package SimpleSAMLphp */ -class AttributeAlter extends \SimpleSAML\Auth\ProcessingFilter +class AttributeAlter extends Auth\ProcessingFilter { /** * Should the pattern found be replaced? diff --git a/modules/core/lib/Auth/Process/AttributeCopy.php b/modules/core/lib/Auth/Process/AttributeCopy.php index 00dcddfcdec47afbc13eb2c5807d4564f93c85f1..8fd600129d6c4a83380214ae4fae619f302ad303 100644 --- a/modules/core/lib/Auth/Process/AttributeCopy.php +++ b/modules/core/lib/Auth/Process/AttributeCopy.php @@ -4,7 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; -use Webmozart\Assert\Assert; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; /** * Attribute filter for renaming attributes. @@ -21,7 +23,7 @@ use Webmozart\Assert\Assert; * ), * */ -class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter +class AttributeCopy extends Auth\ProcessingFilter { /** * Assosiative array with the mappings of attribute names. @@ -42,11 +44,11 @@ class AttributeCopy extends \SimpleSAML\Auth\ProcessingFilter foreach ($config as $source => $destination) { if (!is_string($source)) { - throw new \Exception('Invalid source attribute name: ' . var_export($source, true)); + throw new Exception('Invalid source attribute name: ' . var_export($source, true)); } if (!is_string($destination) && !is_array($destination)) { - throw new \Exception('Invalid destination attribute name: ' . var_export($destination, true)); + throw new Exception('Invalid destination attribute name: ' . var_export($destination, true)); } $this->map[$source] = $destination; diff --git a/modules/core/lib/Auth/Process/AttributeLimit.php b/modules/core/lib/Auth/Process/AttributeLimit.php index f5f1f4698b4fc8900fd7189e44c9fc18b64b9864..e61301cd88074a3e434be2c8685aa5f9689ee3b1 100644 --- a/modules/core/lib/Auth/Process/AttributeLimit.php +++ b/modules/core/lib/Auth/Process/AttributeLimit.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * A filter for limiting which attributes are passed on. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class AttributeLimit extends \SimpleSAML\Auth\ProcessingFilter +class AttributeLimit extends Auth\ProcessingFilter { /** * List of attributes which this filter will allow through. diff --git a/modules/core/lib/Auth/Process/AttributeMap.php b/modules/core/lib/Auth/Process/AttributeMap.php index 5a79368b94ed03c9d46b08f2641b33790ec2ec48..8fcecb20d42e033a6890ca042bc76ee70d41a8b3 100644 --- a/modules/core/lib/Auth/Process/AttributeMap.php +++ b/modules/core/lib/Auth/Process/AttributeMap.php @@ -4,9 +4,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Module; -use Webmozart\Assert\Assert; /** * Attribute filter for renaming attributes. @@ -14,7 +16,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter +class AttributeMap extends Auth\ProcessingFilter { /** * Associative array with the mappings of attribute names. @@ -55,11 +57,11 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter } if (!is_string($origName)) { - throw new \Exception('Invalid attribute name: ' . var_export($origName, true)); + throw new Exception('Invalid attribute name: ' . var_export($origName, true)); } if (!is_string($newName) && !is_array($newName)) { - throw new \Exception('Invalid attribute name: ' . var_export($newName, true)); + throw new Exception('Invalid attribute name: ' . var_export($newName, true)); } $this->map[$origName] = $newName; @@ -89,7 +91,7 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter if (count($m) === 2) { // we are asked for a file in a module if (!Module::isModuleEnabled($m[0])) { - throw new \Exception("Module '$m[0]' is not enabled."); + throw new Exception("Module '$m[0]' is not enabled."); } $filePath = Module::getModuleDir($m[0]) . '/attributemap/' . $m[1] . '.php'; } else { @@ -98,14 +100,14 @@ class AttributeMap extends \SimpleSAML\Auth\ProcessingFilter } if (!file_exists($filePath)) { - throw new \Exception('Could not find attribute map file: ' . $filePath); + throw new Exception('Could not find attribute map file: ' . $filePath); } /** @psalm-var mixed|null $attributemap */ $attributemap = null; include($filePath); if (!is_array($attributemap)) { - throw new \Exception('Attribute map file "' . $filePath . '" didn\'t define an attribute map.'); + throw new Exception('Attribute map file "' . $filePath . '" didn\'t define an attribute map.'); } if ($this->duplicate) { diff --git a/modules/core/lib/Auth/Process/AttributeValueMap.php b/modules/core/lib/Auth/Process/AttributeValueMap.php index 890cb0208fa07cf00247540b01b8c634d299deef..183b48546569900bc53647aabf76d512ef5e517e 100644 --- a/modules/core/lib/Auth/Process/AttributeValueMap.php +++ b/modules/core/lib/Auth/Process/AttributeValueMap.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Filter to create target attribute based on value(s) in source attribute @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @author Martin van Es, m7 * @package SimpleSAMLphp */ -class AttributeValueMap extends \SimpleSAML\Auth\ProcessingFilter +class AttributeValueMap extends Auth\ProcessingFilter { /** * The name of the attribute we should assign values to (ie: the target attribute). diff --git a/modules/core/lib/Auth/Process/Cardinality.php b/modules/core/lib/Auth/Process/Cardinality.php index 47a4308a937ac9208cd8e383b695ed2fa73a89a1..9e3bb200c824f9fe6f2f30fae992a783fae60e2b 100644 --- a/modules/core/lib/Auth/Process/Cardinality.php +++ b/modules/core/lib/Auth/Process/Cardinality.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Filter to ensure correct cardinality of attributes @@ -17,7 +17,7 @@ use Webmozart\Assert\Assert; * @author Guy Halse, http://orcid.org/0000-0002-9388-8592 * @package SimpleSAMLphp */ -class Cardinality extends \SimpleSAML\Auth\ProcessingFilter +class Cardinality extends Auth\ProcessingFilter { /** @var array Associative array with the mappings of attribute names. */ private $cardinality = []; diff --git a/modules/core/lib/Auth/Process/CardinalitySingle.php b/modules/core/lib/Auth/Process/CardinalitySingle.php index bcdec278033a0fe34029914ec6fb648bcafc3192..23ddc4e540412cf0d90afa96310bb4b091f6132e 100644 --- a/modules/core/lib/Auth/Process/CardinalitySingle.php +++ b/modules/core/lib/Auth/Process/CardinalitySingle.php @@ -4,11 +4,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Filter to ensure correct cardinality of single-valued attributes @@ -19,7 +19,7 @@ use Webmozart\Assert\Assert; * @author Guy Halse, http://orcid.org/0000-0002-9388-8592 * @package SimpleSAMLphp */ -class CardinalitySingle extends \SimpleSAML\Auth\ProcessingFilter +class CardinalitySingle extends Auth\ProcessingFilter { /** @var array Attributes that should be single-valued or we generate an error */ private $singleValued = []; diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php index 764538336e4a5d3e12cf87c7f29256ffd05dfb8d..f3e9f710f11d274b21cb8eeaaf358426f96918a6 100644 --- a/modules/core/lib/Auth/Process/ExtendIdPSession.php +++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php @@ -4,15 +4,16 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Session; use SimpleSAML\SessionHandler; -use Webmozart\Assert\Assert; /** * Extend IdP session and cookies. */ -class ExtendIdPSession extends \SimpleSAML\Auth\ProcessingFilter +class ExtendIdPSession extends Auth\ProcessingFilter { /** * @param array &$state diff --git a/modules/core/lib/Auth/Process/GenerateGroups.php b/modules/core/lib/Auth/Process/GenerateGroups.php index fe0cd5f3c3ac64573b099b38cf40fac23c77deb3..d5bb34529299ab4957c5e87ac6ca7c7227cf0dd6 100644 --- a/modules/core/lib/Auth/Process/GenerateGroups.php +++ b/modules/core/lib/Auth/Process/GenerateGroups.php @@ -4,8 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Filter to generate a groups attribute based on many of the attributes of the user. @@ -13,7 +15,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter +class GenerateGroups extends Auth\ProcessingFilter { /** * The attributes we should generate groups from. @@ -43,7 +45,7 @@ class GenerateGroups extends \SimpleSAML\Auth\ProcessingFilter // Validate configuration foreach ($config as $attributeName) { if (!is_string($attributeName)) { - throw new \Exception('Invalid attribute name for core:GenerateGroups filter: ' . + throw new Exception('Invalid attribute name for core:GenerateGroups filter: ' . var_export($attributeName, true)); } } diff --git a/modules/core/lib/Auth/Process/LanguageAdaptor.php b/modules/core/lib/Auth/Process/LanguageAdaptor.php index c1cefff0cccbb4906bd03da5229b001bb2f3c7a5..3c1be618ba16ebc3d1dd9979ad02156d1745dec3 100644 --- a/modules/core/lib/Auth/Process/LanguageAdaptor.php +++ b/modules/core/lib/Auth/Process/LanguageAdaptor.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Locale\Language; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Filter to set and get language settings from attributes. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @author Andreas Ã…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ -class LanguageAdaptor extends \SimpleSAML\Auth\ProcessingFilter +class LanguageAdaptor extends Auth\ProcessingFilter { /** @var string */ private $langattr = 'preferredLanguage'; diff --git a/modules/core/lib/Auth/Process/PHP.php b/modules/core/lib/Auth/Process/PHP.php index 541992d0911b4c4a20c2ade50594e91dfd6a2141..ad3454fbd4b66116a8815c4e4705f80717458890 100644 --- a/modules/core/lib/Auth/Process/PHP.php +++ b/modules/core/lib/Auth/Process/PHP.php @@ -4,8 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Attribute filter for running arbitrary PHP code. @@ -13,7 +14,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class PHP extends \SimpleSAML\Auth\ProcessingFilter +class PHP extends Auth\ProcessingFilter { /** * The PHP code that should be run. @@ -38,7 +39,7 @@ class PHP extends \SimpleSAML\Auth\ProcessingFilter if (!isset($config['code'])) { throw new Error\Exception("core:PHP: missing mandatory configuration option 'code'."); } - $this->code = (string) $config['code']; + $this->code = strval($config['code']); } diff --git a/modules/core/lib/Auth/Process/ScopeAttribute.php b/modules/core/lib/Auth/Process/ScopeAttribute.php index 8c13339b02c74dc2c5fe7aeff961ea5bdfef0ed9..4c60aa0c8573832698fa2a703fb6e4d2257bccef 100644 --- a/modules/core/lib/Auth/Process/ScopeAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeAttribute.php @@ -4,8 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Configuration; -use Webmozart\Assert\Assert; /** * Add a scoped variant of an attribute. @@ -13,7 +14,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class ScopeAttribute extends \SimpleSAML\Auth\ProcessingFilter +class ScopeAttribute extends Auth\ProcessingFilter { /** * The attribute we extract the scope from. diff --git a/modules/core/lib/Auth/Process/ScopeFromAttribute.php b/modules/core/lib/Auth/Process/ScopeFromAttribute.php index eec2cf68b388c5e068b059f8d863835bb9247f54..7ed93ae7415e5b96964b515c7fbf17a1cb714ee1 100644 --- a/modules/core/lib/Auth/Process/ScopeFromAttribute.php +++ b/modules/core/lib/Auth/Process/ScopeFromAttribute.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Retrieve a scope from a source attribute and add it as a virtual target @@ -24,7 +25,7 @@ use Webmozart\Assert\Assert; * to add a virtual 'scope' attribute from the eduPersonPrincipalName * attribute. */ -class ScopeFromAttribute extends \SimpleSAML\Auth\ProcessingFilter +class ScopeFromAttribute extends Auth\ProcessingFilter { /** * The attribute where the scope is taken from diff --git a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php index 66fedc7617d08d8e6b7ea665d5c5f5bc743937f0..8b2774b009e0ecf56f7ec6534d554883e120de6a 100644 --- a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php +++ b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php @@ -4,8 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Log a line in the STAT log with one attribute. @@ -13,7 +15,7 @@ use Webmozart\Assert\Assert; * @author Andreas Ã…kre Solberg, UNINETT AS. * @package SimpleSAMLphp */ -class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter +class StatisticsWithAttribute extends Auth\ProcessingFilter { /** * The attribute to log @@ -45,14 +47,14 @@ class StatisticsWithAttribute extends \SimpleSAML\Auth\ProcessingFilter if (array_key_exists('attributename', $config)) { $this->attribute = $config['attributename']; if (!is_string($this->attribute)) { - throw new \Exception('Invalid attribute name given to core:StatisticsWithAttribute filter.'); + throw new Exception('Invalid attribute name given to core:StatisticsWithAttribute filter.'); } } if (array_key_exists('type', $config)) { $this->typeTag = $config['type']; if (!is_string($this->typeTag)) { - throw new \Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.'); + throw new Exception('Invalid typeTag given to core:StatisticsWithAttribute filter.'); } } diff --git a/modules/core/lib/Auth/Process/TargetedID.php b/modules/core/lib/Auth/Process/TargetedID.php index 5ed6278398c7a8516964389ffb524113fac7008b..6aff8258d5fb17fa0bcaeeb333d4fea9ddb00f32 100644 --- a/modules/core/lib/Auth/Process/TargetedID.php +++ b/modules/core/lib/Auth/Process/TargetedID.php @@ -4,10 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use Exception; use SAML2\Constants; use SAML2\XML\saml\NameID; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Filter to generate the eduPersonTargetedID attribute. @@ -37,7 +39,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class TargetedID extends \SimpleSAML\Auth\ProcessingFilter +class TargetedID extends Auth\ProcessingFilter { /** * The attribute we should generate the targeted id from, or NULL if we should use the @@ -68,14 +70,14 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter if (array_key_exists('attributename', $config)) { $this->attribute = $config['attributename']; if (!is_string($this->attribute)) { - throw new \Exception('Invalid attribute name given to core:TargetedID filter.'); + throw new Exception('Invalid attribute name given to core:TargetedID filter.'); } } if (array_key_exists('nameId', $config)) { $this->generateNameId = $config['nameId']; if (!is_bool($this->generateNameId)) { - throw new \Exception('Invalid value of \'nameId\'-option to core:TargetedID filter.'); + throw new Exception('Invalid value of \'nameId\'-option to core:TargetedID filter.'); } } } @@ -93,7 +95,7 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter if ($this->attribute === null) { if (!array_key_exists('UserID', $state)) { - throw new \Exception('core:TargetedID: Missing UserID for this user. Please' . + throw new Exception('core:TargetedID: Missing UserID for this user. Please' . ' check the \'userid.attribute\' option in the metadata against the' . ' attributes provided by the authentication source.'); } @@ -101,7 +103,7 @@ class TargetedID extends \SimpleSAML\Auth\ProcessingFilter $userID = $state['UserID']; } else { if (!array_key_exists($this->attribute, $state['Attributes'])) { - throw new \Exception('core:TargetedID: Missing attribute \'' . $this->attribute . + throw new Exception('core:TargetedID: Missing attribute \'' . $this->attribute . '\', which is needed to generate the targeted ID.'); } diff --git a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php index 2ce421d3cf59de276d9a51ff9cf18f584bd740e2..ef47239e91f037e529e99ad6bbfca92b4c7b3d8a 100644 --- a/modules/core/lib/Auth/Process/WarnShortSSOInterval.php +++ b/modules/core/lib/Auth/Process/WarnShortSSOInterval.php @@ -4,18 +4,18 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Give a warning to the user if we receive multiple requests in a short time. * * @package SimpleSAMLphp */ -class WarnShortSSOInterval extends \SimpleSAML\Auth\ProcessingFilter +class WarnShortSSOInterval extends Auth\ProcessingFilter { /** * Process a authentication response. diff --git a/modules/core/lib/Auth/Source/AdminPassword.php b/modules/core/lib/Auth/Source/AdminPassword.php index 9433372556bf500d2aa7d8ae27f0b63724612ef5..82ee499abb98e56e4a568a34ca49c483bfafa9a4 100644 --- a/modules/core/lib/Auth/Source/AdminPassword.php +++ b/modules/core/lib/Auth/Source/AdminPassword.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth\Source; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; -use Webmozart\Assert\Assert; +use SimpleSAML\Module\core\Auth\UserPassBase; /** * Authentication source which verifies the password against @@ -15,7 +16,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class AdminPassword extends \SimpleSAML\Module\core\Auth\UserPassBase +class AdminPassword extends UserPassBase { /** * Constructor for this authentication source. diff --git a/modules/core/lib/Auth/UserPassBase.php b/modules/core/lib/Auth/UserPassBase.php index ccba12bcd822188a0da445a75468588b1d968c3b..c81c172e9015d925f8f263546512d246b006f319 100644 --- a/modules/core/lib/Auth/UserPassBase.php +++ b/modules/core/lib/Auth/UserPassBase.php @@ -5,13 +5,13 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils\HTTP; -use Webmozart\Assert\Assert; /** * Helper class for username/password authentication. @@ -22,7 +22,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -abstract class UserPassBase extends \SimpleSAML\Auth\Source +abstract class UserPassBase extends Auth\Source { /** * The string used to identify our states. diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php index 3ef8bbc2351f241536d75465208de47360ab4a57..a1186cae70721f41706aaad890295dc09f418778 100644 --- a/modules/core/lib/Auth/UserPassOrgBase.php +++ b/modules/core/lib/Auth/UserPassOrgBase.php @@ -4,12 +4,12 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Auth; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Helper class for username/password/organization authentication. @@ -22,7 +22,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source +abstract class UserPassOrgBase extends Auth\Source { /** * The string used to identify our states. diff --git a/modules/core/lib/Controller/Login.php b/modules/core/lib/Controller/Login.php index e555b1c6619971be5677ef8e36e19a3c5f9cd66f..de75c470284e713171e0084b10efb7ef59226af9 100644 --- a/modules/core/lib/Controller/Login.php +++ b/modules/core/lib/Controller/Login.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Controller; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Auth\AuthenticationFactory; use SimpleSAML\Configuration; @@ -16,7 +17,6 @@ use SimpleSAML\XHTML\Template; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Webmozart\Assert\Assert; /** * Controller class for the core module. diff --git a/modules/core/lib/Controller/Redirection.php b/modules/core/lib/Controller/Redirection.php index aa35589c83ba4b4ab30010646a6481f571f47ae5..373f77bff681b4bd23059069424222a3df806539 100644 --- a/modules/core/lib/Controller/Redirection.php +++ b/modules/core/lib/Controller/Redirection.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Controller; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; @@ -14,7 +15,6 @@ use SimpleSAML\Utils; use SimpleSAML\XHTML\Template; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Webmozart\Assert\Assert; /** * Controller class for the core module. diff --git a/modules/core/lib/Stats/Output/File.php b/modules/core/lib/Stats/Output/File.php index df83076923caba53db330feb33e9bc3ff5f5acf8..90fde84378cc265c2481d5c17a5deab0985d9943 100644 --- a/modules/core/lib/Stats/Output/File.php +++ b/modules/core/lib/Stats/Output/File.php @@ -4,9 +4,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\core\Stats\Output; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Statistics logger that writes to a set of log files diff --git a/modules/core/www/postredirect.php b/modules/core/www/postredirect.php index 07bac08e8fe030280f630c9d2e13424fd40eea00..4fecbd9f220798dfb078ba5538c706a01a43e3e8 100644 --- a/modules/core/www/postredirect.php +++ b/modules/core/www/postredirect.php @@ -6,27 +6,33 @@ * @package SimpleSAMLphp */ -use Webmozart\Assert\Assert; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Configuration; +use SimpleSAML\Error; +use SimpleSAML\Session; +use SimpleSAML\Utils; +use SimpleSAML\XHTML\Template; if (array_key_exists('RedirId', $_REQUEST)) { $postId = $_REQUEST['RedirId']; - $session = \SimpleSAML\Session::getSessionFromRequest(); + $session = Session::getSessionFromRequest(); } elseif (array_key_exists('RedirInfo', $_REQUEST)) { $encData = base64_decode($_REQUEST['RedirInfo']); if (empty($encData)) { - throw new \SimpleSAML\Error\BadRequest('Invalid RedirInfo data.'); + throw new Error\BadRequest('Invalid RedirInfo data.'); } - list($sessionId, $postId) = explode(':', \SimpleSAML\Utils\Crypto::aesDecrypt($encData)); + list($sessionId, $postId) = explode(':', Utils\Crypto::aesDecrypt($encData)); if (empty($sessionId) || empty($postId)) { - throw new \SimpleSAML\Error\BadRequest('Invalid session info data.'); + throw new Error\BadRequest('Invalid session info data.'); } - $session = \SimpleSAML\Session::getSession($sessionId); + $session = Session::getSession($sessionId); } else { - throw new \SimpleSAML\Error\BadRequest('Missing redirection info parameter.'); + throw new Error\BadRequest('Missing redirection info parameter.'); } if ($session === null) { @@ -46,12 +52,12 @@ Assert::isArray($postData); Assert::keyExists($postData, 'url'); Assert::keyExists($postData, 'post'); -if (!\SimpleSAML\Utils\HTTP::isValidURL($postData['url'])) { - throw new \SimpleSAML\Error\Exception('Invalid destination URL.'); +if (!Utils\HTTP::isValidURL($postData['url'])) { + throw new Error\Exception('Invalid destination URL.'); } -$config = \SimpleSAML\Configuration::getInstance(); -$template = new \SimpleSAML\XHTML\Template($config, 'post.php'); +$config = Configuration::getInstance(); +$template = new Template($config, 'post.php'); $template->data['destination'] = $postData['url']; $template->data['post'] = $postData['post']; $template->send(); diff --git a/modules/cron/hooks/hook_configpage.php b/modules/cron/hooks/hook_configpage.php index cb43582994a0e41e690f878e95684711370fb8d6..05301a912c4897d616b9571c70c0b6e586d69788 100644 --- a/modules/cron/hooks/hook_configpage.php +++ b/modules/cron/hooks/hook_configpage.php @@ -1,16 +1,20 @@ <?php +use SimpleSAML\Locale\Translate; +use SimpleSAML\Module; +use SimpleSAML\XHTML\Template; + /** * Hook to add the cron module to the config page. * * @param \SimpleSAML\XHTML\Template &$template The template that we should alter in this hook. * @return void */ -function cron_hook_configpage(\SimpleSAML\XHTML\Template &$template): void +function cron_hook_configpage(Template &$template): void { $template->data['links']['cron'] = [ - 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), - 'text' => \SimpleSAML\Locale\Translate::noop('Cron module information page'), + 'href' => Module::getModuleURL('cron/croninfo.php'), + 'text' => Translate::noop('Cron module information page'), ]; $template->getLocalization()->addModuleDomain('cron'); } diff --git a/modules/cron/hooks/hook_cron.php b/modules/cron/hooks/hook_cron.php index 2211d7a40260ae56e97d7c58c4028a15eef31d7f..f411fb7ca24087029252d546b2b4021b206b109b 100644 --- a/modules/cron/hooks/hook_cron.php +++ b/modules/cron/hooks/hook_cron.php @@ -1,6 +1,7 @@ <?php -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Configuration; /** * Hook to run a cron job. @@ -13,7 +14,7 @@ function cron_hook_cron(array &$croninfo): void Assert::keyExists($croninfo, 'summary'); Assert::keyExists($croninfo, 'tag'); - $cronconfig = \SimpleSAML\Configuration::getConfig('module_cron.php'); + $cronconfig = Configuration::getConfig('module_cron.php'); if ($cronconfig->getValue('debug_message', true)) { $croninfo['summary'][] = 'Cron did run tag [' . $croninfo['tag'] . '] at ' . date(DATE_RFC822); diff --git a/modules/cron/hooks/hook_frontpage.php b/modules/cron/hooks/hook_frontpage.php index 4e34f505d0c0a97307bf97d7d9b2b5e8414de439..9282b4a18051c9c91f16086b1c0f34992a2731c3 100644 --- a/modules/cron/hooks/hook_frontpage.php +++ b/modules/cron/hooks/hook_frontpage.php @@ -1,6 +1,7 @@ <?php -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Module; /** * Hook to add the modinfo module to the frontpage. @@ -13,7 +14,7 @@ function cron_hook_frontpage(array &$links): void Assert::keyExists($links, 'links'); $links['config'][] = [ - 'href' => SimpleSAML\Module::getModuleURL('cron/croninfo.php'), + 'href' => Module::getModuleURL('cron/croninfo.php'), 'text' => '{cron:cron:link_cron}', ]; } diff --git a/modules/cron/lib/Cron.php b/modules/cron/lib/Cron.php index c75bc80c26d5e5132e9367f61ae8d039be6fbf0a..0966b8773fa876e43384b26860b5c497fc0e3ec5 100644 --- a/modules/cron/lib/Cron.php +++ b/modules/cron/lib/Cron.php @@ -4,10 +4,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\cron; +use Exception; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Logger; use SimpleSAML\Module; -use Webmozart\Assert\Assert; /** * Handles interactions with SSP's cron system/hooks. @@ -42,7 +43,7 @@ class Cron public function runTag(string $tag): array { if (!$this->isValidTag($tag)) { - throw new \Exception("Invalid cron tag '$tag''"); + throw new Exception("Invalid cron tag '$tag''"); } $summary = []; diff --git a/modules/exampleauth/lib/Auth/Process/RedirectTest.php b/modules/exampleauth/lib/Auth/Process/RedirectTest.php index 27b575f0f9ae89cc6ad3fff92f79cc4949bf4493..6f9214d91d89779746b732bb76ec7bf6f9f91fdc 100644 --- a/modules/exampleauth/lib/Auth/Process/RedirectTest.php +++ b/modules/exampleauth/lib/Auth/Process/RedirectTest.php @@ -4,10 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\exampleauth\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * A simple processing filter for testing that redirection works as it should. diff --git a/modules/exampleauth/lib/Auth/Source/External.php b/modules/exampleauth/lib/Auth/Source/External.php index 235c159adb0771ef7ec730dbc82951ead7f748ed..7d59c63da32e7c609cc19aef6701d0eed6446106 100644 --- a/modules/exampleauth/lib/Auth/Source/External.php +++ b/modules/exampleauth/lib/Auth/Source/External.php @@ -4,11 +4,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\exampleauth\Auth\Source; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Error; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Example external authentication source. @@ -30,7 +30,7 @@ use Webmozart\Assert\Assert; * * @package SimpleSAMLphp */ -class External extends \SimpleSAML\Auth\Source +class External extends Auth\Source { /** * The key of the AuthId field in the state. diff --git a/modules/exampleauth/lib/Auth/Source/StaticSource.php b/modules/exampleauth/lib/Auth/Source/StaticSource.php index 75e6a57da5c2604be0b4081e9b8f8b03c2124393..ead4484ba216bfc3b394fa8fe5d788631ceaa786 100644 --- a/modules/exampleauth/lib/Auth/Source/StaticSource.php +++ b/modules/exampleauth/lib/Auth/Source/StaticSource.php @@ -4,8 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\exampleauth\Auth\Source; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Example authentication source. @@ -16,7 +18,7 @@ use Webmozart\Assert\Assert; * @author Olav Morken, UNINETT AS. * @package SimpleSAMLphp */ -class StaticSource extends \SimpleSAML\Auth\Source +class StaticSource extends Auth\Source { /** * The attributes we return. @@ -39,8 +41,8 @@ class StaticSource extends \SimpleSAML\Auth\Source // Parse attributes try { $this->attributes = Utils\Attributes::normalizeAttributesArray($config); - } catch (\Exception $e) { - throw new \Exception('Invalid attributes for authentication source ' . + } catch (Exception $e) { + throw new Exception('Invalid attributes for authentication source ' . $this->authId . ': ' . $e->getMessage()); } } diff --git a/modules/exampleauth/lib/Auth/Source/UserPass.php b/modules/exampleauth/lib/Auth/Source/UserPass.php index e4e6b21883a755574ea39a6763284615a27a6f22..62fa2ee098283efc2329b65b85bfdc8cf12cc08b 100644 --- a/modules/exampleauth/lib/Auth/Source/UserPass.php +++ b/modules/exampleauth/lib/Auth/Source/UserPass.php @@ -4,9 +4,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\exampleauth\Auth\Source; +use Exception; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; +use SimpleSAML\Module\core\Auth\UserPassBase; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Example authentication source - username & password. @@ -18,7 +20,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class UserPass extends \SimpleSAML\Module\core\Auth\UserPassBase +class UserPass extends UserPassBase { /** * Our users, stored in an associative array. The key of the array is "<username>:<password>", @@ -45,14 +47,14 @@ 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( + throw new Exception( 'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass ); } $userpass = explode(':', $userpass, 2); if (count($userpass) !== 2) { - throw new \Exception( + throw new Exception( 'Invalid <username>:<password> for authentication source ' . $this->authId . ': ' . $userpass[0] ); } @@ -61,8 +63,8 @@ class UserPass extends \SimpleSAML\Module\core\Auth\UserPassBase try { $attributes = Utils\Attributes::normalizeAttributesArray($attributes); - } catch (\Exception $e) { - throw new \Exception('Invalid attributes for user ' . $username . + } catch (Exception $e) { + throw new Exception('Invalid attributes for user ' . $username . ' in authentication source ' . $this->authId . ': ' . $e->getMessage()); } $this->users[$username . ':' . $password] = $attributes; diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index b4e00ad4895bce69f89e6141bbc3e5cc87767507..7e6cb6fb28bbf8695b86a781a36bf2fbbb181643 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -4,13 +4,14 @@ declare(strict_types=1); namespace SimpleSAML\Module\multiauth\Auth\Source; +use Exception; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Module; use SimpleSAML\Session; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Authentication source which let the user chooses among a list of @@ -19,7 +20,7 @@ use Webmozart\Assert\Assert; * @author Lorenzo Gil, Yaco Sistemas S.L. * @package SimpleSAMLphp */ -class MultiAuth extends \SimpleSAML\Auth\Source +class MultiAuth extends Auth\Source { /** * The key of the AuthId field in the state. @@ -65,12 +66,12 @@ class MultiAuth extends \SimpleSAML\Auth\Source parent::__construct($info, $config); if (!array_key_exists('sources', $config)) { - throw new \Exception('The required "sources" config option was not found'); + throw new Exception('The required "sources" config option was not found'); } if (array_key_exists('preselect', $config) && is_string($config['preselect'])) { if (!array_key_exists($config['preselect'], $config['sources'])) { - throw new \Exception('The optional "preselect" config option must be present in "sources"'); + throw new Exception('The optional "preselect" config option must be present in "sources"'); } $this->preselect = $config['preselect']; @@ -193,7 +194,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $state[self::SOURCESID] ); if ($as === null || !in_array($authId, $valid_sources, true)) { - throw new \Exception('Invalid authentication source: ' . $authId); + throw new Exception('Invalid authentication source: ' . $authId); } // Save the selected authentication source for the logout process. @@ -209,7 +210,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $as->authenticate($state); } catch (Error\Exception $e) { Auth\State::throwException($state, $e); - } catch (\Exception $e) { + } catch (Exception $e) { $e = new Error\UnserializableException($e); Auth\State::throwException($state, $e); } @@ -234,7 +235,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source $source = Auth\Source::getById($authId); if ($source === null) { - throw new \Exception('Invalid authentication source during logout: ' . $authId); + throw new Exception('Invalid authentication source during logout: ' . $authId); } // Then, do the logout on it $source->logout($state); diff --git a/modules/saml/hooks/hook_metadata_hosted.php b/modules/saml/hooks/hook_metadata_hosted.php index 38f35ccfe2234b3ea5d9f42fb2ec7aa534ca2c57..d91d8062df3c5487c34f836d463a0ac6c27f0184 100644 --- a/modules/saml/hooks/hook_metadata_hosted.php +++ b/modules/saml/hooks/hook_metadata_hosted.php @@ -1,6 +1,7 @@ <?php -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; /** * Hook to add the metadata for hosted entities to the frontpage. @@ -10,7 +11,7 @@ use Webmozart\Assert\Assert; */ function saml_hook_metadata_hosted(array &$metadataHosted) { - $sources = \SimpleSAML\Auth\Source::getSourcesOfType('saml:SP'); + $sources = Auth\Source::getSourcesOfType('saml:SP'); foreach ($sources as $source) { /** @var \SimpleSAML\Module\saml\Auth\Source\SP $source */ diff --git a/modules/saml/lib/Auth/Process/AttributeNameID.php b/modules/saml/lib/Auth/Process/AttributeNameID.php index 6c5db9bff29f6cadd31321f3241b904959c108c8..e840f2b6c21b0e4890646b6ace5710d229dc0392 100644 --- a/modules/saml/lib/Auth/Process/AttributeNameID.php +++ b/modules/saml/lib/Auth/Process/AttributeNameID.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; +use SimpleSAML\Module\saml\BaseNameIDGenerator; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Authentication processing filter to create a NameID from an attribute. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class AttributeNameID extends \SimpleSAML\Module\saml\BaseNameIDGenerator +class AttributeNameID extends BaseNameIDGenerator { /** * The attribute we should use as the NameID. diff --git a/modules/saml/lib/Auth/Process/AuthnContextClassRef.php b/modules/saml/lib/Auth/Process/AuthnContextClassRef.php index e1cb26b6619488b4c21b82b1fc383801c29668ba..1c98f44aec66382a108162da72c6d39cbfbd85bd 100644 --- a/modules/saml/lib/Auth/Process/AuthnContextClassRef.php +++ b/modules/saml/lib/Auth/Process/AuthnContextClassRef.php @@ -4,15 +4,16 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth\ProcessingFilter; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Filter for setting the AuthnContextClassRef in the response. * * @package SimpleSAMLphp */ -class AuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter +class AuthnContextClassRef extends ProcessingFilter { /** * The URI we should set as the AuthnContextClassRef in the login response. @@ -38,7 +39,7 @@ class AuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter throw new Error\Exception('Missing AuthnContextClassRef option in processing filter.'); } - $this->authnContextClassRef = (string) $config['AuthnContextClassRef']; + $this->authnContextClassRef = strval($config['AuthnContextClassRef']); } diff --git a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php index d33f6bad767675ac2f2eb1aacd0d9e58cbc32a42..2ba768e3ed93a8e97fab336d2a707ea7801b407d 100644 --- a/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php +++ b/modules/saml/lib/Auth/Process/ExpectedAuthnContextClassRef.php @@ -4,12 +4,13 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; +use SimpleSAML\Auth\ProcessingFilter; use SimpleSAML\Error; use SimpleSAML\Logger; use SimpleSAML\Module; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Attribute filter to validate AuthnContextClassRef values. @@ -27,7 +28,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class ExpectedAuthnContextClassRef extends \SimpleSAML\Auth\ProcessingFilter +class ExpectedAuthnContextClassRef extends ProcessingFilter { /** * Array of accepted AuthnContextClassRef diff --git a/modules/saml/lib/Auth/Process/FilterScopes.php b/modules/saml/lib/Auth/Process/FilterScopes.php index 39b35206989a4e996e5aa7b5d158f2519164678b..0e374d07a0768810bebb3003a06ac89c9c20ea4c 100644 --- a/modules/saml/lib/Auth/Process/FilterScopes.php +++ b/modules/saml/lib/Auth/Process/FilterScopes.php @@ -4,9 +4,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth\ProcessingFilter; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Filter to remove attribute values which are not properly scoped. @@ -16,7 +17,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class FilterScopes extends \SimpleSAML\Auth\ProcessingFilter +class FilterScopes extends ProcessingFilter { /** * @var array Stores any pre-configured scoped attributes which come from the filter configuration. diff --git a/modules/saml/lib/Auth/Process/NameIDAttribute.php b/modules/saml/lib/Auth/Process/NameIDAttribute.php index e33265b567e0a2690e44f536eb6ae01c896ee265..7ec8a1caeab4b48a6bf4d405f309a06ba0706027 100644 --- a/modules/saml/lib/Auth/Process/NameIDAttribute.php +++ b/modules/saml/lib/Auth/Process/NameIDAttribute.php @@ -5,8 +5,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; use SAML2\Constants; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth\ProcessingFilter; use SimpleSAML\Error; -use Webmozart\Assert\Assert; /** * Authentication processing filter to create an attribute from a NameID. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class NameIDAttribute extends \SimpleSAML\Auth\ProcessingFilter +class NameIDAttribute extends ProcessingFilter { /** * The attribute we should save the NameID in. diff --git a/modules/saml/lib/Auth/Process/PersistentNameID.php b/modules/saml/lib/Auth/Process/PersistentNameID.php index c36eaf62e88b831affa2c4ab61846771d67bb10b..f54b2153216d3e7ddc4c845838280ac2d3f5405e 100644 --- a/modules/saml/lib/Auth/Process/PersistentNameID.php +++ b/modules/saml/lib/Auth/Process/PersistentNameID.php @@ -5,10 +5,11 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Logger; +use SimpleSAML\Module\saml\BaseNameIDGenerator; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Authentication processing filter to generate a persistent NameID. @@ -16,7 +17,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class PersistentNameID extends \SimpleSAML\Module\saml\BaseNameIDGenerator +class PersistentNameID extends BaseNameIDGenerator { /** * Which attribute contains the unique identifier of the user. diff --git a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php index f9bfd25ba4ff4f49d8b2f19b4f9eee95ef8e15ac..3f889124f75c531f71d3749f2ca6ae4ef407d2d2 100644 --- a/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php +++ b/modules/saml/lib/Auth/Process/PersistentNameID2TargetedID.php @@ -5,8 +5,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; use SAML2\Constants; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth\ProcessingFilter; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Authentication processing filter to create the eduPersonTargetedID attribute from the persistent NameID. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class PersistentNameID2TargetedID extends \SimpleSAML\Auth\ProcessingFilter +class PersistentNameID2TargetedID extends ProcessingFilter { /** * The attribute we should save the NameID in. @@ -43,7 +44,7 @@ class PersistentNameID2TargetedID extends \SimpleSAML\Auth\ProcessingFilter parent::__construct($config, $reserved); if (isset($config['attribute'])) { - $this->attribute = (string) $config['attribute']; + $this->attribute = strval($config['attribute']); } else { $this->attribute = 'eduPersonTargetedID'; } diff --git a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php index abf6d580976d3bca4b776391ebb8a58a220088b8..2e2bd639dd23aab72764eee0ed8760a6de00d48d 100644 --- a/modules/saml/lib/Auth/Process/SQLPersistentNameID.php +++ b/modules/saml/lib/Auth/Process/SQLPersistentNameID.php @@ -5,9 +5,10 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; +use SimpleSAML\Module\saml\BaseNameIDGenerator; /** * Authentication processing filter to generate a persistent NameID. @@ -15,7 +16,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class SQLPersistentNameID extends \SimpleSAML\Module\saml\BaseNameIDGenerator +class SQLPersistentNameID extends BaseNameIDGenerator { /** * Which attribute contains the unique identifier of the user. diff --git a/modules/saml/lib/Auth/Process/TransientNameID.php b/modules/saml/lib/Auth/Process/TransientNameID.php index 932ef696ac8dba65482435a598c2e43dc912cce8..7e3266117c6e58a42dfd044b9f6f3b72ea1a1767 100644 --- a/modules/saml/lib/Auth/Process/TransientNameID.php +++ b/modules/saml/lib/Auth/Process/TransientNameID.php @@ -5,8 +5,9 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml\Auth\Process; use SAML2\Constants; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Module\saml\BaseNameIDGenerator; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Authentication processing filter to generate a transient NameID. @@ -14,7 +15,7 @@ use Webmozart\Assert\Assert; * @package SimpleSAMLphp */ -class TransientNameID extends \SimpleSAML\Module\saml\BaseNameIDGenerator +class TransientNameID extends BaseNameIDGenerator { /** * Initialize this filter, parse configuration diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 7664481f5c3470b53484b9848f6b7366fc3e7b23..98ef637fd2f7ed319523adff6dd3de8f9411d55a 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -8,6 +8,7 @@ use SAML2\AuthnRequest; use SAML2\Binding; use SAML2\Constants; use SAML2\XML\saml\NameID; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; @@ -18,7 +19,6 @@ use SimpleSAML\Module; use SimpleSAML\Session; use SimpleSAML\Store; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; class SP extends \SimpleSAML\Auth\Source { diff --git a/modules/saml/lib/BaseNameIDGenerator.php b/modules/saml/lib/BaseNameIDGenerator.php index 15bb39770fd1b55287e795a8cefd5ae7a9d9c2d2..a6deb6010cc3ef24df62ed35b6046d9cc420e16c 100644 --- a/modules/saml/lib/BaseNameIDGenerator.php +++ b/modules/saml/lib/BaseNameIDGenerator.php @@ -5,8 +5,8 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml; use SAML2\XML\saml\NameID; +use SimpleSAML\Assert\Assert; use SimpleSAML\Logger; -use Webmozart\Assert\Assert; /** * Base filter for generating NameID values. diff --git a/modules/saml/lib/Error.php b/modules/saml/lib/Error.php index f8e7311b1f89224740e24e5b76ef4a52c77077cd..64a3835a7c8ce6e8ed5bf81221fe4eae50b8531f 100644 --- a/modules/saml/lib/Error.php +++ b/modules/saml/lib/Error.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace SimpleSAML\Module\saml; use SAML2\Constants; -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; /** * Class for representing a SAML 2 error. diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php index 613c9e707d56f59edc5efd49a99814bdfb1ec35e..4e8aaed3170bac3531205567cf0e26151daac1f4 100644 --- a/modules/saml/lib/IdP/SAML2.php +++ b/modules/saml/lib/IdP/SAML2.php @@ -25,6 +25,7 @@ use SAML2\XML\saml\Issuer; use SAML2\XML\saml\NameID; use SAML2\XML\saml\SubjectConfirmation; use SAML2\XML\saml\SubjectConfirmationData; +use SimpleSAML\Assert\Assert; use SimpleSAML\Auth; use SimpleSAML\Configuration; use SimpleSAML\Error; @@ -34,7 +35,6 @@ use SimpleSAML\Metadata\MetaDataStorageHandler; use SimpleSAML\Module; use SimpleSAML\Stats; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * IdP implementation for SAML 2.0 protocol. diff --git a/modules/saml/lib/IdP/SQLNameID.php b/modules/saml/lib/IdP/SQLNameID.php index 6a2e6d31f278c0f8bc82b856d0c0b3250e6eb339..d83ca638473019038446094108af75cbbe0dca37 100644 --- a/modules/saml/lib/IdP/SQLNameID.php +++ b/modules/saml/lib/IdP/SQLNameID.php @@ -6,11 +6,11 @@ namespace SimpleSAML\Module\saml\IdP; use PDO; use PDOStatement; +use SimpleSAML\Assert\Assert; use SimpleSAML\Error; use SimpleSAML\Store; use SimpleSAML\Database; use SimpleSAML\Configuration; -use Webmozart\Assert\Assert; /** * Helper class for working with persistent NameIDs stored in SQL datastore. diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index c5194aeca622586e2f602ae393cd74e0f332ccf7..875f211bb585314ec4fbd3945367006ed495f83e 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -18,11 +18,11 @@ use SAML2\XML\ds\KeyInfo; use SAML2\XML\ds\X509Certificate; use SAML2\XML\ds\X509Data; use SAML2\XML\saml\Issuer; +use SimpleSAML\Assert\Assert; use SimpleSAML\Configuration; use SimpleSAML\Error as SSP_Error; use SimpleSAML\Logger; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * Common code for building SAML 2 messages based on the available metadata. diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php index a955516dd16ae22d814fcbb820eecb755a8ea35a..47af236b7a6526b478275e98bd8c66d9ce853d90 100644 --- a/modules/saml/lib/SP/LogoutStore.php +++ b/modules/saml/lib/SP/LogoutStore.php @@ -6,11 +6,11 @@ namespace SimpleSAML\Module\saml\SP; use PDO; use SAML2\XML\saml\NameID; +use SimpleSAML\Assert\Assert; use SimpleSAML\Logger; use SimpleSAML\Session; use SimpleSAML\Store; use SimpleSAML\Utils; -use Webmozart\Assert\Assert; /** * A directory over logout information. diff --git a/modules/saml/www/sp/discoresp.php b/modules/saml/www/sp/discoresp.php index 8ee798645fc591a1f35fba38175eac2a92cdd322..28d855a7c04c114ff10375f481e3d083d3c0d838 100644 --- a/modules/saml/www/sp/discoresp.php +++ b/modules/saml/www/sp/discoresp.php @@ -4,29 +4,31 @@ * Handler for response from IdP discovery service. */ -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; +use SimpleSAML\Error; if (!array_key_exists('AuthID', $_REQUEST)) { - throw new \SimpleSAML\Error\BadRequest('Missing AuthID to discovery service response handler'); + throw new Error\BadRequest('Missing AuthID to discovery service response handler'); } if (!array_key_exists('idpentityid', $_REQUEST)) { - throw new \SimpleSAML\Error\BadRequest('Missing idpentityid to discovery service response handler'); + throw new Error\BadRequest('Missing idpentityid to discovery service response handler'); } /** @var array $state */ -$state = \SimpleSAML\Auth\State::loadState($_REQUEST['AuthID'], 'saml:sp:sso'); +$state = Auth\State::loadState($_REQUEST['AuthID'], 'saml:sp:sso'); // Find authentication source Assert::keyExists($state, 'saml:sp:AuthId'); $sourceId = $state['saml:sp:AuthId']; -$source = \SimpleSAML\Auth\Source::getById($sourceId); +$source = Auth\Source::getById($sourceId); if ($source === null) { throw new Exception('Could not find authentication source with id ' . $sourceId); } if (!($source instanceof \SimpleSAML\Module\saml\Auth\Source\SP)) { - throw new \SimpleSAML\Error\Exception('Source type changed?'); + throw new Error\Exception('Source type changed?'); } $source->startSSO($_REQUEST['idpentityid'], $state); diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php index c5727f0a943f169e401bf7a322882f665deb7ea3..d54431233014bcf455d6f704dab250c3931062cf 100644 --- a/modules/saml/www/sp/metadata.php +++ b/modules/saml/www/sp/metadata.php @@ -1,23 +1,33 @@ <?php +use SAML2\Constants; +use SimpleSAML\Auth; +use SimpleSAML\Configuration; +use SimpleSAML\Error; +use SimpleSAML\Locale\Translate; +use SimpleSAML\Metadata; +use SimpleSAML\Module; +use SimpleSAML\Store; +use SimpleSAML\Utils; +use SimpleSAML\XHTML\Template; use Symfony\Component\VarExporter\VarExporter; if (!array_key_exists('PATH_INFO', $_SERVER)) { - throw new \SimpleSAML\Error\BadRequest('Missing authentication source id in metadata URL'); + throw new Error\BadRequest('Missing authentication source id in metadata URL'); } -$config = \SimpleSAML\Configuration::getInstance(); +$config = Configuration::getInstance(); if ($config->getBoolean('admin.protectmetadata', false)) { - \SimpleSAML\Utils\Auth::requireAdmin(); + Utils\Auth::requireAdmin(); } $sourceId = substr($_SERVER['PATH_INFO'], 1); -$source = \SimpleSAML\Auth\Source::getById($sourceId); +$source = Auth\Source::getById($sourceId); if ($source === null) { - throw new \SimpleSAML\Error\AuthSource($sourceId, 'Could not find authentication source.'); + throw new Error\AuthSource($sourceId, 'Could not find authentication source.'); } -if (!($source instanceof \SimpleSAML\Module\saml\Auth\Source\SP)) { - throw new \SimpleSAML\Error\AuthSource( +if (!($source instanceof Module\saml\Auth\Source\SP)) { + throw new Error\AuthSource( $sourceId, 'The authentication source is not a SAML Service Provider.' ); @@ -25,20 +35,20 @@ if (!($source instanceof \SimpleSAML\Module\saml\Auth\Source\SP)) { $entityId = $source->getEntityId(); $spconfig = $source->getMetadata(); -$store = \SimpleSAML\Store::getInstance(); +$store = Store::getInstance(); $metaArray20 = []; $slosvcdefault = [ - \SAML2\Constants::BINDING_HTTP_REDIRECT, - \SAML2\Constants::BINDING_SOAP, + Constants::BINDING_HTTP_REDIRECT, + Constants::BINDING_SOAP, ]; $slob = $spconfig->getArray('SingleLogoutServiceBinding', $slosvcdefault); -$slol = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-logout.php/' . $sourceId); +$slol = Module::getModuleURL('saml/sp/saml2-logout.php/' . $sourceId); foreach ($slob as $binding) { - if ($binding == \SAML2\Constants::BINDING_SOAP && !($store instanceof \SimpleSAML\Store\SQL)) { + if ($binding == Constants::BINDING_SOAP && !($store instanceof Store\SQL)) { // we cannot properly support SOAP logout continue; } @@ -68,29 +78,29 @@ foreach ($assertionsconsumerservices as $services) { $acsArray = ['index' => $index]; switch ($services) { case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST': - $acsArray['Binding'] = \SAML2\Constants::BINDING_HTTP_POST; - $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); - if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) { - $supported_protocols[] = \SAML2\Constants::NS_SAMLP; + $acsArray['Binding'] = Constants::BINDING_HTTP_POST; + $acsArray['Location'] = Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); + if (!in_array(Constants::NS_SAMLP, $supported_protocols, true)) { + $supported_protocols[] = Constants::NS_SAMLP; } break; case 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post': $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:1.0:profiles:browser-post'; - $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml1-acs.php/' . $sourceId); + $acsArray['Location'] = Module::getModuleURL('saml/sp/saml1-acs.php/' . $sourceId); if (!in_array('urn:oasis:names:tc:SAML:1.1:protocol', $supported_protocols, true)) { $supported_protocols[] = 'urn:oasis:names:tc:SAML:1.1:protocol'; } break; case 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact': $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact'; - $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); - if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) { - $supported_protocols[] = \SAML2\Constants::NS_SAMLP; + $acsArray['Location'] = Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); + if (!in_array(Constants::NS_SAMLP, $supported_protocols, true)) { + $supported_protocols[] = Constants::NS_SAMLP; } break; case 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01': $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01'; - $acsArray['Location'] = \SimpleSAML\Module::getModuleURL( + $acsArray['Location'] = Module::getModuleURL( 'saml/sp/saml1-acs.php/' . $sourceId . '/artifact' ); if (!in_array('urn:oasis:names:tc:SAML:1.1:protocol', $supported_protocols, true)) { @@ -99,10 +109,10 @@ foreach ($assertionsconsumerservices as $services) { break; case 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser': $acsArray['Binding'] = 'urn:oasis:names:tc:SAML:2.0:profiles:holder-of-key:SSO:browser'; - $acsArray['Location'] = \SimpleSAML\Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); - $acsArray['hoksso:ProtocolBinding'] = \SAML2\Constants::BINDING_HTTP_REDIRECT; - if (!in_array(\SAML2\Constants::NS_SAMLP, $supported_protocols, true)) { - $supported_protocols[] = \SAML2\Constants::NS_SAMLP; + $acsArray['Location'] = Module::getModuleURL('saml/sp/saml2-acs.php/' . $sourceId); + $acsArray['hoksso:ProtocolBinding'] = Constants::BINDING_HTTP_REDIRECT; + if (!in_array(Constants::NS_SAMLP, $supported_protocols, true)) { + $supported_protocols[] = Constants::NS_SAMLP; } break; } @@ -113,7 +123,7 @@ foreach ($assertionsconsumerservices as $services) { $metaArray20['AssertionConsumerService'] = $spconfig->getArray('AssertionConsumerService', $eps); $keys = []; -$certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig, false, 'new_'); +$certInfo = Utils\Crypto::loadPublicKey($spconfig, false, 'new_'); if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $hasNewCert = true; @@ -129,7 +139,7 @@ if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $hasNewCert = false; } -$certInfo = \SimpleSAML\Utils\Crypto::loadPublicKey($spconfig); +$certInfo = Utils\Crypto::loadPublicKey($spconfig); if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $certData = $certInfo['certData']; @@ -146,9 +156,9 @@ if ($certInfo !== null && array_key_exists('certData', $certInfo)) { $format = $spconfig->getValue('NameIDPolicy', null); if ($format !== null) { if (is_array($format)) { - $metaArray20['NameIDFormat'] = \SimpleSAML\Configuration::loadFromArray($format)->getString( + $metaArray20['NameIDFormat'] = Configuration::loadFromArray($format)->getString( 'Format', - \SAML2\Constants::NAMEID_TRANSIENT + Constants::NAMEID_TRANSIENT ); } elseif (is_string($format)) { $metaArray20['NameIDFormat'] = $format; @@ -198,14 +208,14 @@ if ($orgName !== null) { $metaArray20['OrganizationURL'] = $spconfig->getLocalizedString('OrganizationURL', null); if ($metaArray20['OrganizationURL'] === null) { - throw new \SimpleSAML\Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); + throw new Error\Exception('If OrganizationName is set, OrganizationURL must also be set.'); } } if ($spconfig->hasValue('contacts')) { $contacts = $spconfig->getArray('contacts'); foreach ($contacts as $contact) { - $metaArray20['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($contact); + $metaArray20['contacts'][] = Utils\Config\Metadata::getContact($contact); } } @@ -217,7 +227,7 @@ if ($email && $email !== 'na@example.org') { 'name' => $config->getString('technicalcontact_name', null), 'contactType' => 'technical' ]; - $metaArray20['contacts'][] = \SimpleSAML\Utils\Config\Metadata::getContact($techcontact); + $metaArray20['contacts'][] = Utils\Config\Metadata::getContact($techcontact); } // add certificate @@ -255,7 +265,7 @@ if ($spconfig->hasValue('redirect.sign')) { $metaArray20['metadata-set'] = 'saml20-sp-remote'; $metaArray20['entityid'] = $entityId; -$metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($entityId); +$metaBuilder = new Metadata\SAMLBuilder($entityId); $metaBuilder->addMetadataSP20($metaArray20, $supported_protocols); $metaBuilder->addOrganizationInfo($metaArray20); @@ -271,14 +281,14 @@ if (isset($metaArray20['attributes']) && is_array($metaArray20['attributes'])) { } // sign the metadata if enabled -$xml = \SimpleSAML\Metadata\Signer::sign($xml, $spconfig->toArray(), 'SAML 2 SP'); +$xml = 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.twig', 'admin'); + $t = new Template($config, 'metadata.twig', 'admin'); $t->data['clipboard.js'] = true; $t->data['header'] = 'saml20-sp'; // TODO: Replace with headerString in 2.0 - $t->data['headerString'] = \SimpleSAML\Locale\Translate::noop('metadata_saml20-sp'); + $t->data['headerString'] = Translate::noop('metadata_saml20-sp'); $t->data['metadata'] = htmlspecialchars($xml); $t->data['metadataflat'] = '$metadata[' . var_export($entityId, true) . '] = ' . VarExporter::export($metaArray20) . ';'; diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php index 1ca32b5c3dbbf9a5ccf35d4d4995a3a336628807..b287ef5b4e0fb71cde9c69d30637fcfd47bb2b8d 100644 --- a/modules/saml/www/sp/saml2-acs.php +++ b/modules/saml/www/sp/saml2-acs.php @@ -4,46 +4,57 @@ * Assertion consumer service handler for SAML 2.0 SP authentication client. */ -use Webmozart\Assert\Assert; +use SAML2\Binding; +use SAML2\Assertion; +use SAML2\HTTPArtifact; +use SAML2\Response; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Auth; +use SimpleSAML\Error; +use SimpleSAML\Module; +use SimpleSAML\Logger; +use SimpleSAML\Session; +use SimpleSAML\Store; +use SimpleSAML\Utils; if (!array_key_exists('PATH_INFO', $_SERVER)) { - throw new \SimpleSAML\Error\BadRequest('Missing authentication source ID in assertion consumer service URL'); + throw new Error\BadRequest('Missing authentication source ID in assertion consumer service URL'); } $sourceId = substr($_SERVER['PATH_INFO'], 1); /** @var \SimpleSAML\Module\saml\Auth\Source\SP $source */ -$source = \SimpleSAML\Auth\Source::getById($sourceId, '\SimpleSAML\Module\saml\Auth\Source\SP'); +$source = Auth\Source::getById($sourceId, '\SimpleSAML\Module\saml\Auth\Source\SP'); $spMetadata = $source->getMetadata(); try { - $b = \SAML2\Binding::getCurrentBinding(); + $b = Binding::getCurrentBinding(); } catch (Exception $e) { // TODO: look for a specific exception // This is dirty. Instead of checking the message of the exception, \SAML2\Binding::getCurrentBinding() should throw // a specific exception when the binding is unknown, and we should capture that here if ($e->getMessage() === 'Unable to find the current binding.') { - throw new \SimpleSAML\Error\Error('ACSPARAMS', $e, 400); + throw new Error\Error('ACSPARAMS', $e, 400); } else { // do not ignore other exceptions! throw $e; } } -if ($b instanceof \SAML2\HTTPArtifact) { +if ($b instanceof HTTPArtifact) { $b->setSPMetadata($spMetadata); } $response = $b->receive(); -if (!($response instanceof \SAML2\Response)) { - throw new \SimpleSAML\Error\BadRequest('Invalid message received to AssertionConsumerService endpoint.'); +if (!($response instanceof Response)) { + throw new Error\BadRequest('Invalid message received to AssertionConsumerService endpoint.'); } $issuer = $response->getIssuer(); if ($issuer === null) { // no Issuer in the response. Look for an unencrypted assertion with an issuer foreach ($response->getAssertions() as $a) { - if ($a instanceof \SAML2\Assertion) { + if ($a instanceof Assertion) { // we found an unencrypted assertion, there should be an issuer here $issuer = $a->getIssuer(); break; @@ -56,7 +67,7 @@ if ($issuer === null) { } $issuer = $issuer->getValue(); -$session = \SimpleSAML\Session::getSessionFromRequest(); +$session = Session::getSessionFromRequest(); $prevAuth = $session->getAuthData($sourceId, 'saml:sp:prevAuth'); /** @psalm-var string $issuer */ if ($prevAuth !== null && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $issuer) { @@ -67,15 +78,15 @@ if ($prevAuth !== null && $prevAuth['id'] === $response->getId() && $prevAuth['i * In that case we may as well just redo the previous redirect * instead of displaying a confusing error message. */ - SimpleSAML\Logger::info( + Logger::info( 'Duplicate SAML 2 response detected - ignoring the response and redirecting the user to the correct page.' ); if (isset($prevAuth['redirect'])) { - \SimpleSAML\Utils\HTTP::redirectTrustedURL($prevAuth['redirect']); + Utils\HTTP::redirectTrustedURL($prevAuth['redirect']); } - SimpleSAML\Logger::info('No RelayState or ReturnURL available, cannot redirect.'); - throw new \SimpleSAML\Error\Exception('Duplicate assertion received.'); + Logger::info('No RelayState or ReturnURL available, cannot redirect.'); + throw new Error\Exception('Duplicate assertion received.'); } $idpMetadata = null; @@ -85,10 +96,10 @@ $stateId = $response->getInResponseTo(); if (!empty($stateId)) { // this should be a response to a request we sent earlier try { - $state = \SimpleSAML\Auth\State::loadState($stateId, 'saml:sp:sso'); + $state = Auth\State::loadState($stateId, 'saml:sp:sso'); } catch (Exception $e) { // something went wrong, - SimpleSAML\Logger::warning('Could not load state specified by InResponseTo: ' . $e->getMessage() . + Logger::warning('Could not load state specified by InResponseTo: ' . $e->getMessage() . ' Processing response as unsolicited.'); } } @@ -97,7 +108,7 @@ if ($state) { // check that the authentication source is correct Assert::keyExists($state, 'saml:sp:AuthId'); if ($state['saml:sp:AuthId'] !== $sourceId) { - throw new \SimpleSAML\Error\Exception( + throw new Error\Exception( 'The authentication source id in the URL does not match the authentication source which sent the request.' ); } @@ -108,7 +119,7 @@ if ($state) { $idpMetadata = $source->getIdPMetadata($issuer); $idplist = $idpMetadata->getArrayize('IDPList', []); if (!in_array($state['ExpectedIssuer'], $idplist, true)) { - SimpleSAML\Logger::warning( + Logger::warning( 'The issuer of the response not match to the identity provider we sent the request to.' ); } @@ -118,7 +129,7 @@ if ($state) { $state = [ 'saml:sp:isUnsolicited' => true, 'saml:sp:AuthId' => $sourceId, - 'saml:sp:RelayState' => \SimpleSAML\Utils\HTTP::checkURLAllowed( + 'saml:sp:RelayState' => Utils\HTTP::checkURLAllowed( $spMetadata->getString( 'RelayState', $response->getRelayState() @@ -127,18 +138,18 @@ if ($state) { ]; } -SimpleSAML\Logger::debug('Received SAML2 Response from ' . var_export($issuer, true) . '.'); +Logger::debug('Received SAML2 Response from ' . var_export($issuer, true) . '.'); if (is_null($idpMetadata)) { $idpMetadata = $source->getIdPmetadata($issuer); } try { - $assertions = \SimpleSAML\Module\saml\Message::processResponse($spMetadata, $idpMetadata, $response); -} catch (\SimpleSAML\Module\saml\Error $e) { + $assertions = Module\saml\Message::processResponse($spMetadata, $idpMetadata, $response); +} catch (Module\saml\Error $e) { // the status of the response wasn't "success" $e = $e->toException(); - \SimpleSAML\Auth\State::throwException($state, $e); + Auth\State::throwException($state, $e); return; } @@ -151,12 +162,12 @@ $foundAuthnStatement = false; foreach ($assertions as $assertion) { // check for duplicate assertion (replay attack) - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); if ($store !== false) { $aID = $assertion->getId(); if ($store->get('saml.AssertionReceived', $aID) !== null) { - $e = new \SimpleSAML\Error\Exception('Received duplicate assertion.'); - \SimpleSAML\Auth\State::throwException($state, $e); + $e = new Error\Exception('Received duplicate assertion.'); + Auth\State::throwException($state, $e); } $notOnOrAfter = $assertion->getNotOnOrAfter(); @@ -192,8 +203,8 @@ foreach ($assertions as $assertion) { $assertion = end($assertions); if (!$foundAuthnStatement) { - $e = new \SimpleSAML\Error\Exception('No AuthnStatement found in assertion(s).'); - \SimpleSAML\Auth\State::throwException($state, $e); + $e = new Error\Exception('No AuthnStatement found in assertion(s).'); + Auth\State::throwException($state, $e); } if ($expire !== null) { @@ -205,7 +216,7 @@ if ($expire !== null) { if (!empty($nameId)) { // register this session in the logout store - \SimpleSAML\Module\saml\SP\LogoutStore::addSession($sourceId, $nameId, $sessionIndex, $logoutExpire); + Module\saml\SP\LogoutStore::addSession($sourceId, $nameId, $sessionIndex, $logoutExpire); // we need to save the NameID and SessionIndex for logout $logoutState = [ diff --git a/modules/saml/www/sp/saml2-logout.php b/modules/saml/www/sp/saml2-logout.php index aaf269e047e0b7546dbcdc9bdd30c394e40e5f9c..bc367c104afc467506fe797f3f11dee7e469e5a3 100644 --- a/modules/saml/www/sp/saml2-logout.php +++ b/modules/saml/www/sp/saml2-logout.php @@ -6,28 +6,41 @@ * This endpoint handles both logout requests and logout responses. */ +use Exception; +use SAML2\Binding; +use SAML2\Constants; +use SAML2\LogoutResponse; +use SAML2\LogoutRequest; +use SAML2\SOAP; +use SAML2\XML\saml\Issuer; +use SimpleSAML\Auth; +use SimpleSAML\Error; +use SimpleSAML\Logger; +use SimpleSAML\Metadata; +use SimpleSAML\Utils; + if (!array_key_exists('PATH_INFO', $_SERVER)) { - throw new \SimpleSAML\Error\BadRequest('Missing authentication source ID in logout URL'); + throw new Error\BadRequest('Missing authentication source ID in logout URL'); } $sourceId = substr($_SERVER['PATH_INFO'], 1); /** @var \SimpleSAML\Module\saml\Auth\Source\SP $source */ -$source = \SimpleSAML\Auth\Source::getById($sourceId); +$source = Auth\Source::getById($sourceId); if ($source === null) { - throw new \Exception('Could not find authentication source with id ' . $sourceId); + throw new Exception('Could not find authentication source with id ' . $sourceId); } elseif (!($source instanceof \SimpleSAML\Module\saml\Auth\Source\SP)) { - throw new \SimpleSAML\Error\Exception('Source type changed?'); + throw new Error\Exception('Source type changed?'); } try { - $binding = \SAML2\Binding::getCurrentBinding(); -} catch (\Exception $e) { + $binding = Binding::getCurrentBinding(); +} catch (Exception $e) { // TODO: look for a specific exception // This is dirty. Instead of checking the message of the exception, \SAML2\Binding::getCurrentBinding() should throw // an specific exception when the binding is unknown, and we should capture that here if ($e->getMessage() === 'Unable to find the current binding.') { - throw new \SimpleSAML\Error\Error('SLOSERVICEPARAMS', $e, 400); + throw new Error\Error('SLOSERVICEPARAMS', $e, 400); } else { throw $e; // do not ignore other exceptions! } @@ -35,7 +48,7 @@ try { $message = $binding->receive(); $issuer = $message->getIssuer(); -if ($issuer instanceof \SAML2\XML\saml\Issuer) { +if ($issuer instanceof Issuer) { $idpEntityId = $issuer->getValue(); } else { $idpEntityId = $issuer; @@ -43,60 +56,60 @@ if ($issuer instanceof \SAML2\XML\saml\Issuer) { if ($idpEntityId === null) { // Without an issuer we have no way to respond to the message. - throw new \SimpleSAML\Error\BadRequest('Received message on logout endpoint without issuer.'); + throw new Error\BadRequest('Received message on logout endpoint without issuer.'); } $spEntityId = $source->getEntityId(); -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); +$metadata = Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpMetadata = $source->getIdPMetadata($idpEntityId); $spMetadata = $source->getMetadata(); -\SimpleSAML\Module\saml\Message::validateMessage($idpMetadata, $spMetadata, $message); +Module\saml\Message::validateMessage($idpMetadata, $spMetadata, $message); $destination = $message->getDestination(); -if ($destination !== null && $destination !== \SimpleSAML\Utils\HTTP::getSelfURLNoQuery()) { - throw new \SimpleSAML\Error\Exception('Destination in logout message is wrong.'); +if ($destination !== null && $destination !== Utils\HTTP::getSelfURLNoQuery()) { + throw new Error\Exception('Destination in logout message is wrong.'); } -if ($message instanceof \SAML2\LogoutResponse) { +if ($message instanceof LogoutResponse) { $relayState = $message->getRelayState(); if ($relayState === null) { // Somehow, our RelayState has been lost. - throw new \SimpleSAML\Error\BadRequest('Missing RelayState in logout response.'); + throw new Error\BadRequest('Missing RelayState in logout response.'); } if (!$message->isSuccess()) { - \SimpleSAML\Logger::warning( - 'Unsuccessful logout. Status was: ' . \SimpleSAML\Module\saml\Message::getResponseError($message) + Logger::warning( + 'Unsuccessful logout. Status was: ' . Module\saml\Message::getResponseError($message) ); } - $state = \SimpleSAML\Auth\State::loadState($relayState, 'saml:slosent'); + $state = 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); +} elseif ($message instanceof LogoutRequest) { + Logger::debug('module/saml2/sp/logout: Request from ' . $idpEntityId); + Logger::stats('saml20-idp-SLO idpinit ' . $spEntityId . ' ' . $idpEntityId); if ($message->isNameIdEncrypted()) { try { - $keys = \SimpleSAML\Module\saml\Message::getDecryptionKeys($idpMetadata, $spMetadata); - } catch (\Exception $e) { - throw new \SimpleSAML\Error\Exception('Error decrypting NameID: ' . $e->getMessage()); + $keys = Module\saml\Message::getDecryptionKeys($idpMetadata, $spMetadata); + } catch (Exception $e) { + throw new Error\Exception('Error decrypting NameID: ' . $e->getMessage()); } - $blacklist = \SimpleSAML\Module\saml\Message::getBlacklistedAlgorithms($idpMetadata, $spMetadata); + $blacklist = Module\saml\Message::getBlacklistedAlgorithms($idpMetadata, $spMetadata); $lastException = null; foreach ($keys as $i => $key) { try { $message->decryptNameId($key, $blacklist); - \SimpleSAML\Logger::debug('Decryption with key #' . $i . ' succeeded.'); + Logger::debug('Decryption with key #' . $i . ' succeeded.'); $lastException = null; break; - } catch (\Exception $e) { - \SimpleSAML\Logger::debug('Decryption with key #' . $i . ' failed with exception: ' . $e->getMessage()); + } catch (Exception $e) { + Logger::debug('Decryption with key #' . $i . ' failed with exception: ' . $e->getMessage()); $lastException = $e; } } @@ -109,7 +122,7 @@ if ($message instanceof \SAML2\LogoutResponse) { $sessionIndexes = $message->getSessionIndexes(); /** @psalm-suppress PossiblyNullArgument This will be fixed in saml2 5.0 */ - $numLoggedOut = \SimpleSAML\Module\saml\SP\LogoutStore::logoutSessions($sourceId, $nameId, $sessionIndexes); + $numLoggedOut = Module\saml\SP\LogoutStore::logoutSessions($sourceId, $nameId, $sessionIndexes); if ($numLoggedOut === false) { // This type of logout was unsupported. Use the old method $source->handleLogout($idpEntityId); @@ -117,24 +130,24 @@ if ($message instanceof \SAML2\LogoutResponse) { } // Create and send response - $lr = \SimpleSAML\Module\saml\Message::buildLogoutResponse($spMetadata, $idpMetadata); + $lr = Module\saml\Message::buildLogoutResponse($spMetadata, $idpMetadata); $lr->setRelayState($message->getRelayState()); $lr->setInResponseTo($message->getId()); if ($numLoggedOut < count($sessionIndexes)) { - \SimpleSAML\Logger::warning('Logged out of ' . $numLoggedOut . ' of ' . count($sessionIndexes) . ' sessions.'); + Logger::warning('Logged out of ' . $numLoggedOut . ' of ' . count($sessionIndexes) . ' sessions.'); } $dst = $idpMetadata->getEndpointPrioritizedByBinding( 'SingleLogoutService', [ - \SAML2\Constants::BINDING_HTTP_REDIRECT, - \SAML2\Constants::BINDING_HTTP_POST + Constants::BINDING_HTTP_REDIRECT, + Constants::BINDING_HTTP_POST ] ); - if (!($binding instanceof \SAML2\SOAP)) { - $binding = \SAML2\Binding::getBinding($dst['Binding']); + if (!($binding instanceof SOAP)) { + $binding = Binding::getBinding($dst['Binding']); if (isset($dst['ResponseLocation'])) { $dst = $dst['ResponseLocation']; } else { @@ -147,5 +160,5 @@ if ($message instanceof \SAML2\LogoutResponse) { $binding->send($lr); } else { - throw new \SimpleSAML\Error\BadRequest('Unknown message received on logout endpoint: ' . get_class($message)); + throw new Error\BadRequest('Unknown message received on logout endpoint: ' . get_class($message)); } diff --git a/modules/saml/www/sp/wrong_authncontextclassref.php b/modules/saml/www/sp/wrong_authncontextclassref.php index 15c08cd9a4d96bbe681c33876bc2d99c7f209da2..da2ed84f90d6192537ad3a3373a911559a970ddc 100644 --- a/modules/saml/www/sp/wrong_authncontextclassref.php +++ b/modules/saml/www/sp/wrong_authncontextclassref.php @@ -1,5 +1,8 @@ <?php -$globalConfig = \SimpleSAML\Configuration::getInstance(); -$t = new \SimpleSAML\XHTML\Template($globalConfig, 'saml:sp/wrong_authncontextclassref.twig'); +use SimpleSAML\Configuration; +use SimpleSAML\XHTML\Template; + +$globalConfig = Configuration::getInstance(); +$t = new Template($globalConfig, 'saml:sp/wrong_authncontextclassref.twig'); $t->send(); diff --git a/tests/lib/SimpleSAML/Utils/HTTPTest.php b/tests/lib/SimpleSAML/Utils/HTTPTest.php index 09b9f699b58a7f039033adfb71169f24f67f842e..5ecbef2d2ae2fa22a3b83de015d3a3041d1aa4db 100644 --- a/tests/lib/SimpleSAML/Utils/HTTPTest.php +++ b/tests/lib/SimpleSAML/Utils/HTTPTest.php @@ -9,7 +9,6 @@ use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Test\Utils\ClearStateTestCase; use SimpleSAML\Utils\HTTP; -use Webmozart\Assert\Assert; class HTTPTest extends ClearStateTestCase { diff --git a/www/saml2/idp/ArtifactResolutionService.php b/www/saml2/idp/ArtifactResolutionService.php index 16a99dc62e1285bb179ff4d8cd46ba8c44c26410..c98fba2a8328c9e7aa3803d8176d070ab4f77679 100644 --- a/www/saml2/idp/ArtifactResolutionService.php +++ b/www/saml2/idp/ArtifactResolutionService.php @@ -10,25 +10,36 @@ require_once('../../_include.php'); -$config = \SimpleSAML\Configuration::getInstance(); +use Exception; +use SAML2\ArtifactResolve; +use SAML2\ArtifactResponse; +use SAML2\DOMDocumentFactory; +use SAML2\SOAP; +use SimpleSAML\Configuration; +use SimpleSAML\Error; +use SimpleSAML\Module; +use SimpleSAML\Metadata; +use SimpleSAML\Store; + +$config = Configuration::getInstance(); if (!$config->getBoolean('enable.saml20-idp', false)) { - throw new \SimpleSAML\Error\Error('NOACCESS'); + throw new Error\Error('NOACCESS'); } -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); +$metadata = Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); $idpMetadata = $metadata->getMetaDataConfig($idpEntityId, 'saml20-idp-hosted'); if (!$idpMetadata->getBoolean('saml20.sendartifact', false)) { - throw new \SimpleSAML\Error\Error('NOACCESS'); + throw new Error\Error('NOACCESS'); } -$store = \SimpleSAML\Store::getInstance(); +$store = Store::getInstance(); if ($store === false) { throw new Exception('Unable to send artifact without a datastore configured.'); } -$binding = new \SAML2\SOAP(); +$binding = new SOAP(); try { $request = $binding->receive(); } catch (Exception $e) { @@ -37,12 +48,12 @@ try { // an specific exception when the binding is unknown, and we should capture that here. Also note that the exception // message here is bogus! if ($e->getMessage() === 'Invalid message received to AssertionConsumerService endpoint.') { - throw new \SimpleSAML\Error\Error('ARSPARAMS', $e, 400); + throw new Error\Error('ARSPARAMS', $e, 400); } else { throw $e; // do not ignore other exceptions! } } -if (!($request instanceof \SAML2\ArtifactResolve)) { +if (!($request instanceof ArtifactResolve)) { throw new Exception('Message received on ArtifactResolutionService wasn\'t a ArtifactResolve request.'); } @@ -55,15 +66,15 @@ $responseData = $store->get('artifact', $artifact); $store->delete('artifact', $artifact); if ($responseData !== null) { - $document = \SAML2\DOMDocumentFactory::fromString($responseData); + $document = DOMDocumentFactory::fromString($responseData); $responseXML = $document->firstChild; } else { $responseXML = null; } -$artifactResponse = new \SAML2\ArtifactResponse(); +$artifactResponse = new ArtifactResponse(); $artifactResponse->setIssuer($idpEntityId); $artifactResponse->setInResponseTo($request->getId()); $artifactResponse->setAny($responseXML); -\SimpleSAML\Module\saml\Message::addSign($idpMetadata, $spMetadata, $artifactResponse); +Module\saml\Message::addSign($idpMetadata, $spMetadata, $artifactResponse); $binding->send($artifactResponse); diff --git a/www/saml2/idp/SSOService.php b/www/saml2/idp/SSOService.php index 61b472ece679d30b62af7dfd008ba67b756e7959..c0679790caeea6f83588d92e101b664b42e5bf5c 100644 --- a/www/saml2/idp/SSOService.php +++ b/www/saml2/idp/SSOService.php @@ -11,19 +11,25 @@ require_once('../../_include.php'); -use Webmozart\Assert\Assert; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Error; +use SimpleSAML\Idp; +use SimpleSAML\Logger; +use SimpleSAML\Metadata; +use SimpleSAML\Module; -\SimpleSAML\Logger::info('SAML2.0 - IdP.SSOService: Accessing SAML 2.0 IdP endpoint SSOService'); +Logger::info('SAML2.0 - IdP.SSOService: Accessing SAML 2.0 IdP endpoint SSOService'); -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); +$metadata = Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); -$idp = \SimpleSAML\IdP::getById('saml2:' . $idpEntityId); +$idp = IdP::getById('saml2:' . $idpEntityId); try { - \SimpleSAML\Module\saml\IdP\SAML2::receiveAuthnRequest($idp); -} catch (\Exception $e) { + Module\saml\IdP\SAML2::receiveAuthnRequest($idp); +} catch (Exception $e) { if ($e->getMessage() === "Unable to find the current binding.") { - throw new \SimpleSAML\Error\Error('SSOPARAMS', $e, 400); + throw new Error\Error('SSOPARAMS', $e, 400); } else { throw $e; // do not ignore other exceptions! } diff --git a/www/saml2/idp/SingleLogoutService.php b/www/saml2/idp/SingleLogoutService.php index ab4a49b0f1062346cf10f3b119d24511371238ed..8ff5872d1dd343598336cfa10eb30c2c51f7f811 100644 --- a/www/saml2/idp/SingleLogoutService.php +++ b/www/saml2/idp/SingleLogoutService.php @@ -10,27 +10,34 @@ require_once('../../_include.php'); -use Webmozart\Assert\Assert; +use Exception; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Error; +use SimpleSAML\Idp; +use SimpleSAML\Logger; +use SimpleSAML\Metadata; +use SimpleSAML\Module; +use SimpleSAML\Utils; -\SimpleSAML\Logger::info('SAML2.0 - IdP.SingleLogoutService: Accessing SAML 2.0 IdP endpoint SingleLogoutService'); +Logger::info('SAML2.0 - IdP.SingleLogoutService: Accessing SAML 2.0 IdP endpoint SingleLogoutService'); -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); +$metadata = Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); -$idp = \SimpleSAML\IdP::getById('saml2:' . $idpEntityId); +$idp = IdP::getById('saml2:' . $idpEntityId); if (isset($_REQUEST['ReturnTo'])) { - $idp->doLogoutRedirect(\SimpleSAML\Utils\HTTP::checkURLAllowed((string) $_REQUEST['ReturnTo'])); + $idp->doLogoutRedirect(Utils\HTTP::checkURLAllowed((string) $_REQUEST['ReturnTo'])); } else { try { - \SimpleSAML\Module\saml\IdP\SAML2::receiveLogoutMessage($idp); - } catch (\Exception $e) { + Module\saml\IdP\SAML2::receiveLogoutMessage($idp); + } catch (Exception $e) { // TODO: look for a specific exception /* * This is dirty. Instead of checking the message of the exception, \SAML2\Binding::getCurrentBinding() should * throw an specific exception when the binding is unknown, and we should capture that here */ if ($e->getMessage() === 'Unable to find the current binding.') { - throw new \SimpleSAML\Error\Error('SLOSERVICEPARAMS', $e, 400); + throw new Error\Error('SLOSERVICEPARAMS', $e, 400); } else { throw $e; // do not ignore other exceptions! } diff --git a/www/saml2/idp/initSLO.php b/www/saml2/idp/initSLO.php index 24e6748f870df7e971643feb540de754d3950cfe..24f27c470e221947dbb680770297c92cf5063f82 100644 --- a/www/saml2/idp/initSLO.php +++ b/www/saml2/idp/initSLO.php @@ -2,17 +2,22 @@ require_once('../../_include.php'); -use Webmozart\Assert\Assert; +use SimpleSAML\Assert\Assert; +use SimpleSAML\Error; +use SimpleSAML\Idp; +use SimpleSAML\Logger; +use SimpleSAML\Metadata; +use SimpleSAML\Utils; -$metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); +$metadata = Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpEntityId = $metadata->getMetaDataCurrentEntityID('saml20-idp-hosted'); -$idp = \SimpleSAML\IdP::getById('saml2:' . $idpEntityId); +$idp = IdP::getById('saml2:' . $idpEntityId); -\SimpleSAML\Logger::info('SAML2.0 - IdP.initSLO: Accessing SAML 2.0 IdP endpoint init Single Logout'); +Logger::info('SAML2.0 - IdP.initSLO: Accessing SAML 2.0 IdP endpoint init Single Logout'); if (!isset($_GET['RelayState'])) { - throw new \SimpleSAML\Error\Error('NORELAYSTATE'); + throw new Error\Error('NORELAYSTATE'); } -$idp->doLogoutRedirect(\SimpleSAML\Utils\HTTP::checkURLAllowed((string) $_GET['RelayState'])); +$idp->doLogoutRedirect(Utils\HTTP::checkURLAllowed((string) $_GET['RelayState'])); Assert::true(false); diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index cdfa430f17db1489e14c2fdcd8fd1604d815aac6..f8e49d8816b2aa0052c4e2d67e4853a4c568e483 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -5,12 +5,12 @@ require_once('../../_include.php'); use Symfony\Component\VarExporter\VarExporter; use SAML2\Constants; +use SimpleSAML\Assert\Assert; use SimpleSAML\Module; use SimpleSAML\Utils\Auth as Auth; use SimpleSAML\Utils\Crypto as Crypto; use SimpleSAML\Utils\HTTP as HTTP; use SimpleSAML\Utils\Config\Metadata as Metadata; -use Webmozart\Assert\Assert; // load SimpleSAMLphp configuration and metadata $config = \SimpleSAML\Configuration::getInstance();