Skip to content

Commit

Permalink
Merge pull request #554 from Slamdunk/naming_things
Browse files Browse the repository at this point in the history
Rename expirationTime/lifetime to what it really is: idle timeout
  • Loading branch information
Ocramius authored Dec 23, 2022
2 parents fb7ab95 + aeed749 commit e104492
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use PSR7Sessions\Storageless\Http\SessionMiddleware;

$sessionMiddleware = SessionMiddleware::fromSymmetricKeyDefaults(
InMemory::base64Encoded('OpcMuKmoxkhzW0Y1iESpjWwL/D3UBdDauJOe742BJ5Q='), // replace this with a key of your own (see below)
1200 // session lifetime, in seconds
1200 // session idle timeout, in seconds
);
```

Expand All @@ -35,7 +35,7 @@ use PSR7Sessions\Storageless\Http\SessionMiddleware;
$sessionMiddleware = SessionMiddleware::fromRsaAsymmetricKeyDefaults(
InMemory::file('/path/to/private_key.pem'),
InMemory::file('/path/to/public_key.pem'),
1200 // session lifetime, in seconds
1200 // session idle timeout, in seconds
);
```

Expand Down Expand Up @@ -83,7 +83,7 @@ $sessionMiddleware = new SessionMiddleware(
InMemory::base64Encoded('FW6ELbU3817sflp2XmnCQ3JJTIMihR1RctQu7VQ73Fg=')
),
SessionMiddleware::buildDefaultCookie(),
1200, // session lifetime, in seconds
1200, // session idle timeout, in seconds
SystemClock::fromSystemTimezone(),
60 // session automatic refresh time, in seconds
);
Expand Down Expand Up @@ -137,7 +137,7 @@ return new SessionMiddleware(
->withSecure(false)
->withHttpOnly(true)
->withPath('/'),
1200, // session lifetime, in seconds
1200, // session idle timeout, in seconds
SystemClock::fromUTC(),
);
```
12 changes: 6 additions & 6 deletions src/Storageless/Http/SessionMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ final class SessionMiddleware implements MiddlewareInterface
public function __construct(
Configuration $configuration,
SetCookie $defaultCookie,
private int $expirationTime,
private int $idleTimeout,
private Clock $clock,
private int $refreshTime = self::DEFAULT_REFRESH_TIME,
) {
Expand All @@ -72,15 +72,15 @@ public function __construct(
/**
* This constructor simplifies instantiation when using HTTPS (REQUIRED!) and symmetric key encryption
*/
public static function fromSymmetricKeyDefaults(Signer\Key $symmetricKey, int $expirationTime): self
public static function fromSymmetricKeyDefaults(Signer\Key $symmetricKey, int $idleTimeout): self
{
return new self(
Configuration::forSymmetricSigner(
new Signer\Hmac\Sha256(),
$symmetricKey,
),
self::buildDefaultCookie(),
$expirationTime,
$idleTimeout,
new SystemClock(new DateTimeZone(date_default_timezone_get())),
);
}
Expand All @@ -92,7 +92,7 @@ public static function fromSymmetricKeyDefaults(Signer\Key $symmetricKey, int $e
public static function fromRsaAsymmetricKeyDefaults(
Signer\Key $privateRsaKey,
Signer\Key $publicRsaKey,
int $expirationTime,
int $idleTimeout,
): self {
return new self(
Configuration::forAsymmetricSigner(
Expand All @@ -101,7 +101,7 @@ public static function fromRsaAsymmetricKeyDefaults(
$publicRsaKey,
),
self::buildDefaultCookie(),
$expirationTime,
$idleTimeout,
new SystemClock(new DateTimeZone(date_default_timezone_get())),
);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ private function shouldTokenBeRefreshed(Token|null $token): bool
private function getTokenCookie(SessionInterface $sessionContainer): SetCookie
{
$now = $this->clock->now();
$expiresAt = $now->add(new DateInterval(sprintf('PT%sS', $this->expirationTime)));
$expiresAt = $now->add(new DateInterval(sprintf('PT%sS', $this->idleTimeout)));

return $this
->defaultCookie
Expand Down

0 comments on commit e104492

Please sign in to comment.