PHPackages                             equidna/domain-token-auth - 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. equidna/domain-token-auth

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

equidna/domain-token-auth
=========================

Secure domain-based token authentication package for Laravel

2.2.0(2mo ago)0128↓86.7%MITPHPPHP ^8.2

Since Apr 20Pushed 2mo agoCompare

[ Source](https://github.com/EquidnaMX/domain-token-auth)[ Packagist](https://packagist.org/packages/equidna/domain-token-auth)[ RSS](/packages/equidna-domain-token-auth/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (4)Dependencies (7)Versions (5)Used By (0)

README
======

[](#readme)

> This documentation follows the coding conventions reflected throughout the codebase.

---

Project Overview
----------------

[](#project-overview)

**`equidna/domain-token-auth`** is a Laravel package that provides secure, domain-scoped opaque token authentication. It issues cryptographically random tokens tied to a *functional domain*, a polymorphic owner model, a set of roles and fine-grained actions, optional custom `data` payload, and an optional validity window. Tokens are stored only as SHA-256 hashes; the plain-text value is shown exactly once at issuance time.

**Who it is for:**

- Laravel application developers who need API token authentication without depending on Laravel Sanctum or Passport.
- Multi-tenant SaaS platforms that must ensure a token issued for one tenant cannot be used in another tenant's context (via optional `equidna/bee-hive` integration).
- Integrators building machine-to-machine token pipelines with per-domain authorization rules.

**Main use cases:**

- Issuing short-lived or long-lived tokens for human users, application clients, services, or partner integrations, each in its own named domain.
- Protecting routes with per-domain middleware (`domain-token:{domain}`).
- Enforcing fine-grained action authorization with wildcard support (`users.*`, `*`).
- Attaching and consuming domain-specific metadata through token `data` after authentication.
- Revoking tokens immediately without modifying the consuming request flow.

---

Project Type &amp; Tech Summary
-------------------------------

[](#project-type--tech-summary)

PropertyValue**Project type**Laravel **package** (library)**Package name**`equidna/domain-token-auth`**PHP version**`^8.2`**Laravel version**`^12.0` (via `illuminate/*` components)**Primary database**Relies on the host application's configured database**Cache**Not used internally**Queue**Not used internally**Key external service**`equidna/bee-hive` *(optional)* - multi-tenant context propagation---

Quick Start
-----------

[](#quick-start)

1. **Install** via Composer:

    ```
    composer require equidna/domain-token-auth
    ```
2. **Publish the configuration** file:

    ```
    php artisan vendor:publish --tag=domain-token-auth:config
    ```
3. **Publish and run migrations**:

    ```
    php artisan vendor:publish --tag=domain-token-auth:migrations
    php artisan migrate
    ```
4. **Implement `TokenOwner`** on your owner model and add the `HasDomainTokens` trait:

    ```
    use Equidna\DomainTokenAuth\Concerns\HasDomainTokens;
    use Equidna\DomainTokenAuth\Contracts\TokenOwner;
    use Illuminate\Database\Eloquent\Model;

    class User extends Model implements TokenOwner
    {
        use HasDomainTokens;
    }
    ```
5. **Configure your domains** in `config/domain-token-auth.php`.
6. **Protect routes** with the `domain-token` middleware:

    ```
    Route::middleware('domain-token:user')->group(function () {
        Route::get('/profile', ProfileController::class);
    });
    ```
7. **Issue tokens** via the facade or Artisan command:

    ```
    use Equidna\DomainTokenAuth\Facades\DomainToken;

    $issued = DomainToken::issue(
       domain: 'user',
       owner: $user,
       roles: ['admin'],
       data: ['client' => 'mobile', 'region' => 'mx']
    );
    $plainToken = $issued->plainTextToken; // show once
    ```
8. **Consume authenticated token data** in protected routes:

    ```
    Route::middleware('domain-token:user')->get('/me', function () {
       return [
          'client' => DomainToken::data('client'),
          'all_data' => DomainToken::data(),
       ];
    });
    ```

For full details, see [Deployment Instructions](doc/deployment-instructions.md).

---

Documentation Index
-------------------

[](#documentation-index)

- [Deployment Instructions](doc/deployment-instructions.md)
- [API Documentation](doc/api-documentation.md)
- [Routes Documentation](doc/routes-documentation.md)
- [Artisan Commands](doc/artisan-commands.md)
- [Tests Documentation](doc/tests-documentation.md)
- [Architecture Diagrams](doc/architecture-diagrams.md)
- [Monitoring](doc/monitoring.md)
- [Business Logic &amp; Core Processes](doc/business-logic-and-core-processes.md)
- [Open Questions &amp; Assumptions](doc/open-questions-and-assumptions.md)

---

License
-------

[](#license)

MIT - see [LICENSE](LICENSE).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance84

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Total

4

Last Release

80d ago

Major Versions

1.0.0 → 2.0.02026-04-21

### Community

Maintainers

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

---

Top Contributors

[![gruelasjr](https://avatars.githubusercontent.com/u/40619710?v=4)](https://github.com/gruelasjr "gruelasjr (11 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/equidna-domain-token-auth/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k96.5k1](/packages/mike-bronner-laravel-model-caching)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1613.3k4](/packages/masterix21-laravel-licensing)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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