Reputation: 12718
I am building a RESTful Laravel 5.1 API. I only want to allow my frontend Angular app to access certain routes, but currently all the routes are simply exposed.
I was going to use auth middleware
to check that my frontend app is authorized to access a route:
$router->get('/sensitiveData', ['middleware' => 'auth',
'Resources\Questions@getSensitiveData'
]);
But this is good for checking a specific user.
How can I protect my routes such that only specified client apps can access routes? Should I be registering a ClientID somewhere? How can I specify this?
Upvotes: 0
Views: 1404
Reputation: 6279
Check this package
Usage
In your controller extend the ApiGuardController
this way your api is private , you can access it only when using an Authorization token
You can find more informations and Options in the docs (like how to create the private api-key or Turning off authentication for a specific method ..etc)
there is no need to set a middleware for it.
Upvotes: 1