Skip to content

Commit 45256e7

Browse files
committed
Improves documentation, and updates the configuration to leverage the environment
1 parent 306d85b commit 45256e7

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

readme.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,51 @@ A wrapper to add the ability to accept signed requests to a Laravel project.
99
```sh
1010
composer require soapbox/signed-requests
1111
```
12+
13+
### Setup the Service Provider
14+
15+
Open `config/app.php` and register the required service provider above your application providers.
16+
17+
```php
18+
'providers' => [
19+
...
20+
SoapBox\SignedRequests\ServiceProvider::class
21+
...
22+
]
23+
```
24+
25+
### Publish the Configuration
26+
27+
```php
28+
php artisan vendor:publish
29+
```
30+
31+
### Configuring your Environment
32+
33+
You will need to set the following details in your environment:
34+
35+
```sh
36+
SIGNED_REQUEST_SIGNATURE_HEADER=
37+
SIGNED_REQUEST_ALGORITHM_HEADER=
38+
SIGNED_REQUEST_KEY=
39+
```
40+
41+
The `SIGNED_REQUEST_SIGNATURE_HEADER` should be the request header that the signature will be included on, something like `X-SIGNATURE`. Similarly the `SIGNED_REQUEST_ALGORITHM_HEADER` should be the request header that the includes the algorithm used to sign the request. Finally the `SIGNED_REQUEST_KEY` should hold the key used to verify the signed requests.
42+
43+
### Setup the Middleware
44+
45+
Signed Requests includes a middleware to validate the signature of a request for your automatically. To get started, add the following middleware to the `$routeMiddleware` property of your `app/Http/Kernel.php` file.
46+
47+
```php
48+
'verify-signature' => \SoapBox\SignedRequests\Middlewares\VerifySignature::class
49+
```
50+
51+
### Verify the Signature
52+
53+
The `verify-signature` middleware may be assigned to a route to verify the signature of the incoming request to verify its authenticity:
54+
55+
```php
56+
Route::get('/fire', function () {
57+
return "You'll only see this if the signature of the request is valid!";
58+
})->middleware('verify-signature');
59+
```

resources/config/signed-requests.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
| look for the signature and algorithm respectively.
1111
*/
1212
'headers' => [
13-
'signature' => 'X-Signature',
14-
'algorithm' => 'X-Algorithm'
13+
'signature' => env('SIGNED_REQUEST_SIGNATURE_HEADER', 'X-Signature'),
14+
'algorithm' => env('SIGNED_REQUEST_ALGORITHM_HEADER', 'X-Algorithm')
1515
],
1616

1717
/*

0 commit comments

Comments
 (0)