Laravel API Authentication using JWT Tokens

preview_player
Показать описание

Laravel login and generate JWT Token with Laravel Sanctum using HttpOnly Cookies. We will Login using JWT( JSON Web Token ) which is the standard method for SPA Authentications. We will not use the traditional "Bearer method" but instead we will login using HttpOnly cookies which is a more secure authentication.

This video can be combined with other videos:

00:00 Intro
00:35 Laravel Installation
02:09 Routes
05:20 Database
08:33 Register
13:27 Login
24:48 Authenticated User
32:25 Logout

#laravel #php
Рекомендации по теме
Комментарии
Автор

Quick tip here:
The pipe ("|") character, when encoded for its use in URLs, becomes "%7C". This is the reason the token didn't work @ about 29:00 in the vídeo, because he was replacing only the % instead of "%7C".
Hope it helps!

yago.estevez
Автор

Bro you are actually an ABSOLUTE LEGEND!!
I find this tutorial very helpful from the way you explained <3

UpdaterMC
Автор

Subscribed!!!! Man, you're a legend!

tahmidferdous
Автор

mate, this is not jwt it's actually sanctum token
and you don't need to use a middleware to process the token ... you can do it more professional way by adding the authorization header to your request in your http library like axios

husseinh
Автор

thanks so so so much !! you're the man !!!! subscribing right now !!!

martinn
Автор

Very good video, man, it really helped me a lot, waiting for more vids! :D

kerintambasco
Автор

You really have my big thanks for showing me the way where you don't have to use postman to implement the Authorization: Bearer
I am using this on passport and using your way. it saved me 5-6 days of sleepless nights. Time to subscribe and thanks again

danmarlcadiz
Автор

Thank you very much for this great tutorial, may god bless you and your family

rifatalom
Автор

Hi! great video sir! Anyway just want to add, it would be better to delete the token in the table also because user can still access the restricted method after logout just by adding the Authorization manually on the header. ^___^

junreydotarot
Автор

at logout, you might want to add to delete the token in database also. otherwise it will stackup

wailantirajoh
Автор

Really a Good and Understandable video. Your explanation is good. Need more videos like this. Thanks! This is very helpful.

sivaramakrishnans
Автор

Excelente mi amigo, me has ayudado demasiado, muy buen video

dobges
Автор

Love from bottom to top of my heart bro 💜

fullstackabhi
Автор

i can't find the jwt tokens that you mentioned in the title. But you gave me an idea so i forgive you. thankyou

cion
Автор

thankyou verry much! that is a lot helpful for me.

dthieu
Автор

laravel sanctum check user token from mysql database in every request ?
this is very bad for big application.

mehrshaddarzi
Автор

This video is great! thanks!!!

Do you intend recording something about Refreshing the token?

joshbarros
Автор

Isn't the restful api supposed to be stateless or am I wrong? If I'm going to store the token in the database or on disk why not do it with the session, which was invented like 1000 years ago? Why are we reinventing the wheel? I think that's not how JWT is used. That's how Sanctum is designed, I'm not criticizing the video.

biliyonnet
Автор

Why should one use cookie-based authentication when he's building APIs? Don't the mobile developers have to do extra work to manage those cookies?

sirajul-anik
Автор

Hi! Is it possible to develop a working login form in front end if there is no 'user' implemented in the backend?

jonaldbalingit