RefreshTokenStore
RefreshTokenStore
Default DBI-backed Hazaar\OAuth\Interface\RefreshTokenStore implementation, which can also list and revoke grants
class RefreshTokenStore implements \Hazaar\OAuth\Interface\ListableRefreshTokenStoreImplements: Hazaar\OAuth\Interface\ListableRefreshTokenStore
(Hazaar\OAuth\Interface\ListableRefreshTokenStore).
Expects a table (default oauth_refresh_tokens) with columns token_hash (primary key), client_id, user_identity, scope (JSON text), resource, expires_at, family_id and consumed_at (integer, 0 while the token is unused). The nullable columns created_at, last_used_at and device_label are optional: without them grants are listed without those details. The framework ships the tables as dbitool migrations in libs/dbi/migrations/oauth.json (and oauth_grants.json to add the optional columns to an existing table).
Tokens are hashed with SHA-256 before storage and lookup — the plaintext value is never persisted, the same way a password would be handled.
A token that has been exchanged is kept as a tombstone (consumed_at set) until it expires, rather than deleted, so reuse of a rotated token can be detected and its family_id revoked. Hazaar\OAuth\Store\DBI\RefreshTokenStore::consume marks the row in a single UPDATE ... RETURNING statement, so concurrent redemptions of the same token can never both get it live.
Configuration (oauth.server.refresh_tokens_options):
database(string|array, optional): passed to Hazaar\DBI\Adapter::create. Defaults to the application's default database connection.table(string, optional): table name. Defaults tooauth_refresh_tokens.
Constants
array
private const array = nullProperties
table
private Table $tableType: Hazaar\DBI\Table
grantColumns
public array $grantColumnsType: array
Methods
__construct
public __construct(array|Options $options = 'new Options()'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$options | array | Hazaar\OAuth\Store\DBI\Options |
save
public save(RefreshToken $token): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | Hazaar\OAuth\RefreshToken |
consume
public consume(string $token): ?RefreshTokenReturns: Hazaar\OAuth\RefreshToken
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
find
public find(string $token): ?RefreshTokenReturns: Hazaar\OAuth\RefreshToken
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
revoke
public revoke(string $token): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
revokeFamily
public revokeFamily(string $familyId): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$familyId | string |
listForUser
public listForUser(string $userIdentity): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$userIdentity | string |
revokeById
public revokeById(string $id, string $userIdentity): boolReturns: bool
Parameters
| Parameter | Type | Description |
|---|---|---|
$id | string | |
$userIdentity | string |
revokeAllForUser
public revokeAllForUser(string $userIdentity, ?string $clientId): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$userIdentity | string | |
$clientId | string |
revokeAllForClient
public revokeAllForClient(string $clientId): intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$clientId | string |
revokeWhere
Deletes every token matching the criteria, and returns how many grants (families) still in use lost their
private revokeWhere(array $criteria): intReturns: int
live token. Families with only tombstones left were already unusable, so they aren't counted.
Parameters
| Parameter | Type | Description |
|---|---|---|
$criteria | array |
onlyGrantColumns
Drops the optional grant columns the table doesn't have, so a table created before they existed still works.
private onlyGrantColumns(array $values): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$values | array |
nullableInt
private nullableInt(mixed $value): ?intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$value | mixed |
hash
private hash(string $token): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$token | string |
hydrate
private hydrate(array $record, string $token): RefreshTokenReturns: Hazaar\OAuth\RefreshToken
Parameters
| Parameter | Type | Description |
|---|---|---|
$record | array | |
$token | string |
Generated by Hazaar API Doc Generator on Sun, 08 Nov 2026 03:36:15 +0000