Skip to content

Commit

Permalink
Merge pull request #138 from Slamdunk/lcobucci_clock_v2
Browse files Browse the repository at this point in the history
Update lcobucci/clock requirement from ^1.3.0 to ^2.0.0
  • Loading branch information
Ocramius authored Sep 29, 2020
2 parents 9ff0c88 + e7cd36a commit 0b6a5f5
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backwards-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ vendor
composer.phar
clover.xml
infectionlog.txt
.phpunit.result.cache
.phpcs-cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 22 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
```
Expand Down
2 changes: 1 addition & 1 deletion examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions src/Storageless/Http/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,6 +44,7 @@
use stdClass;

use function assert;
use function date_default_timezone_get;
use function is_numeric;

final class SessionMiddleware implements MiddlewareInterface
Expand Down Expand Up @@ -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()))
);
}

Expand All @@ -129,7 +131,7 @@ public static function fromAsymmetricKeyDefaults(
->withPath('/'),
new Parser(),
$expirationTime,
new SystemClock()
new SystemClock(new DateTimeZone(date_default_timezone_get()))
);
}

Expand Down
12 changes: 7 additions & 5 deletions test/StoragelessTest/Http/SessionMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Dflydev\FigCookies\FigResponseCookies;
use Dflydev\FigCookies\Modifier\SameSite;
use Dflydev\FigCookies\SetCookie;
Expand All @@ -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;
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
);

Expand Down Expand Up @@ -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()))
);
},
],
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0b6a5f5

Please sign in to comment.