Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to disable routes in Laravel Passport?

I'm using Passport password grant, I don't need any other functionality, so I need to disable routes that are not related to password grant.

Is there a way to do that?

like image 249
Zaid Direya Avatar asked Mar 05 '17 09:03

Zaid Direya


People also ask

Is laravel Passport stateless?

Laravel Passport is an OAuth 2.0 server implementation for stateless authentication.

Does laravel Passport use JWT?

Passport uses JWT authentication as standard but also implements full OAuth 2.0 authorization.

How does laravel Passport authentication work?

Laravel Passport is an easy way to set up an authentication system for your API. As a Laravel package, it uses an OAuth2 server to perform authentication, creating tokens for user applications that request to interface with the API it protects, and only granting them access if their tokens are validated.

What is scope in laravel Passport?

Laravel passport token scope provides you beautiful services. Scopes allow your API clients to request a specific set of permissions when requesting authorization to access an account. For example, if you are building an e-commerce application, not all API consumers will need the ability to place orders.


1 Answers

I was wondering this too and found that Passport::routes() takes an optional callback. If a callback is not set, then all routes get registered.

To set individual routes for each auth type modify the following code for your use in your AuthServiceProvider:

Passport::routes(function ($router) {
    $router->forAuthorization();
    $router->forAccessTokens();
    $router->forTransientTokens();
    $router->forClients();
    $router->forPersonalAccessTokens();
});
like image 181
wsamoht Avatar answered Oct 21 '22 05:10

wsamoht