I make an application on Laravel and the following task arose. There is a route that should be accessible only to authenticated users. I know about standard Laravela authentication / authorization tools, but here you need to organize everything a little differently. There is a third-party server on which users are stored (login and password). So, when you go through the route, the login page will open, on which the user enters a username and password. After the submission, these login and password will be sent to that third-party server, which in return will return true (if such login and password exist), or false. If true, then the transition to this route. Moreover, if the user is authenticated 1 time, then you need to do so that the token is generated for him and stored for some time, so that every time you go through the route you do not have to authenticate. Tell me, please, in which direction to dig. Maybe there are some examples of how this can be organized and indeed how to build this entire chain correctly. I would be grateful for any help!
1 answer
If I understand correctly, then you need the following:
1) Create a users table in which you will store the token and associate the user with the remote server with your local visitor.
2) After the server has said that everything is OK, you create a user with a token locally or if he already exists in the database, simply take his id from the local database by token.
3) Perform authorization by id :
Auth::loginUsingId('Ваш локальный id', true); // Второй параметр отвечает за remember me |