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(2y ago)013MITPHPPHP &gt;=7.4

Since Jun 11Pushed 2y 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 1mo ago

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 10% 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

1071d 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.4k272.7M162](/packages/google-auth)[thenetworg/oauth2-azure

Azure Active Directory OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2509.6M48](/packages/thenetworg-oauth2-azure)[stevenmaguire/oauth2-keycloak

Keycloak OAuth 2.0 Client Provider for The PHP League OAuth2-Client

2275.9M27](/packages/stevenmaguire-oauth2-keycloak)[patrickbussmann/oauth2-apple

Sign in with Apple OAuth 2.0 Client Provider for The PHP League OAuth2-Client

1132.5M6](/packages/patrickbussmann-oauth2-apple)[socialiteproviders/microsoft

Microsoft OAuth2 Provider for Laravel Socialite

326.1M13](/packages/socialiteproviders-microsoft)[microsoft/kiota-authentication-phpleague

Authentication provider for Kiota using the PHP League OAuth 2.0 client to authenticate against the Microsoft Identity platform

153.2M7](/packages/microsoft-kiota-authentication-phpleague)

PHPackages © 2026

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