Skip to content
docsv0.12.0

OperationAuthorization

The exact thing a signature authorizes. A confirmation flag says yes without knowing to what: `--yes` on `plugins.remove` consents to removal in the abstract, so the same consent covers removing any plugin, on any host, at any later moment. This carries the target with it, which is what turns consent into authorization — a signature over `MailPlugin` cannot be presented to remove `BillingPlugin`, because the bytes that were signed name one and not the other. Every field is load-bearing: - `operation` and `arguments` — what is being authorized, in full. - `host` — where. An authorization produced against staging is not an authorization in production, and without this the two are the same string. - `issuedAt` — when, so a signature captured today cannot be presented next month. - `nonce` — which one, so it cannot be presented twice inside the freshness window either.

OperationAuthorization::__construct()

public function __construct(string $operation, array $arguments, string $host, string $issuedAt, string $nonce):

Parameters

Parameters of __construct()
NameTypeDescription
$operationstring
$argumentsarray<string, mixed>
$hoststring
$issuedAtstring
$noncestring

OperationAuthorization::canonical()

public function canonical(): string

The bytes that get signed and verified — identical on both sides or nothing works. Sorted keys and no whitespace, because JSON has many spellings of the same object and a signature is over bytes, not over meaning. If the signer serialized `{"a":1,"b":2}` and the verifier rebuilt `{"b":2,"a":1}`, every valid authorization would be rejected — a failure that looks like an attack and is a formatting difference.

OperationAuthorization::ageInSeconds()

public function ageInSeconds(int $now): int

How long ago this was issued, in seconds, against the supplied clock. Negative when the stamp is in the future — which the authorizer treats as a failure rather than as "very fresh", since a clock ahead of ours is either broken or being helped.

Parameters

Parameters of ageInSeconds()
NameTypeDescription
$nowint

OperationAuthorization::fromCanonical()

public static function fromCanonical(string $json): ?self

Rebuild from the canonical bytes, or null when they are not a well-formed authorization. Used by the verifying side, which must parse what it was handed rather than trust a structure it built itself.

Parameters

Parameters of fromCanonical()
NameTypeDescription
$jsonstring