19declare(strict_types=1);
57 $this->clock =
$clock ??
static fn():
int => time();
78 if ($this->keys === null) {
85 if (abs($age) > self::MAX_AGE) {
94 return $this->
verify($expected, $proof, $this->keys->current)
95 || ($old_proof !==
null && $this->
verify($expected, $old_proof, $this->keys->current))
96 || ($this->keys->old !==
null && $this->verify($expected, $proof, $this->keys->old));
101 $url = strtoupper($url);
103 return pack(
'N', strlen($access_token)) . $access_token
104 . pack(
'N', strlen($url)) . $url
108 private function verify(
string $expected,
string $signature,
ProofKey $key): bool
110 $decoded = base64_decode($signature,
true);
111 if ($decoded ===
false || $decoded ===
'') {
115 $public_key = openssl_pkey_get_public($key->
toPem());
119 if ($public_key ===
false) {
123 return openssl_verify($expected, $decoded, $public_key, OPENSSL_ALGO_SHA256) === 1;
foreach($mandatory_scripts as $file) $timestamp
Class Exception Thrown if some procedure did not get the arguments it expected.
A public RSA key of a WOPI client, as published in its discovery with base64 encoded modulus and expo...
The current and the previous proof key of a WOPI client.
Verifies that a request was sent by the WOPI client, see https://learn.microsoft.com/en-us/microsoft-...
verify(string $expected, string $signature, ProofKey $key)
isValid(string $access_token, string $url, ?string $timestamp, ?string $proof, ?string $old_proof)
__construct(private ?ProofKeys $keys, ?\Closure $clock=null)
withKeys(ProofKeys $keys)
static expected(string $access_token, string $url, int $timestamp)
const TICKS_AT_UNIX_EPOCH
X-WOPI-TimeStamp counts the 100 nanosecond intervals since 0001-01-01 (.NET ticks).
if(!file_exists('../ilias.ini.php'))