Download the PHP package tilleuls/url-signer-bundle without Composer
On this page you can find all versions of the php package tilleuls/url-signer-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package url-signer-bundle
UrlSignerBundle
Create and validate signed URLs with a limited lifetime in Symfony.
This bundle is based on spatie/url-signer.
Installation
Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
If you're using Symfony Flex, all configuration is already done.
You can customize it in config/packages/url_signer.yaml
file.
Otherwise, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
Configuration
Add a signature key (as environment variable):
In dev mode, you can use an .env
file:
You can change the signer used to create the signature:
The default expiration time can be changed too.
In seconds:
With a date/time string:
You can also customize the URL parameter names:
Usage
Generate a Signed URL
To create a temporary signed URL for a route, you first need to inject the URL signer to your service or controller:
If autowiring is enabled (the default Symfony configuration) in your application, you have nothing more to do.
Otherwise, inject the url_signer.signer
service in the configuration:
You can now use the URL signer to generate a signed path or a signed URL:
Validate Signed Route Requests
To deny access to a route if the signature is not valid,
add a _signed
extra parameter to the route configuration:
If the signature is invalid (bad signature or expired URL), the request will receive a 403 response (access denied).
Custom Signer
If you need to use a specific hash algorithm for generating the signature, you can create your own signer.
Create a class extending the AbstractUrlSigner
class:
If autoconfiguring is enabled (the default Symfony configuration) in your application, you are done.
Otherwise, register and tag your service:
You can now use your custom signer:
Credits
Created by Alan Poulain for Les-Tilleuls.coop.
All versions of url-signer-bundle with dependencies
spatie/url-signer Version ^2.0
symfony/config Version ^4.4 || ^5.1 || ^6.0 || ^7.0
symfony/dependency-injection Version ^4.4 || ^5.1 || ^6.0 || ^7.0
symfony/event-dispatcher Version ^4.4 || ^5.1 || ^6.0 || ^7.0
symfony/http-kernel Version ^4.4 || ^5.1 || ^6.0 || ^7.0
symfony/routing Version ^4.4 || ^5.1 || ^6.0 || ^7.0