Skip to content

Commit 620733f

Browse files
author
Dave Wong
committed
update readme
1 parent 0e12b0a commit 620733f

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

readme.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,51 @@ Route::get('/fire', function () {
7272
})->middleware('verify-signature');
7373
```
7474

75+
### Setting Up Additional Keys
76+
77+
You can also set up additional keys to use if you want different keys for different endpoints.
78+
79+
Add them to your environment:
80+
81+
```sh
82+
CUSTOM_SIGNED_REQUEST_ALGORITHM=
83+
CUSTOM_SIGNED_REQUEST_CACHE_PREFIX=
84+
CUSTOM_SIGNED_REQUEST_SIGNATURE_HEADER=
85+
CUSTOM_SIGNED_REQUEST_ALGORITHM_HEADER=
86+
CUSTOM_SIGNED_REQUEST_KEY=
87+
CUSTOM_SIGNED_REQUEST_ALLOW_REPLAYS=
88+
CUSTOM_SIGNED_REQUEST_TOLERANCE_SECONDS=
89+
```
90+
91+
Update the configuration in `signed-requests.php`
92+
93+
```php
94+
'default' => [
95+
...
96+
],
97+
'custom' => [
98+
'algorithm' => env('CUSTOM_SIGNED_REQUEST_ALGORITHM', 'sha256'),
99+
'cache-prefix' => env('CUSTOM_SIGNED_REQUEST_CACHE_PREFIX', 'signed-requests'),
100+
'headers' => [
101+
'signature' => env('CUSTOM_SIGNED_REQUEST_SIGNATURE_HEADER', 'X-Signature'),
102+
'algorithm' => env('CUSTOM_SIGNED_REQUEST_ALGORITHM_HEADER', 'X-Signature-Algorithm')
103+
],
104+
'key' => env('CUSTOM_SIGNED_REQUEST_KEY', 'key'),
105+
'request-replay' => [
106+
'allow' => env('CUSTOM_SIGNED_REQUEST_ALLOW_REPLAYS', false),
107+
'tolerance' => env('CUSTOM_SIGNED_REQUEST_TOLERANCE_SECONDS', 30)
108+
]
109+
]
110+
```
111+
112+
Set up your route to use the custom key. The param you pass must be the same name as the key you set in the configuration in `signed-requests.php`
113+
114+
```php
115+
Route::get('/fire', function () {
116+
return "You'll only see this if the signature of the request is valid!";
117+
})->middleware('verify-signature:custom');
118+
```
119+
75120
### Signing Postman Requests
76121

77122
If you, like us, like to use [postman](https://www.getpostman.com/) to share your api internally you can use the following pre-request script to automatically sign your postman requests:

0 commit comments

Comments
 (0)