dusterio / lumen-passport

Making Laravel Passport work with Lumen
MIT License
654 stars 141 forks source link

Add middleware to routes of PassportServiceProvider #31

Closed yokovaski closed 7 years ago

yokovaski commented 7 years ago

Hi,

I want to add middleware to the routes defined in PassportServiceProvider. I have tried to override the routes in /routes/web.php: $app->post('/oauth/token', [ 'middleware' => 'reject', 'uses' => '\Dusterio\LumenPassport\Http\Controllers\AccessTokenController@issueToken', ]); This is throwing a 500 at me without a error message. I am currently clueless about what is going wrong.

I do not know if it is at all possible to add middleware to package defined routes and can't find any good solutions to my problem. Who is able to help me? :)

desyncr commented 7 years ago

Take a look at here and here where a route prefixing feature was implemented. I believe you can add your middleware configuration there.

Edit: Or just take a look at this section in the README.md.

yokovaski commented 7 years ago

Ah, I overlooked this merge because the latest release is from February. Thanks for the answer! I added "dusterio/lumen-passport": "dev-master", to my composer.json and Dusterio\LumenPassport\LumenPassport::routes($app, [ 'prefix' => 'api/v1/protected', 'middleware' => 'reject', ]); at the end of my bootstrap/app.php. It works perfectly now!

desyncr commented 7 years ago

Should be a new release soon? @dusterio