class OAuthAccounts

Constants

DEFAULT_CACHE_TTL

DEFAULT_CACHE_PREFIX

protected DEFAULT_ACCOUNT_MODEL

Properties

static protected OAuthAccount> $accountModel
static protected bool $initialized
static protected string|null $partitionColumn
static protected null|Closure(): null|int|string $partitionResolver
protected Repository|null $cache
protected int $cacheTtl
protected Repository|null $renewalCache
protected string $renewalStore

Methods

__construct(Repository $config, Factory $cacheFactory, ModelCacheCoordinator $cacheCoordinator, ModelCacheStoreValidator $cacheValidator, TokenAcquisition $acquisition, ExceptionHandler $exceptions)

Create the account service.

static void
useAccountModel(string $model)

Select the account model.

static string
accountModel()

Get the configured account model.

static void
resolvePartitionUsing(string $column, Closure $resolver)

Configure the account partition resolver.

string|null
partition()

Resolve the current partition, rejecting missing configured context.

void
prepareAccount(OAuthAccount $account)

Validate an existing account's partition or fill it for a new account.

identity(OAuthAccount $account)

Capture an account's persisted storage identity.

void
ensurePartition(OAuthAccountIdentity $identity)

Check that an account reference still belongs to the active context.

find(OAuthAccountIdentity $identity)

Read committed credentials, using the shared cache when enabled.

void
invalidate(OAuthAccountIdentity $identity)

Invalidate the account after its transaction commits.

token(OAuthAccountIdentity $identity, Closure $refreshUsing)

Get current credentials, sharing one bounded renewal with waiting callers.

usableToken(OAuthAccount $account)

Return a usable token, or null when renewal must run first.

renew(OAuthAccountIdentity $identity, Closure $refreshUsing, int $attempt, int|null $retryDelay)

Claim, perform and persist one provider attempt while holding the renewal lock.

replacementToken(OAuthAccountIdentity $identity)

Use the authoritative replacement after losing a conditional write.

int|null
retryDelay(Throwable $exception, string|null $error, int $attempt)

Calculate a bounded provider retry delay in milliseconds.

string|null
oauthError(Throwable $exception)

Read a structured OAuth error without inspecting exception messages.

ResponseInterface|null
failureResponse(Throwable $exception)

Get the response retained by the supported OAuth clients.

bool
cacheEnabled()

Determine whether shared credential caching is enabled.

cache()

Resolve and validate the credential cache only when it is used.

renewalCache()

Resolve and validate the renewal lock store only when it is used.

string
cacheKey(OAuthAccountIdentity $identity)

Build the shared credential key.

static void
flushState()

Flush all static state.

Details

at line 71
__construct(Repository $config, Factory $cacheFactory, ModelCacheCoordinator $cacheCoordinator, ModelCacheStoreValidator $cacheValidator, TokenAcquisition $acquisition, ExceptionHandler $exceptions)

Create the account service.

Parameters

Repository $config
Factory $cacheFactory
ModelCacheCoordinator $cacheCoordinator
ModelCacheStoreValidator $cacheValidator
TokenAcquisition $acquisition
ExceptionHandler $exceptions

at line 88
static void useAccountModel(string $model)

Select the account model.

The model persists for the worker lifetime and affects every account operation.

Parameters

string $model

Return Value

void

at line 107
static string accountModel()

Get the configured account model.

Return Value

string

at line 119
static void resolvePartitionUsing(string $column, Closure $resolver)

Configure the account partition resolver.

The column and callback persist for the worker lifetime and affect every account operation.

Parameters

string $column
Closure $resolver

Return Value

void

at line 137
string|null partition()

Resolve the current partition, rejecting missing configured context.

Return Value

string|null

at line 157
void prepareAccount(OAuthAccount $account)

Validate an existing account's partition or fill it for a new account.

Parameters

OAuthAccount $account

Return Value

void

at line 187
OAuthAccountIdentity identity(OAuthAccount $account)

Capture an account's persisted storage identity.

Parameters

OAuthAccount $account

Return Value

OAuthAccountIdentity

at line 222
void ensurePartition(OAuthAccountIdentity $identity)

Check that an account reference still belongs to the active context.

Parameters

OAuthAccountIdentity $identity

Return Value

void

at line 232
OAuthAccount find(OAuthAccountIdentity $identity)

Read committed credentials, using the shared cache when enabled.

Parameters

OAuthAccountIdentity $identity

Return Value

OAuthAccount

at line 255
void invalidate(OAuthAccountIdentity $identity)

Invalidate the account after its transaction commits.

Parameters

OAuthAccountIdentity $identity

Return Value

void

at line 275
OAuthAuthenticator token(OAuthAccountIdentity $identity, Closure $refreshUsing)

Get current credentials, sharing one bounded renewal with waiting callers.

Parameters

OAuthAccountIdentity $identity
Closure $refreshUsing

Return Value

OAuthAuthenticator

at line 321
protected OAuthAuthenticator|null usableToken(OAuthAccount $account)

Return a usable token, or null when renewal must run first.

Parameters

OAuthAccount $account

Return Value

OAuthAuthenticator|null

at line 347
protected OAuthAuthenticator renew(OAuthAccountIdentity $identity, Closure $refreshUsing, int $attempt, int|null $retryDelay)

Claim, perform and persist one provider attempt while holding the renewal lock.

Parameters

OAuthAccountIdentity $identity
Closure $refreshUsing
int $attempt
int|null $retryDelay

Return Value

OAuthAuthenticator

at line 462
protected OAuthAuthenticator replacementToken(OAuthAccountIdentity $identity)

Use the authoritative replacement after losing a conditional write.

Parameters

OAuthAccountIdentity $identity

Return Value

OAuthAuthenticator

at line 475
protected int|null retryDelay(Throwable $exception, string|null $error, int $attempt)

Calculate a bounded provider retry delay in milliseconds.

Parameters

Throwable $exception
string|null $error
int $attempt

Return Value

int|null

at line 507
protected string|null oauthError(Throwable $exception)

Read a structured OAuth error without inspecting exception messages.

Parameters

Throwable $exception

Return Value

string|null

at line 530
protected ResponseInterface|null failureResponse(Throwable $exception)

Get the response retained by the supported OAuth clients.

Parameters

Throwable $exception

Return Value

ResponseInterface|null

at line 542
protected bool cacheEnabled()

Determine whether shared credential caching is enabled.

Return Value

bool

at line 550
protected Repository cache()

Resolve and validate the credential cache only when it is used.

Return Value

Repository

at line 572
protected Repository renewalCache()

Resolve and validate the renewal lock store only when it is used.

Return Value

Repository

at line 591
protected string cacheKey(OAuthAccountIdentity $identity)

Build the shared credential key.

Parameters

OAuthAccountIdentity $identity

Return Value

string

at line 599
static void flushState()

Flush all static state.

Return Value

void