PHPackages                             graphene-ict/laravel-cognito-guard - 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. graphene-ict/laravel-cognito-guard

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

graphene-ict/laravel-cognito-guard
==================================

Laravel authentication guard to validate JSON Web Tokens (JWT) issued by an AWS Cognito User Pool

v1.0.0(3y ago)210[4 PRs](https://github.com/GrapheneICT/laravel-cognito-guard/pulls)MITPHPPHP ^7.3|^8.0

Since Sep 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/GrapheneICT/laravel-cognito-guard)[ Packagist](https://packagist.org/packages/graphene-ict/laravel-cognito-guard)[ Docs](https://github.com/GrapheneICT/laravel-cognito-guard)[ RSS](/packages/graphene-ict-laravel-cognito-guard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (17)Versions (10)Used By (0)

Laravel Cognito Guard
=====================

[](#laravel-cognito-guard)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d0ce040bbd7e97c7832204cfd306a9be3b6fcce0ce26f29f9fd48fc84fca1fa6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6772617068656e656963742f6772617068656e652d6963742d6c61726176656c2d636f676e69746f2d67756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graphene-ict/laravel-cognito-guard)[![GitHub Tests Action Status](https://camo.githubusercontent.com/5cdc3736512a57fb705fd9984ea8f61277b0ae7ab8af91b0aa240b2a82fbb553/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6772617068656e656963742f6772617068656e652d6963742d6c61726176656c2d636f676e69746f2d67756172642f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/GrapheneICT/laravel-cognito-guard/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/5542c60eba6ad7b73b521b73e3f25972205386362fabb00266e540f6fbaaa7ac/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6772617068656e656963742f6772617068656e652d6963742d6c61726176656c2d636f676e69746f2d67756172642f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/GrapheneICT/laravel-cognito-guard/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/0f2a8d8f562d9408ba941755da563bb4626cb6f4c0f2f31de13400b92a242365/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6772617068656e656963742f6772617068656e652d6963742d6c61726176656c2d636f676e69746f2d67756172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graphene-ict/laravel-cognito-guard)

Laravel authentication guard to validate JSON Web Tokens (JWT) issued by an AWS Cognito User Pool

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

[](#installation)

You can install the package via composer:

```
composer require graphene-ict/laravel-cognito-guard
```

You can publish the config file with:

```
php artisan vendor:publish --provider="GrapheneICT\CognitoGuard\Services\CognitoAuthServiceProvider" --tag="config"
```

This is the contents of the published config file:

```
return [
    /*
     * If persist_user_data is true the cognito guard will automatically create a new user
     * record anytime the user contained in a validated JWT
     * does not already exist in the users table.
     *
     * The new user will be created with the user attributes name, email, provider and provider_id so
     * it is required for you to add them at the list of fillable attributes in the model array, if you
     * wish to add more attributes from the cognito modify before it is saved or use the events.
     *
     */
    'persist_user_data' => true,

    'models' => [
        /*
         * When using this package, we need to know which
         * Eloquent model should be used for your user. Of course, it
         * is often just the "User" model but you may use whatever you like.
         *
         */
        'user' => [
            'model' => App\Models\User::class,
        ],
    ],
];
```

Since `persist_user_data` is `true` by default user will be automatically saved with the following attributes: `name, email, provider and provider_id` so adding them in the list of fillables is a must. If you wish to extend with more attributes using the class `CognitoService` modify the data before it is saved or use the events.

```
   $cognitoService = new CognitoService();
   $attributes = $cognitoService->getCognitoUserAttributes($token);
```

Usage
-----

[](#usage)

In config`auth` create additional guard with the coginto driver

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

After that just apply it to the Authentication Defaults as option for authentication shown bellow

```
    'defaults' => [
        'guard' => 'api',
        'passwords' => 'users',
    ],
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Jovan Stojiljkovic](https://github.com/GrapheneICT)

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

1326d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8160951a0cd8e658add59bc36c59497d410ac3a82ab800aa6cd40b54f188f287?d=identicon)[graphene](/maintainers/graphene)

---

Top Contributors

[![jstojiljkovic](https://avatars.githubusercontent.com/u/22980168?v=4)](https://github.com/jstojiljkovic "jstojiljkovic (18 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")

---

Tags

laravelGrapheneICTlaravel-cognito-guard

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/graphene-ict-laravel-cognito-guard/health.svg)

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

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[clerkinc/backend-php

2755.0k](/packages/clerkinc-backend-php)

PHPackages © 2026

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