I installed the Laravel Passport package for Laravel 5.3 as described in the official documentation ( https://laravel.com/docs/5.3/passport#introduction ).
I want the API to be used by the mobile application, so I'm trying to implement password tokens . I created a client to provide a password and a token request process ...
$response = $http->post('http://my-app.com/oauth/token', [ 'form_params' => [ 'grant_type' => 'password', 'client_id' => 'client-id', 'client_secret' => 'client-secret', 'username' => 'my@email.com', 'password' => 'my-password', 'scope' => '', ], ]);
... just works as expected, returning an access token and a refresh-token for one of my users.
But now I want to define some scopes to restrict user access ... After re-documentation, I defined them in the AuthServiceProvider.php download method, for example:
Passport::tokensCan([ 'admin' => 'Perform every action', 'user' => 'Perform only normal user actions', ]);
In this case, if the “malicious” normal user requested a token (using the above POST call) by specifying 'scope' => 'admin' , he or she will receive the “admin” token ... and this is not what I want.
Thus, I would like to know how the workflow in this situation effectively restricts access to ordinary users and where I need to implement the validation logic . .
Thanks in advance.
andcl
source share