PHPackages                             proklung/url-signer-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. proklung/url-signer-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

proklung/url-signer-bundle
==========================

Create and validate signed URLs with a limited lifetime in custom Symfony

1.0.2(4y ago)13MITPHPPHP &gt;=7.3 || ^8.0

Since May 31Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ProklUng/url.signer.bundle)[ Packagist](https://packagist.org/packages/proklung/url-signer-bundle)[ RSS](/packages/proklung-url-signer-bundle/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (3)Dependencies (11)Versions (4)Used By (0)

UrlSignerBundle
===============

[](#urlsignerbundle)

Форк [пакета](https://github.com/coopTilleuls/UrlSignerBundle). Доработано под личные нужды.

Установка
---------

[](#установка)

composer.json:

```
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/proklung/url.signer.bundle"
        }
    ]
```

```
composer require proklung/url-signer-bundle
```

Пример конфигурации
-------------------

[](#пример-конфигурации)

```
url_signer:
  signature_key: 'testkey'
  signer: 'md5' # 'sha256' by default
  default_expiration: 24 # 1 day by default
  expires_parameter: 'expires' # 'expires' by default
  signature_parameter: 'signature' # 'signature' by default
```

Оригинальная документация
-------------------------

[](#оригинальная-документация)

Create and validate signed URLs with a limited lifetime in Symfony.

This bundle is based on [spatie/url-signer](https://github.com/spatie/url-signer).

```
## Configuration

Add a signature key (as environment variable):

```yml
# config/packages/url_signer.yaml
url_signer:
    signature_key: '%env(string:SIGNATURE_KEY)%'

```

In dev mode, you can use an `.env` file:

```
# .env (or .env.local)
SIGNATURE_KEY=your_signature_key
```

You can change the signer used to create the signature:

```
# config/packages/url_signer.yaml
url_signer:
    signer: 'md5' # 'sha256' by default
```

The default expiration time (in days) can be changed too:

```
# config/packages/url_signer.yaml
url_signer:
    default_expiration: 3 # 1 by default
```

You can also customize the URL parameter names:

```
# config/packages/url_signer.yaml
url_signer:
    expires_parameter: 'exp' # 'expires' by default
    signature_parameter: 'sign' # 'signature' by default
```

Usage
-----

[](#usage)

### Generate a Signed URL

[](#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:

```
// src/Controller/DocumentController.php
namespace App\Controller;

use CoopTilleuls\UrlSignerBundle\UrlSigner\UrlSignerInterface;

class DocumentController
{
    public function __construct(
        private UrlSignerInterface $urlSigner,
    ) {}
}
```

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:

```
# config/services.yaml
services:
    App\Controller\DocumentController:
        arguments:
            $urlSigner: '@url_signer.signer'
```

You can now use the URL signer to generate a signed URL:

```
// src/Controller/DocumentController.php
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

class DocumentController extends AbstractController
{
    private function generateSignedUrl(): string
    {
        $url = $this->generateUrl('secured_document', ['id' => 42]);
        // Will expire after one hour.
        $expiration = (new \DateTime('now'))->add(new \DateInterval('PT1H'));
        // An integer can also be used for the expiration: it will correspond to a number of days. For 3 days:
        // $expiration = 3;

        // Not passing the second argument will use the default expiration time (1 day by default).
        // return $this->urlSigner->sign($url);

        // Will return a URL (more precisely a path) like this: /documents/42?expires=1611316656&signature=82f6958bd5c96fda58b7a55ade7f651fadb51e12171d58ed271e744bcc7c85c3
        return $this->urlSigner->sign($url, $expiration);
    }
}
```

### Validate Signed Route Requests

[](#validate-signed-route-requests)

To deny access to a route if the signature is not valid, add a `_signed` [extra parameter](https://symfony.com/doc/current/routing.html#extra-parameters) to the route configuration:

```
# config/routes.yaml
secured_document:
    path: /documents/{id}
    controller: App\Controller\DocumentController::index
    defaults:
        _signed: true
```

If the signature is invalid (bad signature or expired URL), the request will receive a 403 response (access denied).

Custom Signer
-------------

[](#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:

```
// src/UrlSigner/CustomUrlSigner.php
namespace App\UrlSigner;

use CoopTilleuls\UrlSignerBundle\UrlSigner\AbstractUrlSigner;
use Psr\Http\Message\UriInterface;

class CustomUrlSigner extends AbstractUrlSigner
{
    public static function getName(): string
    {
        return 'custom';
    }

    protected function createSignature(UriInterface|string $url, string $expiration): string
    {
        $url = (string) $url;

        return hash_hmac('algo', "{$url}::{$expiration}", $this->signatureKey);
    }
}
```

If autoconfiguring is enabled (the default Symfony configuration) in your application, you are done.

Otherwise, register and tag your service:

```
# config/services.yaml
services:
    App\UrlSigner\CustomUrlSigner:
        # You don't need to specify the arguments
        tags: ['url_signer.signer']
```

You can now use your custom signer:

```
# config/packages/url_signer.yaml
coop_tilleuls_url_signer:
    signer: 'custom'
```

Credits
-------

[](#credits)

Created by [Alan Poulain](https://github.com/alanpoulain) for [Les-Tilleuls.coop](https://les-tilleuls.coop/).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Total

3

Last Release

1735d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.3

1.0.2PHP &gt;=7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9210c86ee6734e537eaf22c0f2fe7a965451e340e39e1aae2b74013f24c2660d?d=identicon)[gedovan](/maintainers/gedovan)

---

Top Contributors

[![ProklUng](https://avatars.githubusercontent.com/u/19857467?v=4)](https://github.com/ProklUng "ProklUng (7 commits)")

---

Tags

bitrix-symfonyphp7wordpress-symfony

### Embed Badge

![Health badge](/badges/proklung-url-signer-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/proklung-url-signer-bundle/health.svg)](https://phpackages.com/packages/proklung-url-signer-bundle)
```

###  Alternatives

[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M192](/packages/simplesamlphp-simplesamlphp)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[scheb/2fa-bundle

A generic interface to implement two-factor authentication in Symfony applications

6914.0M61](/packages/scheb-2fa-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
