Answer the question
In order to leave comments, you need to log in
How to make authorization/authentication for API by token in Laravel?
Laravel 5.3
We need to make an API for an application in which regular authorization is implemented by standard Laravel tools, everything is standard:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
'users' => [
'driver' => 'database',
'table' => 'users',
],
Route::group(['middleware' => ['auth:api']], function() {
// роуты
});
Answer the question
In order to leave comments, you need to log in
Slightly off topic, but maybe you should look at laravel/passport?
And why JWT? Headers:
1. jwt: "Authorization: Bearer lotsOfSymbolsHere"
2. cookies: "Set-Cookie: laravel_session=123; token=456"
Now explain why you bother with absolutely useless technology? Which, moreover, will require so much manipulation, and even worse than cookies?
Read on the Internet why you should NOT use JWT. Yes, you may have already written everything for jwt, but at least it will be for the future)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question