PHPackages                             gashey/lumen-passport-resource - 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. gashey/lumen-passport-resource

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

gashey/lumen-passport-resource
==============================

A lumen passport client grant resource server package

0.1.7(6y ago)020MITPHPPHP &gt;=7.1.3

Since Jul 14Pushed 6y agoCompare

[ Source](https://github.com/gashey/lumen-passport-resource)[ Packagist](https://packagist.org/packages/gashey/lumen-passport-resource)[ Docs](https://github.com/gashey/lumen-passport-resource)[ RSS](/packages/gashey-lumen-passport-resource/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

[![Build Status](https://camo.githubusercontent.com/feb742d054079db4954cc36c85e69a6659642158437ad18a5944d411cb6fe655/68747470733a2f2f7472617669732d63692e6f72672f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652e737667)](https://travis-ci.org/gashey/lumen-passport-resource)[![Code Climate](https://camo.githubusercontent.com/66bb4d28da69964a657afa526e4e10beec52bfa0bfb17788d7c9305e7af10670/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652f6261646765732f6770612e737667)](https://codeclimate.com/github/gashey/lumen-passport-resource/badges)[![Total Downloads](https://camo.githubusercontent.com/e5680a80b200cbd0612f1239cda63c7ea7e23bdd3712cb339fdea3d426a8ccae/68747470733a2f2f706f7365722e707567782e6f72672f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652f642f746f74616c2e737667)](https://packagist.org/packages/gashey/lumen-passport-resource)[![Latest Stable Version](https://camo.githubusercontent.com/b775a13381e8425b9d2d79eab3c4625abe17cbc29caae43ecc9d2e441e2e9ff8/68747470733a2f2f706f7365722e707567782e6f72672f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652f762f737461626c652e737667)](https://packagist.org/packages/gashey/lumen-passport-resource)[![Latest Unstable Version](https://camo.githubusercontent.com/06c8f4329bde01672b5cc5a1e098dccfa7fa9db187d59e74f18a6652caf9e5a1/68747470733a2f2f706f7365722e707567782e6f72672f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652f762f756e737461626c652e737667)](https://packagist.org/packages/gashey/lumen-passport-resource)[![License](https://camo.githubusercontent.com/64a43ae1b105a4c0ecd7f1049cfdf9407e47fe35a05fce096a5bc3cbbbadc46a/68747470733a2f2f706f7365722e707567782e6f72672f6761736865792f6c756d656e2d70617373706f72742d7265736f757263652f6c6963656e73652e737667)](https://packagist.org/packages/gashey/lumen-passport-resource)

Lumen-Passport as an oauth client grant Resource Server
=======================================================

[](#lumen-passport-as-an-oauth-client-grant-resource-server)

Making Laravel Passport work with Lumen as a Client Grant Resource Server. This makes it easy to protect routes and check scopes via Passport middleware. This package requires  created by Denis Mysenko.

A simple service provider that makes Laravel Passport work with Lumen as a resource server

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

[](#dependencies)

- PHP &gt;= 7.1.3
- Lumen &gt;= 5.3

Installation via Composer
-------------------------

[](#installation-via-composer)

First install Lumen if you don't have it yet:

```
$ composer create-project --prefer-dist laravel/lumen lumen-app
```

Then install Lumen Passport (it will fetch Laravel Passport along):

```
$ cd lumen-app
$ composer require gashey/lumen-passport-resource
```

### Modify the bootstrap flow (`bootstrap/app.php` file)

[](#modify-the-bootstrap-flow-bootstrapappphp-file)

We need to enable both Laravel Passport provider and Lumen-specific providers:

```
// Enable Facades
$app->withFacades();

// Enable Eloquent
$app->withEloquent();

// Enable the client middleware and scopes middleware (shipped with Passport)
$app->routeMiddleware([
    'client' => \Laravel\Passport\Http\Middleware\CheckClientCredentials::class,
    'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
]);

// Finally register three service providers - original one and Lumen adapter
$app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class);
$app->register(Gashey\LumenPassportResource\PassportServiceProvider::class);
```

### Run Migrations for Gashey Passport

[](#run-migrations-for-gashey-passport)

```
# Create new tables for Gashey Passport
php artisan migrate
```

### Resource Server Public Key

[](#resource-server-public-key)

This package requires your public key from your Passport Authorization Server.

Copy the "oauth-public.key" file from the 'storage folder' of your Authorization Server project into the 'storage folder of your Resource Server project.

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

[](#configuration)

Edit config/auth.php to suit your needs. A simple example:

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

    'guards' => [
        'api' => [
            'driver' => 'passport',
            'provider' => 'users',
        ],
    ],

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => \App\User::class
        ]
    ]
];
```

Load the config in `bootstrap/app.php` since Lumen doesn't load config files automatically:

```
$app->configure('auth');
```

User model
----------

[](#user-model)

Make sure your user model uses Passport's `HasApiTokens` trait, eg.:

```
class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use HasApiTokens, Authenticatable, Authorizable;

    /* rest of the model */
}
```

Protect routes
--------------

[](#protect-routes)

Add the client and scopes middleware to your routes

```
$router->group(['middleware' => ['client', 'scopes:...'], 'prefix' => 'api/v1'], function () use ($router) {

});
```

Running with Apache httpd
-------------------------

[](#running-with-apache-httpd)

If you are using Apache web server, it may strip Authorization headers and thus break Passport.

Add the following either to your config directly or to `.htaccess`:

```
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

```

License
-------

[](#license)

The MIT License (MIT) Copyright (c) 2019 George Kofi Hagan

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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

Total

7

Last Release

2542d ago

PHP version history (2 changes)0.1.1PHP &gt;=5.6.4

0.1.3PHP &gt;=7.1.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/52868887?v=4)[George Kofi Hagan](/maintainers/gashey)[@gashey](https://github.com/gashey)

---

Top Contributors

[![gashey](https://avatars.githubusercontent.com/u/52868887?v=4)](https://github.com/gashey "gashey (33 commits)")

---

Tags

phplumenlaravel passport

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gashey-lumen-passport-resource/health.svg)

```
[![Health](https://phpackages.com/badges/gashey-lumen-passport-resource/health.svg)](https://phpackages.com/packages/gashey-lumen-passport-resource)
```

###  Alternatives

[dusterio/lumen-passport

Making Laravel Passport work with Lumen

6601.3M9](/packages/dusterio-lumen-passport)

PHPackages © 2026

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