DeviceAuthorizationStore
DeviceAuthorizationStore
Default DBI-backed Hazaar\OAuth\Interface\DeviceAuthorizationStore implementation.
class DeviceAuthorizationStore implements \Hazaar\OAuth\Interface\DeviceAuthorizationStoreImplements: Hazaar\OAuth\Interface\DeviceAuthorizationStore
Expects a table (default oauth_device_codes) with columns device_code_hash (primary key), user_code (unique), client_id, scope (JSON text), resource, expires_at, poll_interval, status, user_identity and last_polled_at. This implementation does not require or provide a schema migration — any text/varchar/integer column types work.
The device code is a bearer secret, so only its SHA-256 hash is stored (the same way Hazaar\OAuth\Store\DBI\RefreshTokenStore stores refresh tokens). Hazaar\OAuth\Store\DBI\DeviceAuthorizationStore::consume deletes and reads back a decided (approved or denied) row in a single DELETE ... RETURNING statement, so concurrent polls can never both redeem the same approval.
Configuration (oauth.server.device_codes_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_device_codes.
Properties
table
private Table $tableType: Hazaar\DBI\Table
Methods
__construct
public __construct(array|Options $options = 'new Options()'): voidParameters
| Parameter | Type | Description |
|---|---|---|
$options | array | Hazaar\OAuth\Store\DBI\Options |
save
public save(DeviceAuthorization $authorization): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$authorization | Hazaar\OAuth\DeviceAuthorization |
update
public update(DeviceAuthorization $authorization): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$authorization | Hazaar\OAuth\DeviceAuthorization |
findByDeviceCode
public findByDeviceCode(string $deviceCode): ?DeviceAuthorizationReturns: Hazaar\OAuth\DeviceAuthorization
Parameters
| Parameter | Type | Description |
|---|---|---|
$deviceCode | string |
findByUserCode
public findByUserCode(string $userCode): ?DeviceAuthorizationReturns: Hazaar\OAuth\DeviceAuthorization
Parameters
| Parameter | Type | Description |
|---|---|---|
$userCode | string |
consume
public consume(string $deviceCode): ?DeviceAuthorizationReturns: Hazaar\OAuth\DeviceAuthorization
Parameters
| Parameter | Type | Description |
|---|---|---|
$deviceCode | string |
hash
private hash(string $deviceCode): stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$deviceCode | string |
columns
private columns(DeviceAuthorization $authorization): arrayReturns: array
Parameters
| Parameter | Type | Description |
|---|---|---|
$authorization | Hazaar\OAuth\DeviceAuthorization |
hydrate
private hydrate(array $record, ?string $deviceCode): DeviceAuthorizationReturns: Hazaar\OAuth\DeviceAuthorization
Parameters
| Parameter | Type | Description |
|---|---|---|
$record | array | |
$deviceCode | string | the plaintext device code when the caller has it; otherwise the stored hash stands in for it |
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:28 +0000