Skip to content

Commit e7daf56

Browse files
committed
Missing signature is validated inside the SignatureStrategy
1 parent 4212914 commit e7daf56

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/ImageServer/LocalImageServer.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ private function validateSignature(RequestInterface $request, string $path): voi
148148
$signatureParameterName = $this->imageStorage->getConfig()[Config::SIGNATURE_PARAMETER_NAME];
149149
assert(is_string($signatureParameterName));
150150

151-
$token = $request->getQueryParameter($signatureParameterName) ?? '';
152-
assert(is_string($token));
153-
154-
if (empty($token)) {
155-
throw new SignatureException('Missing signature in request.');
156-
}
151+
$token = (string) ($request->getQueryParameter($signatureParameterName) ?? '');
157152

158153
if (!$signatureStrategy->verifyToken($token, $path)) {
159154
throw new SignatureException('Request contains invalid signature.');

src/Security/SignatureStrategy.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function verifyToken(string $token, string $path): bool
3535
return true;
3636
}
3737

38+
if ('' === $token) {
39+
return false;
40+
}
41+
3842
return hash_equals($token, $this->doCreateToken(path: $path));
3943
}
4044

0 commit comments

Comments
 (0)