Download the PHP package soapbox/signed-requests without Composer
On this page you can find all versions of the php package soapbox/signed-requests. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package signed-requests
Signed Requests
A wrapper to add the ability to accept signed requests to a Laravel project.
Installation
Composer
Setup the Service Provider
Open config/app.php
and register the required service provider above your application providers.
Publish the Configuration
Configuring your Environment
You will need to set the following details in your environment:
Each of the settings above allows for a different level of configuration.
SIGNED_REQUEST_ALGORITHM
is the algorithm that will be used to generate / verify the signature. This is defaulted to usesha256
feel free to change this to anything thathash_hmac
accepts.SIGNED_REQUEST_CACHE_PREFIX
is the prefix to use for all the cache keys that will be generated. Here you can use the default if you're not planning on sharing a cache between multiple applications.SIGNED_REQUEST_SIGNATURE_HEADER
should be the request header that the signature will be included on,X-Signature
will be used by default.SIGNED_REQUEST_ALGORITHM_HEADER
should be the request header that the includes the algorithm used to sign the request.SIGNED_REQUEST_KEY
is the shared secret key between the application generating the requests, and the application consuming them. This value should not be publically available.SIGNED_REQUEST_ALLOW_REPLAYS
allows you to enable or disable replay attacks. By default replays are disabled.SIGNED_REQUEST_TOLERANCE_SECONDS
is the number of seconds that a request will be considered for. This setting allows for some time drift between servers and is only used when replays are disabled.
Setup the Middleware
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.
Verify the Signature
The verify-signature
middleware may be assigned to a route to verify the signature of the incoming request to verify its authenticity:
Setting Up Additional Keys
You can also set up additional keys to use if you want different keys for different endpoints.
Add them to your environment:
Update the configuration in signed-requests.php
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
Signing Postman Requests
If you, like us, like to use postman to share your api internally you can use the following pre-request script to automatically sign your postman requests:
Note for this to work you'll have to setup your environment to have the following variables:
{{url}}
this is the base url to the api you'll be hitting.{{key}}
this is the shared secret key you'll be using in your environment.
All other environment variables that will be needed will be automatically generated by the above script.
All versions of signed-requests with dependencies
guzzlehttp/guzzle Version ^6.2|^7.2
illuminate/http Version ^7.0
illuminate/support Version ^7.0
nesbot/carbon Version ^2.0
ramsey/uuid Version ^3.6