KMP PHP API Reference

ServicePrincipalToken extends BaseEntity
in package

ServicePrincipalToken Entity - API Authentication Tokens

Supports multiple tokens per service principal for rotation.

Table of Contents

Properties

$branch_id  : int|null
$created  : DateTime
$created_by  : int|null
$creator  : Member|null
$expires_at  : DateTime|null
$id  : int
$last_used_at  : DateTime|null
$modified  : DateTime|null
$name  : string|null
$service_principal  : ServicePrincipal
$service_principal_id  : int
$token_hash  : string
$_accessible  : array<string, bool>
Fields accessible for mass assignment.
$_hidden  : array<string|int, string>

Methods

generateToken()  : string
Generate a new token (plain text - hash before storing).
getBranchId()  : int|null
Get the branch ID for authorization checks.
hashToken()  : string
Hash a token for storage.
isExpired()  : bool
Check if the token has expired.
_getExpiresAtToString()  : string
Get formatted expiration date for display.
_getLastUsedAtToString()  : string
Get formatted last used date for display.
_getMaskedHash()  : string
Get masked token hash for display (first/last 8 chars).

Properties

$branch_id

public int|null $branch_id

Associated branch ID (when applicable)

$modified

public DateTime|null $modified

Last modification timestamp

$_accessible

Fields accessible for mass assignment.

protected array<string, bool> $_accessible = ['service_principal_id' => true, 'name' => true, 'expires_at' => true, 'last_used_at' => true, 'created_by' => true]

$_hidden

protected array<string|int, string> $_hidden = ['token_hash']

Fields hidden from serialization

Methods

generateToken()

Generate a new token (plain text - hash before storing).

public static generateToken() : string
Return values
string

32-byte base64-encoded token

getBranchId()

Get the branch ID for authorization checks.

public getBranchId() : int|null

Child classes should override for complex branch relationships.

Return values
int|null

The branch ID, or null if no association

hashToken()

Hash a token for storage.

public static hashToken(string $token) : string
Parameters
$token : string

Plain text token

Return values
string

Hashed token (SHA-256)

_getExpiresAtToString()

Get formatted expiration date for display.

protected _getExpiresAtToString() : string
Return values
string

_getLastUsedAtToString()

Get formatted last used date for display.

protected _getLastUsedAtToString() : string
Return values
string

_getMaskedHash()

Get masked token hash for display (first/last 8 chars).

protected _getMaskedHash() : string
Return values
string

        
On this page

Search results