Only the hash is stored
The secret goes into the link or the cookie, the store keeps its SHA-256. Whoever reads the store, a replica or a backup gets nothing they can sign in with.
Tokens for reset links, invitations and sessions. Random secrets go to the user, only their hashes are stored, in Redis or in memory.
use Solo\Tokens\RedisTokenStore;
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$resets = new RedisTokenStore($redis, 'app:password-reset:');
$secret = $resets->issue($email, ttlSeconds: 3600);
$mailer->send($email, "https://example.com/reset?token={$secret}");
// Later, when the link comes back:
$token = $resets->consume($submittedToken) ?? throw new InvalidResetLink();
$users->setPassword($token->subject, $newPassword);The store keeps only the hash of $secret. consume() returns the token once and null ever after. Read the getting-started guide for sessions, revoking and tokens kept in your own tables.
PHP 8.3+ is required. Composer installs psr/clock ^1.0 with the package. RedisTokenStore needs the redis extension and Redis 5.0 or later.
composer require solophp/tokensContinue with the getting-started guide.