Skip to content
docsv0.31.1

CsrfTokenLifetimeInterface

A {@see CsrfGuardInterface} that can say how long a token has left — what {@see \Milpa\Live\Http\LiveEndpoint} needs to refresh a token before it expires under a long-lived page (greenhouse decisions/0211: the CSRF token is renewed when it has a tenth of its life left). A sibling interface rather than two more methods on the guard contract, so every existing guard stays valid; a guard that does not implement it is simply never refreshed.

CsrfTokenLifetimeInterface::remaining()

abstract public function remaining(string $token): int

Seconds until `$token` expires — `0` for an expired or malformed token. Reads the token's own expiry; it does NOT verify the signature, so call {@see CsrfGuardInterface::verifyToken()} first.

Parameters

Parameters of remaining()
NameTypeDescription
$tokenstring

CsrfTokenLifetimeInterface::ttl()

abstract public function ttl(): int

The lifetime, in seconds, every token this guard issues starts with.