grixu / passport-module-auth
This package provides model, command & middleware to easily forbid access to certain modules(domains in DDD) when using Client Credentials Grant Tokens
Requires
- php: ^7.1|^8.0
- illuminate/console: ^8.0
- illuminate/database: ^8.0
- illuminate/http: ^8.0
- illuminate/support: ^8.0
- laravel/passport: ^10.1
Requires (Dev)
- brainmaestro/composer-git-hooks: ^2.8
- friendsofphp/php-cs-fixer: ^3.1
- nunomaduro/larastan: ^0.7.12 || ^1.0.0
- nunomaduro/phpinsights: ^2.0
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.4
- spatie/x-ray: ^1.1
- dev-main
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.23.0
- dev-dependabot/github_actions/8398a7/action-slack-3.15.0
- dev-dependabot/github_actions/dependabot/fetch-metadata-1.3.5
- dev-dependabot/github_actions/actions/cache-3.0.11
- dev-dependabot/github_actions/actions/checkout-3.1.0
This package is auto-updated.
Last update: 2023-01-26 01:19:55 UTC
README
This package provides model, commands & middleware to easily forbid access to certain modules(domains in DDD) when using Client Credentials Grant Tokens.
Installation
You can install the package via composer:
composer require grixu/passport-module-auth
Usage
Publish config file to adjust module names in your project:
php artisan vendor:publish --tag=config --provider=Grixu\\PassportModuleAuth\\PassportModuleAuthServiceProvider
Add the middleware to your Kernel class which handling HTTP requests in your Laravel project. In default project scaffold you should edit: app/Http/Kernel.php
use Grixu\PassportModuleAuth\Middleware\ModuleAuthMiddleware; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => Authenticate::class, 'auth.basic' => AuthenticateWithBasicAuth::class, 'client' => CheckClientCredentials::class, 'cache.headers' => SetCacheHeaders::class, 'can' => Authorize::class, 'guest' => RedirectIfAuthenticated::class, 'password.confirm' => RequirePassword::class, 'signed' => ValidateSignature::class, 'throttle' => ThrottleRequests::class, 'verified' => EnsureEmailIsVerified::class, 'passport_module' => ModuleAuthMiddleware::class ];
Then just use it in your controllers or routes. Remember about passing module name!
Route::middleware(['passport_module:products']);
Artisan command
You can use artisan command passport:module-auth
to manage entries in Module Auth system.
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email mateusz.gostanski@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.