mardi 6 décembre 2016

Laravel - Api - How to secure using a key

I am creating an API and use a route group for this:

Route::group(['prefix' => '/api/v1/', 'middleware' => 'App\Http\Middleware\CheckForAuthenticated'] function() {

   Route::group(['prefix'] => '/address'], function() {
       Route::get('/get/', function() {

       }); 

   }); 

}); 

Now what I want to do is to secure the API through a key when I access the url through a GET/POST.

I have created a Middleware but I'm confused how to use the guard so let's say I have the following:

\Auth::guard('api');

if(\Auth::check()) {
   // This user is signed in 
}

However, where do I store/pass the token through the route in order to check to see if the user is authenticated or not?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire