PHPackages                             denniseilander/laravel-passport-scopes-restriction - 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. denniseilander/laravel-passport-scopes-restriction

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

denniseilander/laravel-passport-scopes-restriction
==================================================

Restrict scopes for different Laravel Passport clients.

3.0.1(1y ago)1630.6k↓18.8%1[6 PRs](https://github.com/denniseilander/laravel-passport-scopes-restriction/pulls)MITPHPPHP ^8.2CI passing

Since May 16Pushed 1mo agoCompare

[ Source](https://github.com/denniseilander/laravel-passport-scopes-restriction)[ Packagist](https://packagist.org/packages/denniseilander/laravel-passport-scopes-restriction)[ Docs](https://github.com/denniseilander/laravel-passport-client-scopes)[ GitHub Sponsors](https://github.com/denniseilander)[ RSS](/packages/denniseilander-laravel-passport-scopes-restriction/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (16)Used By (0)

Laravel Passport client scopes restriction
==========================================

[](#laravel-passport-client-scopes-restriction)

[![Packagist Version](https://camo.githubusercontent.com/6dc9c5b8d9f91fa246b2c48ad1e371d18eabece71547780dc904733e02ee5e07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/6dc9c5b8d9f91fa246b2c48ad1e371d18eabece71547780dc904733e02ee5e07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e2e7376673f7374796c653d666c61742d737175617265)[![PHP Version Support](https://camo.githubusercontent.com/a7d06915e20ef417cf1b8a326c9bf783f22319093aba654f418fa5ea259c87b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/a7d06915e20ef417cf1b8a326c9bf783f22319093aba654f418fa5ea259c87b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e3f7374796c653d666c61742d737175617265)[![GitHub Workflow Status (with branch)](https://camo.githubusercontent.com/e826f8f5137a16f82e193a278fc5784507cb7490e5cbca232a9e895171c76774/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e2f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/e826f8f5137a16f82e193a278fc5784507cb7490e5cbca232a9e895171c76774/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e2f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/0128420e9b0f1c222ed17cacb41c4dee0faa10516b05960ab10f9b689dcf5fa0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64656e6e697365696c616e6465722f6c61726176656c2d70617373706f72742d73636f7065732d7265737472696374696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/denniseilander/laravel-passport-scopes-restriction)

This package allows you to limit the scopes a client can request.
By default, [Laravel Passport](https://laravel.com/docs/master/passport) doesn't support restricting scopes per client. Every client can access all available scopes in your project. This package solves that problem.

When to use this package
------------------------

[](#when-to-use-this-package)

When your api project contains multiple third party oauth\_clients, and you can't control which scopes they request, you may want to limit the scopes a client can request.

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

[](#installation)

You can install the package via composer:

```
composer require denniseilander/laravel-passport-scopes-restriction
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Denniseilander\PassportScopeRestriction\PassportClientServiceProvider" --tag="passport-scopes-restriction-migrations"
php artisan migrate
```

Optionally you can publish the config file with:

```
php artisan vendor:publish --provider="Denniseilander\PassportScopeRestriction\PassportClientServiceProvider" --tag="passport-scopes-restriction-config"
```

Usage
-----

[](#usage)

After running the migration, you may add specific scopes to each of your oauth\_clients `allowed_scopes` column. You can assign specific scopes the same way as they are assigned to the oauth\_access\_tokens `scopes` column:

```
// one scope
["read-users"]

// multiple scopes
["read-users","edit-users"]
```

Every time an access token is requested for a specific client, the `allowed_scopes` will be added to the `scopes` column of that token.

You may also add an allowed scope within your `POST: passport/oauth` request, to specific assign a scope to that access\_token:

```
// The same scopes are defined in the allowed_scopes column of the oauth_clients table
Passport::tokensCan([
    'scope-1' => 'Scope 1',
    'scope-2' => 'Scope 2',
    'scope-3' => 'Scope 3',
]);

POST /oauth/token ?scope=scope-1
```

This will only assign `scope-1` to the access\_token.

You may leave the scope field empty, which will assign all allowed scopes to the access\_token

Syncing existing scopes with new allowed scopes
-----------------------------------------------

[](#syncing-existing-scopes-with-new-allowed-scopes)

Sometimes you have your `oauth_access_tokens` table filled with existing tokens and want to update the scopes because you've changed the `allowed_scopes` value of a specific client.

This package makes it easy to synchronize exiting token scopes with your allowed scopes by running the following command:

```
php artisan passport:scopes-sync
```

If you've **added new scopes** to the `allowed_scopes` column on the clients table, but you want to keep the existing scopes on your tokens, you may add the `--keep-existing-scopes` flag to the sync command:

```
php artisan passport:scopes-sync --keep-existing-scopes
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Dennis Eilander](https://github.com/denniseilander)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance71

Regular maintenance activity

Popularity36

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 63.8% 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 ~158 days

Recently: every ~287 days

Total

10

Last Release

399d ago

Major Versions

v0.1.4 → 1.0.02022-02-19

1.0.0 → 2.0.02023-03-11

2.1.0 → 3.0.02024-07-13

PHP version history (3 changes)v0.1.0PHP ^7.4|^8.0

2.0.0PHP ^8.1

3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/05bbd1e057d0dd39c1a0e302aabafdfdd0ea4cf211e4d392c67588198c797644?d=identicon)[denniseilander](/maintainers/denniseilander)

---

Top Contributors

[![denniseilander](https://avatars.githubusercontent.com/u/3907144?v=4)](https://github.com/denniseilander "denniseilander (95 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (33 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (21 commits)")

---

Tags

laravellaravel passportdenniseilanderlaravel-passport-scopes-restriction

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/denniseilander-laravel-passport-scopes-restriction/health.svg)

```
[![Health](https://phpackages.com/badges/denniseilander-laravel-passport-scopes-restriction/health.svg)](https://phpackages.com/packages/denniseilander-laravel-passport-scopes-restriction)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[jeffgreco13/filament-breezy

A custom package for Filament with login flow, profile and teams support.

1.0k1.7M41](/packages/jeffgreco13-filament-breezy)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)[ryangjchandler/laravel-cloudflare-turnstile

A simple package to help integrate Cloudflare Turnstile.

438896.6k2](/packages/ryangjchandler-laravel-cloudflare-turnstile)[spatie/laravel-passkeys

Use passkeys in your Laravel app

444494.4k16](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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