SigningKeyRepository
class SigningKeyRepository
Constants
| protected LOCK_SECONDS |
|
| protected LOCK_WAIT_SECONDS |
|
Methods
Create the signing-key store and its mutation dependencies.
Get the stored keys, newest first, from the writer.
Project keys for server settings without decrypting retired private keys.
Provision the first key without replacing an existing key set.
Publish a replacement, retaining any key already waiting to activate.
Rotate an overdue signing key and prune keys whose retention has passed.
Queue a supplied private key after every key already published for activation.
Import file keys while retaining every token already signed by them.
Remove a compromised key, replacing it immediately if it is signing.
Convert a lifetime to a conservative retention bound, including long months and leap years.
Prune replaced keys after their retention deadlines.
Recompute retention under the set lock and compare before deleting.
Get the newest private key already waiting to activate.
Leave a full publication interval after the newest waiting key.
Store key material and fail if an observer cancels the mutation.
Name the key set whose mutations share a lock.
Prevent a caller's transaction from outliving the key-set lock.
Details
at line 35
__construct(Factory $cache, Repository $config, KeyGenerator $generator, ServerFactory $servers)
Create the signing-key store and its mutation dependencies.
at line 48
Collection
all()
Get the stored keys, newest first, from the writer.
at line 59
array
serverKeys()
Project keys for server settings without decrypting retired private keys.
at line 88
SigningKey|null
create(int $length = KeyGenerator::DEFAULT_LENGTH)
Provision the first key without replacing an existing key set.
at line 110
SigningKey
rotate(int $length = KeyGenerator::DEFAULT_LENGTH)
Publish a replacement, retaining any key already waiting to activate.
at line 139
void
rotateDueKeys(int $length = KeyGenerator::DEFAULT_LENGTH)
Rotate an overdue signing key and prune keys whose retention has passed.
at line 155
SigningKey
import(string $privateKey)
Queue a supplied private key after every key already published for activation.
at line 179
Collection
importFiles(DateTimeInterface|null $retainUntil = null)
Import file keys while retaining every token already signed by them.
at line 245
bool
revoke(string $keyId, int $length = KeyGenerator::DEFAULT_LENGTH)
Remove a compromised key, replacing it immediately if it is signing.
at line 295
static int
lifetimeInSeconds(DateInterval $lifetime)
| internal | shared by key imports and signing-time retention |
Convert a lifetime to a conservative retention bound, including long months and leap years.
at line 306
void
prune()
Prune replaced keys after their retention deadlines.
at line 314
protected void
pruneKeys()
Recompute retention under the set lock and compare before deleting.
at line 350
protected SigningKey|null
waitingKey()
Get the newest private key already waiting to activate.
at line 359
protected CarbonInterface
nextActivation()
Leave a full publication interval after the newest waiting key.
at line 371
protected SigningKey|null
activeKey(Collection $keys)
Get the newest active private key from a newest-first key set.
at line 383
protected SigningKey|null
findByKeyId(Collection $keys, string $keyId)
Find a stored key by its public JWK thumbprint.
at line 393
protected SigningKey
storeKey(array $material, CarbonInterface $activatesAt, CarbonInterface|null $retainUntil = null, int $maxTokenLifetime = 0)
Store key material and fail if an observer cancels the mutation.
at line 410
protected void
deleteKey(SigningKey $key)
Delete a key through its model so key-set observers run atomically.
at line 420
protected string
keySetName()
Name the key set whose mutations share a lock.
at line 428
protected void
ensureNoTransaction()
Prevent a caller's transaction from outliving the key-set lock.
at line 442
protected mixed
mutate(Closure $callback)
Serialize a key-set mutation and commit it before releasing the lock.