PHPackages                             elao/voucher-authentication-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. elao/voucher-authentication-bundle

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

elao/voucher-authentication-bundle
==================================

Provide authentication through vouchers (for email link).

1107PHP

Since Nov 23Pushed 9y ago5 watchersCompare

[ Source](https://github.com/Elao/VoucherAuthenticationBundle)[ Packagist](https://packagist.org/packages/elao/voucher-authentication-bundle)[ RSS](/packages/elao-voucher-authentication-bundle/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Elao Voucher Authentication Bundle [![](https://camo.githubusercontent.com/61152b881283ea7ef22753ec89f7e3cd9dc52b33937bd304426f94c5bc6962fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d332e302d626c75652e737667)](https://camo.githubusercontent.com/61152b881283ea7ef22753ec89f7e3cd9dc52b33937bd304426f94c5bc6962fc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d332e302d626c75652e737667)
========================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#elao-voucher-authentication-bundle-)

Provide authentication through vouchers (for email link).

Installation
------------

[](#installation)

### Require the package through composer:

[](#require-the-package-through-composer)

```
composer require elao/voucher-authentication-bundle

```

### Register the bundle in your `app/AppKernel.php`:

[](#register-the-bundle-in-your-appappkernelphp)

```
class AppKernel extends Kernel {
    public function registerBundles() {
        return [
            // ...
            new Elao\Bundle\VoucherAuthenticationBundle\ElaoVoucherAuthenticationBundle(),
        ];
    }
}
```

### Declare the voucher route

[](#declare-the-voucher-route)

By importing the provided route configuration in your `app/config/routing.yml`:

```
# routing.yml
elao_voucher_authentication:
    resource: "@ElaoVoucherAuthenticationBundle/Resources/config/routing.xml"
    prefix:   /
```

**Note:** You can also declare your own route as long as you specify the corresponding `check_path` and `token_parameter` parameters in your voucher security configuration (see "Custom voucher route").

Usage
-----

[](#usage)

### Enabling voucher authentication

[](#enabling-voucher-authentication)

The Voucher Authentication bundle porvider a `voucher` security provider.

You can enable voucher authentication very simply in your `security.yml`:

```
security:
    firewalls:
        main:
            voucher: ~
```

### Generate a voucher token in your app

[](#generate-a-voucher-token-in-your-app)

Create a new `VoucherInterface` (you can use the provided `DisposableAuthenticationVoucher` implementation or make your own). Then get its token with `getToken()` and, for example, send it to the user by email:

```
use Elao\Bundle\VoucherAuthenticationBundle\Voucher\DisposableAuthenticationVoucher;

class SecurityController extends Controller {
    /**
     * @Route("forgot-password", name="forgot_password")
     */
    public function forgotPasswordAction()
    {
        $voucher = new DisposableAuthenticationVoucher('jane_doe', '+1 hour');
        $activationUrl = $this->generateUrl('voucher', ['token' => $voucher->getToken()]);

        // Don't forget to persist the voucher, or the user won't be able to log in.
        $this->get('elao_voucher_authentication.voucher_provider.default')->persist($voucher);

        $this->mailer->sendResetPasswordEmail($activationUrl);
    }
}
```

### Generate a voucher token from CLI

[](#generate-a-voucher-token-from-cli)

Generate a voucher for the given username (optionally set a time-to-live):

```
bin/console voucher:generate:authenticatio [username] (--ttl="+1 hour")

```

Will result in:

> Authentication voucher for user admin with expiration on 2016-11-15 13:42:24: 6fb11ec1eecd07865d940dd0f990d66b

### Restricting user access using vouchers

[](#restricting-user-access-using-vouchers)

You can protect a route, or any part of you app, by requiring a specific voucher authentication. For exameple, you can allow the route to reset password only to users authenticated via a Voucher with intent `reset_password`.

Use the following security expression: `is_granted('voucher', $intent)` where $intent is the intent you provided to your `Voucher` object.

```
class SecurityController extends Controller
{
    /**
     * @Route("reset_password", name="reset_password")
     * @Security("is_granted('voucher', 'password')")
     */
    public function resetPasswordAction() {}
}

## Full configuration

```yml
security:
    firewalls:
        main:
            voucher:
                remember_me: true
                check_path: voucher
                use_forward: false
                require_previous_session: true
                token_parameter: token
                always_use_default_target_path: false
                default_target_path: /
                login_path: /login
                target_path_parameter: _target_path
                use_referer: false
                failure_path: null
                failure_forward: false
                failure_path_parameter: _failure_path
                voucher_provider: elao_voucher_authentication.voucher_provider.default
```

Custom voucher route
--------------------

[](#custom-voucher-route)

```
# routing.yml
my_voucher_route:
    path: /activate/{my_token}
```

```
security:
    firewalls:
        main:
            voucher:
                check_path: my_voucher_route
                token_parameter: my_token
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e4d0789a5e5af7d70bc34a8afbcafde6ecbe03649eeaee631534759f7d848e2?d=identicon)[Tom32i](/maintainers/Tom32i)

![](https://avatars.githubusercontent.com/u/623877?v=4)[Elao](/maintainers/Elao)[@Elao](https://github.com/Elao)

---

Top Contributors

[![Tom32i](https://avatars.githubusercontent.com/u/1846873?v=4)](https://github.com/Tom32i "Tom32i (8 commits)")

### Embed Badge

![Health badge](/badges/elao-voucher-authentication-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/elao-voucher-authentication-bundle/health.svg)](https://phpackages.com/packages/elao-voucher-authentication-bundle)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

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