PHPackages                             phpro/zf-mvc-auth-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. phpro/zf-mvc-auth-token

AbandonedArchivedLibrary

phpro/zf-mvc-auth-token
=======================

v0.1.0(11y ago)31.1k1MITPHP

Since Jul 28Pushed 5y ago3 watchersCompare

[ Source](https://github.com/phpro/zf-mvc-auth-token)[ Packagist](https://packagist.org/packages/phpro/zf-mvc-auth-token)[ RSS](/packages/phpro-zf-mvc-auth-token/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (9)Versions (1)Used By (0)

> ## Repository abandoned 2020-11-27
>
> [](#repository-abandoned-2020-11-27)
>
> This repository has been archived since we are not using it anymore internally. Feel free to use it AS-IS, we won't be providing any support anymore.

Mvc-Auth-Token implementation for zend framework 2
==================================================

[](#mvc-auth-token-implementation-for-zend-framework-2)

This module will take care of HTTP Token authentication as described in the [draft-hammer-http-token-auth-01](http://tools.ietf.org/html/draft-hammer-http-token-auth-01). It should be used with [zf-mvc-auth](https://github.com/zfcampus/zf-mvc-auth).

The purpose of this module is to provide an extendable interface for validating Tokens. The validation of the Token should be done in a custom adapter.

Query params
------------

[](#query-params)

In some situations, it is not possible to add the Authentication header to the request. Therefor the token parameters can also be added as query parameters:

```
http://yourserver.local/endpoint
    ?token[realm]=realm
    &token[token]=token
    &token[coverage]=coverage
    &token[nonce]=nonce
    &token[timestamp]=timestamp
    &token[auth]=auth

```

*Note*: This part of the authentication is not in the official draft, but could be useful in some situations.

Installation
============

[](#installation)

```
curl -s https://getcomposer.org/installer | php
php composer.phar install

```

Module Installation
-------------------

[](#module-installation)

### Add to composer.json

[](#add-to-composerjson)

```
"phpro/zf-mvc-auth-token": "dev-master"

```

### Add module to application.config.php

[](#add-module-to-applicationconfigphp)

```
return array(
    'modules' => array(
        'Phpro\MvcAuthToken',
        // other libs...
    ),
    // Other config
);
```

### Add a new listener and adapter in your module 'module.config.php'

[](#add-a-new-listener-and-adapter-in-your-module-moduleconfigphp)

```
return array(
    'service_manager' => array(
        'invokables' => array(
            'YourModule\Authentication\Adapter\TokenAdapter' => 'YourModule\Authentication\Adapter\TokenAdapter',
        )
    ),
    'mvc-auth-token-authentication-listener' => array(
        'YourModule\Authentication\Listener\TokenListener' => array(
            'adapter' => 'YourModule\Authentication\Adapter\TokenAdapter',
        ),
    ),
);
```

\*Note: \* The listener is not an actual class. The AbstractAuthenticationListener will create an AuthenticationListener for you, which is configured with your custom adapter.

### Add a TokenAdapter class to your Module.

[](#add-a-tokenadapter-class-to-your-module)

e.g. `YourModule\Authentication\Adapter\TokenAdapter`

This custom class will implement the AdapterInterface and should be used to validate your token:

```
class YourModule\Authentication\Adapter\TokenAdapter
    implements \Phpro\MvcAuthToken\Adapter\AdapterInterface
{
    // Implement your own Token Adapter logica
}
```

### Add a new listener in your Module::onBootstrap

[](#add-a-new-listener-in-your-moduleonbootstrap)

Now the last step is to add your configured AuthenticationListener to the MvcAuthEvent. When the Authentication event is triggered, your listener will handle Token Authorization.

```
/**
 * @param MvcEvent $e
 */
public function onBootstrap(MvcEvent $e)
{
    $app      = $e->getApplication();
    $events   = $app->getEventManager();
    $services = $app->getServiceManager();

    $events->attach(MvcAuthEvent::EVENT_AUTHENTICATION, $services->get('YourModule\Authentication\Listener\TokenListener'), 1000);
}
```

*Note:* Make sure that the priority is above the current zf-mvc-auth authentication priority.

### How to retrieve the authenticated user?

[](#how-to-retrieve-the-authenticated-user)

```
/** @var \Zend\Authentication\AuthenticationService $authentication */
$authentication = $serviceLocator->get('authentication');
$identity = $authentication->getIdentity();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.3% 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

Unknown

Total

1

Last Release

4307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cab1b0de06c75fec5317beded0c2978f3e9e560e6830c1d9048f3e37b3287342?d=identicon)[phpro](/maintainers/phpro)

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (12 commits)")[![bladeofsteel](https://avatars.githubusercontent.com/u/296507?v=4)](https://github.com/bladeofsteel "bladeofsteel (1 commits)")

### Embed Badge

![Health badge](/badges/phpro-zf-mvc-auth-token/health.svg)

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

###  Alternatives

[socalnick/scn-social-auth

Uses the HybridAuth PHP library to Enable authentication via Google, Facebook, Twitter, Yahoo!, etc for the ZfcUser ZF2 module.

21974.2k3](/packages/socalnick-scn-social-auth)[hrevert/ht-img-module

Image manipulation module for Zend Framework 2

1829.6k2](/packages/hrevert-ht-img-module)

PHPackages © 2026

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