class TokenIssuance implements NonCopyableContext, Transient

Constants

protected CONTEXT_KEY

protected REVOCATION_BATCH_SIZE

Properties

AuthCode|DeviceCode|RefreshToken|null $grant
ClientEntityInterface|null $client
Token|null $accessToken
string|null $refreshTokenFamilyId
string|null $tokenName
string|null $dpopJkt
null|list<string> $approvedScopes
null|list<string> $refreshTokenScopes
null|list<string> $requestedResources
null|array<string, list<string>> $resources
list<string> $audience
protected Connection|null $connection
protected int $transactionLevel
protected bool $claimed
protected array<string, mixed> $authorizationAttributes

Methods

__construct(ServerEntry $entry, SigningCryptKey $signingKey, CarbonImmutable $startedAt, bool $tokenRequest = false)

Pin one issuance to its settings and active signing key.

static TokenIssuance|null
current()

Get the current issuance, if one is running.

static mixed
run(ServerFactory $servers, Closure $callback, array $attributes = [], bool $tokenRequest = false)

Run a fresh issuance and restore any enclosing operation afterwards.

bool
isTokenRequest()

Determine whether this operation exchanges credentials for tokens.

void
setGrant(AuthCode|DeviceCode|RefreshToken|null $grant)

Record the grant already read during validation.

void
setClient(ClientEntityInterface $client)

Record the client selected for this operation.

void
setAccessToken(Token $token)

Keep the saved access token available to response extensions.

void
setAuthorizationAttributes(array $attributes)

Record the attributes captured when the user authorized the request.

array
attributes()

Get the attributes carried from authorization or the redeemed grant.

static void
ensureRedemptionAllowed(Connection $connection)

Reject redemption whose durable security writes could be rolled back by its caller.

void
begin()

Begin the credential transaction at the first validated write.

void
claimGrant(string|null $accessTokenId = null)

Claim a validated single-use grant before creating its successor tokens.

bool
hasClaimed(Model $grant, string $id)

Determine whether this operation already consumed a grant.

void
commit()

Commit the issuance before returning its completed response.

void
rollBack()

Undo the issuance without disturbing an enclosing caller's transaction.

void
retainSigningKey(DateTimeInterface $expiresAt, DateInterval|null $lifetime = null)

Retain the signing key until this token's complete lifetime has passed.

static void
revokeAuthCodeTokens(AuthCode $code)

Revoke the credentials issued by a reused authorization code.

static void
revokeRefreshTokenFamily(string $familyId)

Revoke a refresh grant and every access token still linked to it.

static void
revokeAccessTokens(Builder $query)

Revoke selected access tokens within the caller's credential transaction.

Details

at line 80
__construct(ServerEntry $entry, SigningCryptKey $signingKey, CarbonImmutable $startedAt, bool $tokenRequest = false)

Pin one issuance to its settings and active signing key.

Parameters

ServerEntry $entry
SigningCryptKey $signingKey
CarbonImmutable $startedAt
bool $tokenRequest

at line 91
static TokenIssuance|null current()

Get the current issuance, if one is running.

Return Value

TokenIssuance|null

at line 104
static mixed run(ServerFactory $servers, Closure $callback, array $attributes = [], bool $tokenRequest = false)

Run a fresh issuance and restore any enclosing operation afterwards.

Parameters

ServerFactory $servers
Closure $callback
array $attributes
bool $tokenRequest

Return Value

mixed

at line 142
bool isTokenRequest()

Determine whether this operation exchanges credentials for tokens.

Return Value

bool

at line 150
void setGrant(AuthCode|DeviceCode|RefreshToken|null $grant)

Record the grant already read during validation.

Parameters

AuthCode|DeviceCode|RefreshToken|null $grant

Return Value

void

at line 162
void setClient(ClientEntityInterface $client)

Record the client selected for this operation.

Parameters

ClientEntityInterface $client

Return Value

void

at line 170
void setAccessToken(Token $token)

Keep the saved access token available to response extensions.

Parameters

Token $token

Return Value

void

at line 180
void setAuthorizationAttributes(array $attributes)

Record the attributes captured when the user authorized the request.

Parameters

array $attributes

Return Value

void

at line 190
array attributes()

Get the attributes carried from authorization or the redeemed grant.

Return Value

array

at line 207
static void ensureRedemptionAllowed(Connection $connection)

Reject redemption whose durable security writes could be rolled back by its caller.

Device polling timestamps and credential replay revocations must survive OAuth error responses.

Parameters

Connection $connection

Return Value

void

at line 217
void begin()

Begin the credential transaction at the first validated write.

Return Value

void

at line 242
void claimGrant(string|null $accessTokenId = null)

Claim a validated single-use grant before creating its successor tokens.

Parameters

string|null $accessTokenId

Return Value

void

at line 277
bool hasClaimed(Model $grant, string $id)

Determine whether this operation already consumed a grant.

Parameters

Model $grant
string $id

Return Value

bool

at line 286
protected void commit()

Commit the issuance before returning its completed response.

Return Value

void

at line 309
protected void rollBack()

Undo the issuance without disturbing an enclosing caller's transaction.

Return Value

void

at line 322
void retainSigningKey(DateTimeInterface $expiresAt, DateInterval|null $lifetime = null)

Retain the signing key until this token's complete lifetime has passed.

Parameters

DateTimeInterface $expiresAt
DateInterval|null $lifetime

Return Value

void

at line 363
static void revokeAuthCodeTokens(AuthCode $code)

Revoke the credentials issued by a reused authorization code.

Parameters

AuthCode $code

Return Value

void

at line 382
static void revokeRefreshTokenFamily(string $familyId)

Revoke a refresh grant and every access token still linked to it.

Parameters

string $familyId

Return Value

void

at line 411
static void revokeAccessTokens(Builder $query)

Revoke selected access tokens within the caller's credential transaction.

Parameters

Builder $query

Return Value

void