PHPackages                             authava/laravel - 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. authava/laravel

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

authava/laravel
===============

Laravel integration for Authava authentication service

v1.0.0(1y ago)02MITPHPPHP ^8.1

Since Mar 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/authava/laravel)[ Packagist](https://packagist.org/packages/authava/laravel)[ RSS](/packages/authava-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Authava Laravel Client
======================

[](#authava-laravel-client)

A Laravel integration package for the Authava authentication service.

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

[](#installation)

You can install the package via composer:

```
composer require authava/laravel
```

Configuration
-------------

[](#configuration)

1. Publish the configuration file:

```
php artisan vendor:publish --tag=authava-config
```

2. Add your Authava configuration to your `.env` file:

```
AUTHAVA_DOMAIN=auth.yourdomain.com
AUTHAVA_RESOLVER_DOMAIN=api.yourdomain.com # Optional
AUTHAVA_SECURE=true
AUTHAVA_AUTO_REFRESH=true
AUTHAVA_REFRESH_BUFFER=5
AUTHAVA_CACHE_TTL=300
```

Basic Usage
-----------

[](#basic-usage)

### Protecting Routes

[](#protecting-routes)

Add the middleware to your routes:

```
use Authava\Laravel\Middleware\AuthavaAuthenticate;

Route::middleware([AuthavaAuthenticate::class])->group(function () {
    Route::get('/protected', function (Request $request) {
        // Access the authenticated user
        $user = $request->get('authava_user');
        return response()->json(['user' => $user]);
    });
});
```

### User Synchronization

[](#user-synchronization)

If you want to automatically sync Authava users with your local database, use the `EnsureUserExists` middleware:

```
use Authava\Laravel\Middleware\AuthavaAuthenticate;
use Authava\Laravel\Middleware\EnsureUserExists;

Route::middleware([
    AuthavaAuthenticate::class,
    EnsureUserExists::class,
])->group(function () {
    Route::get('/profile', function (Request $request) {
        // Access your local user model
        $user = $request->get('user');
        return response()->json(['user' => $user]);
    });
});
```

### Using the Facade

[](#using-the-facade)

```
use Authava\Laravel\Facades\Authava;

// Get the current session
$session = Authava::getSession($request->header('Cookie'));

// Clear session cache
Authava::clearSessionCache($cookie);

// Get configuration
$config = Authava::getConfig();
```

### Direct Usage

[](#direct-usage)

If you prefer dependency injection:

```
use Authava\Laravel\AuthavaClient;

class UserController extends Controller
{
    public function __construct(private AuthavaClient $authava)
    {
    }

    public function profile(Request $request)
    {
        $session = $this->authava->getSession($request->header('Cookie'));
        // ...
    }
}
```

User Synchronization
--------------------

[](#user-synchronization-1)

The package provides two approaches for user synchronization:

### 1. Middleware Approach

[](#1-middleware-approach)

Use the `EnsureUserExists` middleware to automatically sync users:

```
Route::middleware([
    AuthavaAuthenticate::class,
    EnsureUserExists::class,
])->group(function () {
    // Routes here will have access to synchronized users
});
```

### 2. Manual Synchronization

[](#2-manual-synchronization)

Implement your own user synchronization logic:

```
use App\Models\User;

class UserService
{
    public function syncAuthavaUser(array $authavaUser): User
    {
        return User::updateOrCreate(
            ['auth_id' => $authavaUser['id']],
            [
                'email' => $authavaUser['email'],
                'name' => $authavaUser['name'] ?? null,
                // Map other fields as needed
            ]
        );
    }
}
```

Configuration Options
---------------------

[](#configuration-options)

### Session Caching

[](#session-caching)

The package caches session data to reduce API calls. Configure the TTL in your `.env`:

```
AUTHAVA_CACHE_TTL=300 # Cache for 5 minutes
```

### User Model Mapping

[](#user-model-mapping)

Configure how Authava user fields map to your user model:

```
// config/authava.php
return [
    'user_model' => \App\Models\User::class,
    'user_fields' => [
        'auth_id' => 'id',
        'email' => 'email',
        'name' => 'name',
        // Add custom field mappings
    ],
];
```

Testing
-------

[](#testing)

```
composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Authava](https://authava.com)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance46

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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

Unknown

Total

1

Last Release

415d ago

### Community

Maintainers

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

---

Top Contributors

[![Stackout](https://avatars.githubusercontent.com/u/4387849?v=4)](https://github.com/Stackout "Stackout (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/authava-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/authava-laravel/health.svg)](https://phpackages.com/packages/authava-laravel)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[truckersmp/steam-socialite

Laravel Socialite provider for Steam OpenID.

1516.7k](/packages/truckersmp-steam-socialite)

PHPackages © 2026

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