mijnkantoor / middleware.oauth
Laravel OAuth2 middleware
Requires
- php: >=7
- ext-json: *
- hellohi/api-client: ^2.0
- illuminate/support: 5.5.x|5.6.x|5.7.x|5.8.x|^6.0|^7.0
- symfony/http-foundation: ^3.1|^4
- symfony/http-kernel: ^3.1|^4
Requires (Dev)
- laravel/framework: ^5.7
- orchestra/testbench: 3.3.x|3.4.x|3.5.x|3.6.x|3.7.x
- phpunit/phpunit: ^4.8|^5.2|^7.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2025-04-15 23:14:22 UTC
README
Installation
Require the mijnkantoor/middleware.oauth
package in your composer.json
and update your dependencies:
$ composer require mijnkantoor/middleware.oauth
For laravel >=5.5 that's all. This package supports Laravel new Package Discovery.
If you are using Laravel < 5.5 or have package discovery disabled, you also need to add OauthMiddleware\ServiceProvider to your config/app.php
providers array:
MijnKantoor\OauthMiddleware\ServiceProvider::class,
Global usage
To allow OAuth for all your routes, add the ValidateOAuth
middleware in the $middleware
property of app/Http/Kernel.php
class:
protected $middleware = [ // ... \MijnKantoor\OauthMiddleware\ValidateOAuth::class, ];
Group middleware
If you want to allow OAuth on a specific middleware group or route, add the ValidateOAuth
middleware to your group:
protected $middlewareGroups = [ 'web' => [ // ... ], 'api' => [ // ... \MijnKantoor\OauthMiddleware\ValidateOAuth::class, ], ];
Configuration
The defaults are set in config/oauth-middleware.php
. Copy this file to your own config directory to modify the values. You can publish the config using this command:
$ php artisan vendor:publish --provider="MijnKantoor\OAuthMiddleware\ServiceProvider"