AccountDeletionTicket
in package
Short-lived proof that the visitor has just signed in (password or OAuth) to an account whose deletion is pending. It lets the "account awaiting deletion" page cancel the deletion without a session (the sign-in itself is refused while the deletion is pending).
The ticket is stateless, not the e-mailed cancel token: a stored hash would be replaced and
the link in the mailbox would stop working. It is an HMAC (shared app secret %jwt.secret%,
same as EditorAutosaveScope) over the user id, the request time, the random version of
the request (deletion_nonce) and the ticket expiry. Cancelling, a new request, the claim of
the anonymization and the anonymization itself replace or clear the nonce, so every older
ticket stops matching.
IMPORTANT: the request time alone is not a version. deletion_requested_at has second
precision, so a cancel and a new request within the same second would yield the same value
and the old ticket would cancel the new request. The nonce binds the ticket to one request.
Format: <userId>.<expiresTs>.<hmac>.
Table of Contents
Constants
- TTL_SECONDS : int = 1800
- The visitor has 30 minutes to click "Cancel the deletion" after signing in.
Properties
- $secret : string
Methods
- __construct() : mixed
- issue() : string
- `$requestNonce` is the `deletion_nonce` of the request ('' for a request made before the nonce existed).
- matches() : bool
- Returns whether the ticket belongs to the current deletion request (time and nonce) of the account.
- parseUserId() : int|null
- Returns the user id the ticket was issued for, or null for a malformed or expired ticket.
- sign() : string
Constants
TTL_SECONDS
The visitor has 30 minutes to click "Cancel the deletion" after signing in.
public
int
TTL_SECONDS
= 1800
Properties
$secret read-only
private
string
$secret
Methods
__construct()
public
__construct(string $secret) : mixed
Parameters
- $secret : string
issue()
`$requestNonce` is the `deletion_nonce` of the request ('' for a request made before the nonce existed).
public
issue(int $userId, DateTimeInterface $requestedAt, string $requestNonce, DateTimeInterface $now) : string
Parameters
- $userId : int
- $requestedAt : DateTimeInterface
- $requestNonce : string
- $now : DateTimeInterface
Return values
stringmatches()
Returns whether the ticket belongs to the current deletion request (time and nonce) of the account.
public
matches(string $ticket, int $userId, DateTimeInterface|null $requestedAt, string $requestNonce, DateTimeInterface $now) : bool
Parameters
- $ticket : string
- $userId : int
- $requestedAt : DateTimeInterface|null
- $requestNonce : string
- $now : DateTimeInterface
Return values
boolparseUserId()
Returns the user id the ticket was issued for, or null for a malformed or expired ticket.
public
parseUserId(string $ticket, DateTimeInterface $now) : int|null
Parameters
- $ticket : string
- $now : DateTimeInterface
Return values
int|nullsign()
private
sign(int $userId, DateTimeInterface $requestedAt, string $requestNonce, int $expires) : string
Parameters
- $userId : int
- $requestedAt : DateTimeInterface
- $requestNonce : string
- $expires : int