Skip to content

Commit 65ec541

Browse files
committed
nonce
1 parent e675245 commit 65ec541

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,23 @@ echo '</pre>';
276276
277277
<dfn>Signature Authentication</dfn> is done by the PHP SDK by default internally so you do not need to worry about this :)
278278
279+
If you script the same request payload multiple times in quick succession (for example inside a health check or tight integration test loop), add a random nonce to keep each signature unique:
280+
281+
```php
282+
$params = [
283+
'auth' => [
284+
'key' => 'MY_TRANSLOADIT_KEY',
285+
'expires' => gmdate('Y/m/d H:i:s+00:00', strtotime('+2 hours')),
286+
'nonce' => bin2hex(random_bytes(16)),
287+
],
288+
'steps' => [
289+
//
290+
],
291+
];
292+
```
293+
294+
The nonce is optional for regular usage, but including it in heavily scripted flows prevents Transloadit from rejecting repeated identical signatures.
295+
279296
### Signature Auth (Smart CDN)
280297
281298
You can use the `signedSmartCDNUrl` method to generate signed URLs for Transloadit's [Smart CDN](https://transloadit.com/services/content-delivery/):

test/bootstrap.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public function setUp(): void {
2525
'key' => TRANSLOADIT_KEY,
2626
'secret' => TRANSLOADIT_SECRET,
2727
]);
28+
29+
try {
30+
$nonce = bin2hex(random_bytes(16));
31+
} catch (\Exception $e) {
32+
$nonce = uniqid('php-sdk-', true);
33+
}
34+
$this->request->params['auth']['nonce'] = $nonce;
2835
}
2936
}
3037

0 commit comments

Comments
 (0)