A
A
Alex2017-05-13 17:54:31
API
Alex, 2017-05-13 17:54:31

Laravel 5.4 jwt RESTful API and basic site?

Good afternoon.
Asked to help with authorization for the API. Perhaps in the future I will make API + Swagger (ApiDoc).
At the moment there is a simple site with authorization through a form. There is no division into front and back.
Those. made according to the basic lessons from the docks.
I want to implement RESTful API + JWT Auth, but I don't have enough knowledge how to distribute two authorizations.
All tutorials boil down to one or the other authorization in the Auth\LoginController.
How to distribute all this?
Mb. Who has an example or an article lying around?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergeyj, 2017-05-13
@sensus

Create an API/... directory
to place controllers, etc., everything you need to implement RESTful.
Create an AuthController there, map the routing to it in routers/api.php

D
D3lphi, 2017-05-13
@D3lphi

For more control over authorization and users in general, I recommend using the Sentinel package . Full integration with Laravel. Knows everything that is possible, including recovering passwords, activating users (For example, by email). There is also API authorization and temporary "freezing" of access to the account.
Actually, with the help of it, you can abandon the standard Auth-controllers of the framework.

T
tester_toster, 2017-09-01
@tester_toster

Try laravel Passport. I'm making a laravel + vue + mobile app application on it - the flight is normal. Authorization in Auth automatically occurs when sending a token via api routes. We get the token, pass it to the header. If the site also works with api, you don't need to transfer anything. When authorizing on the site, the user writes an encrypted token in the cookie and checks it automatically.
Pluses - native authorization, a minimum of edits.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question