RefreshTokenStore
RefreshTokenStore
Storage for opaque, revocable refresh tokens.
interface RefreshTokenStoreImplement this against whatever persistence an application already uses and bind it via the oauth.server.refresh_tokens config key. Hazaar\OAuth\Store\DBI\RefreshTokenStore provides a ready-to-use DBI-backed implementation.
Implementations must never persist token in plaintext — hash it (e.g. hash('sha256', ...)) before storage and compare hashes on lookup, the same way a password would be handled.
Methods
__construct
Construct the store.
public __construct(array $config): voidParameters
| Parameter | Type | Description |
|---|---|---|
$config | array |
save
Persists a newly-issued refresh token.
public save(RefreshToken $token): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | Hazaar\OAuth\RefreshToken |
consume
Atomically marks a refresh token as used and returns it.
public consume(string $token): ?RefreshTokenReturns: Hazaar\OAuth\RefreshToken
The authorization server rotates refresh tokens on every use, so marking the token and reading it back are one atomic operation: of two concurrent redemptions of the same token, only one gets it back live.
A token that has already been used is not deleted. It is kept as a tombstone until it expires, so that presenting it again (reuse of a rotated token) can be detected and the whole family revoked. In that case the stored record is returned unchanged, with consumedAt set.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
find
Looks a refresh token up without using it: live tokens and tombstones alike, and expired
public find(string $token): ?RefreshTokenReturns: Hazaar\OAuth\RefreshToken
ones too, so a client can still revoke a token it no longer trusts.
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
revoke
Revokes a single refresh token outright, without rotating it.
public revoke(string $token): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
revokeFamily
Revokes every token in a family: the live token, and the tombstones of those rotated out.
public revokeFamily(string $familyId): voidReturns: void
Used on refresh token reuse, and when a client revokes its grant.
Parameters
| Parameter | Type | Description |
|---|---|---|
$familyId | string |
Generated by Hazaar API Doc Generator on Sun, 08 Nov 2026 03:36:15 +0000