PHPackages                             avn/auth-by-token - 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. avn/auth-by-token

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

avn/auth-by-token
=================

0.1.5(3y ago)013MITPHPPHP &gt;=7.4

Since Jun 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AlexVasechkin/auth-by-token)[ Packagist](https://packagist.org/packages/avn/auth-by-token)[ RSS](/packages/avn-auth-by-token/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (6)Used By (0)

Actions to create authorization via lifetime token
==================================================

[](#actions-to-create-authorization-via-lifetime-token)

How it works
------------

[](#how-it-works)

### For Symfony framework

[](#for-symfony-framework)

First add services to services.yml

```
    Avn\Security\AuthByToken\CreateTokenAction: null
    Avn\Security\AuthByToken\ValidateTokenAction: null
```

Create route to create token for user and send to user email

```
/**
 * @Route("/api/v1/public/create-token-and-send-by-email", methods={"GET"})
 */
public function authByEmail(
    Request $httpRequest,
    MailerInterface $mailer,
    UserRepository $userRepository,
    CreateTokenAction $createTokenAction,
    ParameterBagInterface $parameterBag,
    UrlGeneratorInterface $urlGenerator
) {
    $user = $userRepository->findOneBy(['email' => $httpRequest->toArray()['email'] ]);

    if (is_null($user)) {
        throw new \Exception(sprintf('User[email: %s] not found', $httpRequest->toArray()['email']));
    }

    $token = $createTokenAction->execute($user->getCode()->toBase32());

    $url =   $parameterBag->get('app.host')
           . $urlGenerator->generate('app_login_from_email', ['token' => $token])
    ;

    $mailer->send(
        (new Email())
            ->from($parameterBag->get('app.email.from'))
            ->to($user->getEmail())
            ->subject('Now you can login')
            ->text('Here is your link to login')
            ->html(sprintf('You can login. Just follow the link.', $url))
    );

    return new Response();
}
```

Create route to validate token after user follows the link from email

```
/**
 * @Route("/api/v1/public/login-from-email-link", methods={"POST"}, name="app_login_from_email")
 */
public function register(
    Request $httpRequest,
    ValidateTokenAction $validateTokenAction,
    ParameterBagInterface $parameterBag,
    UserRepository $userRepository
) {
    $response = new RedirectResponse(
        $this->generateUrl('app_dashboard_home')
    );

    $validateTokenAction->execute(
        $httpRequest->get('token'),
        function (AuthTokenData $tokenData, array $payload) use ($response, $parameterBag, $userRepository) {

            $user = $userRepository->findOneByCodeOrFail($payload['sub']);

            $response->headers->setCookie(
                new Cookie(
                    'dashboard-user',
                    $user->getCode(),
                    60 * 60 * 12,
                    '/dashboard',
                    $parameterBag->get('app.host'),
                    true,
                    true
                )
            );
        }
    );

    return $response;
}
```

###  Health Score

19

—

LowBetter than 9% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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 ~0 days

Total

5

Last Release

1117d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.1.2PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae1733023c2dea6cb76f21f20e1fe5266dda8ba76cccc6dd9bbd0e93f56fddb9?d=identicon)[Alex.Vasechkin](/maintainers/Alex.Vasechkin)

---

Top Contributors

[![AlexVasechkin](https://avatars.githubusercontent.com/u/44292324?v=4)](https://github.com/AlexVasechkin "AlexVasechkin (10 commits)")

### Embed Badge

![Health badge](/badges/avn-auth-by-token/health.svg)

```
[![Health](https://phpackages.com/badges/avn-auth-by-token/health.svg)](https://phpackages.com/packages/avn-auth-by-token)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M218](/packages/google-auth)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M218](/packages/api-platform-metadata)[rainlab/user-plugin

User plugin for October CMS

11955.0k15](/packages/rainlab-user-plugin)

PHPackages © 2026

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