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

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

imemento/guard-laravel
======================

Our custom guard for Laravel

v8.1.0(4y ago)02.8k1MITPHPPHP ^8.0CI failing

Since May 14Pushed 4y ago2 watchersCompare

[ Source](https://github.com/mementohub/guard-laravel)[ Packagist](https://packagist.org/packages/imemento/guard-laravel)[ Docs](https://github.com/mementohub/guard-laravel)[ RSS](/packages/imemento-guard-laravel/feed)WikiDiscussions v8.1.x Synced 2d ago

READMEChangelogDependencies (5)Versions (22)Used By (1)

iMemento JWT Guard for Laravel
==============================

[](#imemento-jwt-guard-for-laravel)

[![Build Status](https://github.com/mementohub/guard-laravel/workflows/Testing/badge.svg)](https://github.com/mementohub/guard-laravel/actions)[![Latest Stable Version](https://camo.githubusercontent.com/daaf4542cc302a3fc07360a2c540db98c488a3c7814b20121466544307d122cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d656d656e746f2f67756172642d6c61726176656c)](https://packagist.org/packages/imemento/guard-laravel)[![License](https://camo.githubusercontent.com/b7cb3f59212c90f6a09e2b5cfbcc081d9138f6ed90f18b9aef3168dc173cec62/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f696d656d656e746f2f67756172642d6c61726176656c)](https://packagist.org/packages/imemento/guard-laravel)[![Total Downloads](https://camo.githubusercontent.com/11b311e81dd2b4daa0528bcad0052f17b7e04ba55f22dbf7633858d508f7c346/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f696d656d656e746f2f67756172642d6c61726176656c)](https://packagist.org/packages/imemento/guard-laravel)

Takes care of the authorization and sets the roles and permissions for the user and consumer. Depends on the [iMemento JWT](https://gitlab.com/imemento/composer/packages/jwt) package for JWT related tasks. Decrypting the tokens happens in the JWT package.

Install
-------

[](#install)

```
composer require imemento/guard-laravel
```

The package uses Service Discovery. Still, if necessary, you can add the service to `config/app.php`:

```
iMemento\Guard\Laravel\AuthServiceProvider::class,
```

In `config/auth.php` add a guard with *jwt* as the driver:

```
'api' => [
	'driver' 	=> 'jwt',
	'provider' 	=> 'users',
],
```

In `config/auth.php` add a user provider with *static* as the driver. The model needs to be an instance of `iMemento\SDK\Auth\User::class` or an extension of it.

```
'users' => [
	'driver' 	=> 'static',
	'model' 	=> iMemento\SDK\Auth\User::class,
],
```

Dependencies
------------

[](#dependencies)

Since this package handles multiple operations in order to achieve the desired results, the following `.env` variables should be properly defined:

```
AUTH_KEY=
```

Usage
-----

[](#usage)

To use the JWT Guard for all the routes in your `routes/api.php` file you just need to add it to the `api` middleware group in `app/Http/Kernel.php`.

```
'api' => [
	'throttle:60,1',
	'bindings',
	'auth:api', #this
],
```

If your API exposes public endpoints, the ones that should be guarded by the JWT Guard should be specifically grouped:

```
	Route::group(['middleware' => 'auth:api'], function ()) {
		//...
	}
```

Authenticated user
------------------

[](#authenticated-user)

Once the Guard has been applied, the app will have access to an authenticated user through `auth()->user()`.

The following fields are added to the current user and can be used in the application's policies.

```
{
  "id": 13,
  "agency_id": 2,
  "roles": ["admin"],
  "consumer_roles": ["user"],
  "permissions": ["read","write"]
}
```

The fields *id*, *agency\_id* can be null, *roles* can be empty.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 79% 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 ~58 days

Recently: every ~75 days

Total

21

Last Release

1802d ago

Major Versions

v5.8.x-dev → 6.0.02020-09-30

v6.0.x-dev → 7.0.02020-09-30

v7.0.x-dev → v8.0.x-dev2020-09-30

PHP version history (5 changes)5.6.0PHP ^7.1

6.0.0PHP ^7.2

7.0.0PHP ^7.2.5

v8.0.x-devPHP ^7.3

v8.1.x-devPHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![gxgstan](https://avatars.githubusercontent.com/u/3264036?v=4)](https://github.com/gxgstan "gxgstan (49 commits)")[![bcismariu](https://avatars.githubusercontent.com/u/10166477?v=4)](https://github.com/bcismariu "bcismariu (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M220](/packages/backpack-crud)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135224.7k7](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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