From ca88182a71c23945dbbcdc264c7ee7975f456ea9 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Wed, 23 Sep 2020 15:49:25 +0200 Subject: [PATCH 1/2] Update lcobucci/clock requirement from ^1.3.0 to ^2.0.0 --- .gitignore | 2 + composer.json | 2 +- composer.lock | 37 +++++++++++-------- docs/configuration.md | 2 +- examples/index.php | 2 +- src/Storageless/Http/SessionMiddleware.php | 6 ++- .../Http/SessionMiddlewareTest.php | 12 +++--- 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 29024607..4b05e8e0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ vendor composer.phar clover.xml infectionlog.txt +.phpunit.result.cache +.phpcs-cache diff --git a/composer.json b/composer.json index 865e635d..c6054862 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "ext-json": "*", "dflydev/fig-cookies": "^2.0.1", "lcobucci/jwt": "^3.3.2", - "lcobucci/clock": "^1.3.0", + "lcobucci/clock": "^2.0.0", "psr/http-message": "^1.0.1", "psr/http-server-handler": "^1.0.1", "psr/http-server-middleware": "^1.0.1" diff --git a/composer.lock b/composer.lock index 5f4f83d9..5c09aaac 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": "8f868fea5f90509f38096e8decd028b4", + "content-hash": "5fc59e65300c52ad8c9e7cd6a6dca9b2", "packages": [ { "name": "dflydev/fig-cookies", @@ -62,37 +62,33 @@ }, { "name": "lcobucci/clock", - "version": "1.3.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/lcobucci/clock.git", - "reference": "70f25bddfb21a9cbf8d45cc53571de8ab45f5b69" + "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/lcobucci/clock/zipball/70f25bddfb21a9cbf8d45cc53571de8ab45f5b69", - "reference": "70f25bddfb21a9cbf8d45cc53571de8ab45f5b69", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/353d83fe2e6ae95745b16b3d911813df6a05bfb3", + "reference": "353d83fe2e6ae95745b16b3d911813df6a05bfb3", "shasum": "" }, "require": { - "php": "^7.4" + "php": "^7.4 || ^8.0" }, "require-dev": { - "infection/infection": "^0.15", - "lcobucci/coding-standard": "^4.0", + "infection/infection": "^0.17", + "lcobucci/coding-standard": "^6.0", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^0.12", "phpstan/phpstan-deprecation-rules": "^0.12", "phpstan/phpstan-phpunit": "^0.12", "phpstan/phpstan-strict-rules": "^0.12", - "phpunit/phpunit": "^9.0" + "phpunit/php-code-coverage": "9.1.4", + "phpunit/phpunit": "9.3.7" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, "autoload": { "psr-4": { "Lcobucci\\Clock\\": "src" @@ -109,7 +105,17 @@ } ], "description": "Yet another clock abstraction", - "time": "2020-02-26T20:20:12+00:00" + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2020-08-27T18:56:02+00:00" }, { "name": "lcobucci/jwt", @@ -2839,6 +2845,7 @@ "type": "github" } ], + "abandoned": true, "time": "2020-06-27T06:36:25+00:00" }, { diff --git a/docs/configuration.md b/docs/configuration.md index 08e06d1b..84a00b3d 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -80,7 +80,7 @@ $sessionMiddleware = new SessionMiddleware( $cookieBlueprint, new \Lcobucci\JWT\Parser(), 1200, // session lifetime, in seconds - new \Lcobucci\Clock\SystemClock(), + new \Lcobucci\Clock\SystemClock(new DateTimeZone(date_default_timezone_get()), 60 // session automatic refresh time, in seconds ); ``` diff --git a/examples/index.php b/examples/index.php index 24bebadd..37b2d6a0 100644 --- a/examples/index.php +++ b/examples/index.php @@ -50,7 +50,7 @@ ->withPath('/'), new Parser(), 1200, // 20 minutes - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); $myMiddleware = new class implements RequestHandlerInterface { diff --git a/src/Storageless/Http/SessionMiddleware.php b/src/Storageless/Http/SessionMiddleware.php index 01ef6282..09ffe0cd 100644 --- a/src/Storageless/Http/SessionMiddleware.php +++ b/src/Storageless/Http/SessionMiddleware.php @@ -21,6 +21,7 @@ namespace PSR7Sessions\Storageless\Http; use BadMethodCallException; +use DateTimeZone; use Dflydev\FigCookies\FigResponseCookies; use Dflydev\FigCookies\Modifier\SameSite; use Dflydev\FigCookies\SetCookie; @@ -43,6 +44,7 @@ use stdClass; use function assert; +use function date_default_timezone_get; use function is_numeric; final class SessionMiddleware implements MiddlewareInterface @@ -105,7 +107,7 @@ public static function fromSymmetricKeyDefaults(string $symmetricKey, int $expir ->withPath('/'), new Parser(), $expirationTime, - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); } @@ -129,7 +131,7 @@ public static function fromAsymmetricKeyDefaults( ->withPath('/'), new Parser(), $expirationTime, - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); } diff --git a/test/StoragelessTest/Http/SessionMiddlewareTest.php b/test/StoragelessTest/Http/SessionMiddlewareTest.php index 9a24ccae..01897af5 100644 --- a/test/StoragelessTest/Http/SessionMiddlewareTest.php +++ b/test/StoragelessTest/Http/SessionMiddlewareTest.php @@ -22,6 +22,7 @@ use DateTime; use DateTimeImmutable; +use DateTimeZone; use Dflydev\FigCookies\FigResponseCookies; use Dflydev\FigCookies\Modifier\SameSite; use Dflydev\FigCookies\SetCookie; @@ -45,6 +46,7 @@ use ReflectionProperty; use function assert; +use function date_default_timezone_get; use function file_get_contents; use function is_string; use function random_int; @@ -406,7 +408,7 @@ public function testRejectsTokensWithInvalidSignature(): void SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), new Parser(), 100, - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); $this->ensureSameResponse( @@ -461,7 +463,7 @@ public function testSessionTokenParsingIsDelayedWhenSessionIsNotBeingUsed(): voi $signer->expects(self::never())->method('verify'); $signer->method('getAlgorithmId')->willReturn('HS256'); - $currentTimeProvider = new SystemClock(); + $currentTimeProvider = new SystemClock(new DateTimeZone(date_default_timezone_get())); $setCookie = SetCookie::create(SessionMiddleware::DEFAULT_COOKIE); $middleware = new SessionMiddleware($signer, 'foo', 'foo', $setCookie, new Parser(), 100, $currentTimeProvider); $request = (new ServerRequest()) @@ -533,7 +535,7 @@ public function testShouldNotRegenerateTokenWhenRequestHasATokenThatIsFarFromExp SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), new Parser(), 1000, - new SystemClock(), + new SystemClock(new DateTimeZone(date_default_timezone_get())), 300 ); @@ -565,7 +567,7 @@ static function (): SessionMiddleware { SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), new Parser(), 100, - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); }, ], @@ -608,7 +610,7 @@ public function testMutableCookieWillNotBeUsed(): void $cookie, new Parser(), 1000, - new SystemClock() + new SystemClock(new DateTimeZone(date_default_timezone_get())) ); $cookie->mutated = true; From e7cd36a6b2af139984eceb8bd36d1bacc8dd1301 Mon Sep 17 00:00:00 2001 From: Filippo Tessarotto Date: Thu, 24 Sep 2020 07:43:32 +0200 Subject: [PATCH 2/2] Let's try Composer v1 --- .github/workflows/backwards-compatibility.yml | 2 +- .github/workflows/coding-standards.yml | 2 +- .github/workflows/mutation-tests.yml | 2 +- .github/workflows/phpunit.yml | 2 +- .github/workflows/psalm.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/backwards-compatibility.yml b/.github/workflows/backwards-compatibility.yml index bec07b46..101526c9 100644 --- a/.github/workflows/backwards-compatibility.yml +++ b/.github/workflows/backwards-compatibility.yml @@ -31,7 +31,7 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" ini-values: memory_limit=-1 - tools: composer:v2, cs2pr + tools: composer:v1, cs2pr - name: "Cache dependencies" uses: "actions/cache@v2" diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index 061f498f..5bf594fd 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -29,7 +29,7 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" ini-values: memory_limit=-1 - tools: composer:v2, cs2pr + tools: composer:v1, cs2pr - name: "Cache dependencies" uses: "actions/cache@v2" diff --git a/.github/workflows/mutation-tests.yml b/.github/workflows/mutation-tests.yml index 595345e3..5e307537 100644 --- a/.github/workflows/mutation-tests.yml +++ b/.github/workflows/mutation-tests.yml @@ -31,7 +31,7 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" ini-values: memory_limit=-1 - tools: composer:v2, cs2pr + tools: composer:v1, cs2pr - name: "Cache dependencies" uses: "actions/cache@v2" diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index df42e9c5..bf92dbf2 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -33,7 +33,7 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" ini-values: memory_limit=-1 - tools: composer:v2, cs2pr + tools: composer:v1, cs2pr - name: "Cache dependencies" uses: "actions/cache@v2" diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 8356e723..8390aa22 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -29,7 +29,7 @@ jobs: coverage: "pcov" php-version: "${{ matrix.php-version }}" ini-values: memory_limit=-1 - tools: composer:v2, cs2pr + tools: composer:v1, cs2pr - name: "Cache dependencies" uses: "actions/cache@v2"