I was fully prepared for sarcasm and snark. Instead I got the most useful short intro on web-authentication there is.
@snowballeffect7812
Ай бұрын
We were taught how to roll our own auth at my boot camp just so we could have a deeper understanding on how it works and what can go wrong. Super valuable skill to have! to clarify, we did this from scratch, including hashing and salting passwords and using session tokens.
@vaishnavejp9247
Ай бұрын
that all of ben's videos
@petleveler8366
Ай бұрын
@@snowballeffect7812 that is the basics everyone should know that
@snowballeffect7812
Ай бұрын
@@petleveler8366 you'd be surprised, apparently. maybe they do know that, but it seemed rare for anyone to implement working auth from scratch.
@snowballeffect7812
Ай бұрын
@@petleveler8366 not sure why my response was deleted lol. but I'll try again and say that I don't think most devs have implemented auth from scratch on their own.
@Ibbysz
Ай бұрын
Insane how you explained auth better than anyone i've ever seen including big auth providers.
@goober9105
Ай бұрын
No way hes back
@2breezy866
Ай бұрын
We are so back
@yaaaayeet745
Ай бұрын
hostinger bro :)
@zweitekonto9654
Ай бұрын
guess what, he is
@emptytank604
Ай бұрын
This was quite possibly the best and most concise explanation of how to implement auth I have seen. Thank you!
@vinceerkadoo45
Ай бұрын
Literally popped on my suggestion seconds before i was going to search for this!
@ghdshds1899
Ай бұрын
damn google really has your personal data dead to rights
@AndrewScofield
Ай бұрын
Great high level tutorial for a very confusing topic! There are so many tutorials out there that make it seem like you have to start out at enterprise level complication, when in reality a setup like this is going to work great for most people.
@zb2747
Ай бұрын
Very concise explanation of JWT vs Sessions. Interesting to see how your take on the two has developed over the years. I find your videos super helpful when it comes to doing auth without 3rd party Lastly, it’s great seeing you Ben. Much peace and success brother
@MaxPicAxe
Ай бұрын
I can't believe you just explained so much about auth I had no idea about in this short video, so well. Thank you.
@mikealejandro3938
Ай бұрын
Ben, you're mi inspiration for becoming a web dev, it's been like 3 years since I started this journey seriously (at 17), now I have a decent job, thanks for existing brother, love your vids, we miss you homie !
@maneeshparihar
Ай бұрын
Thanks a ton ... nobody explained it better and all in one video.. I will need to dig a bit more in CSRF and XSS bits.. but still crisp and yet adequately detailed. Kudos
@schism15
Ай бұрын
Perfect timing for this. I had just decided to try rolling my own auth on my latest side project since its not critical, will be low traffic and I'm tired of auth feeling like such a black box.
@PedroPedruzzi
Ай бұрын
Very nice. I've used this design with two JWT, but never seen it explained anywhere. Cool!
@Andres-Estrella
Ай бұрын
Thanks! Auth is one of those things you have to implement 2 or 3 times to fully understand.
@kevinroleke2769
Ай бұрын
You don’t need to buy a service for email. It’s a bit annoying but you can setup postfix on a VPS and point MX, SPF, DMARC records.
@user-zo2ky4mz7d
Ай бұрын
I was just researching this for a side project. Thanks Ben for reading my mind.
@w.e.b_b
Ай бұрын
I am stoked for this. You’re such an incredible engineer and I owe much of my success as a programmer to your teachings! Thank you my friend
@monsieurLDN
28 күн бұрын
What did you learn from him? I see mostly reaction videos
@w.e.b_b
28 күн бұрын
@@monsieurLDN you’ll have to go back to his content from 2018-2019ish when he was making more long form content
@amagicpotato5511
Ай бұрын
Had to figure all this out myself a year ago. This video will serve well for anyone else that finds themselves in the same position. Thanks Benji!
@ygvanz
Ай бұрын
From all of the authentication videos I have seen, you explained everything very well.
@rutvikpatel7640
Ай бұрын
You uploaded this video right when I needed it! You answered so many questions of mine in just 15 mins than I found answers online for last 2 days. Thank you so much. And please make a next video on how you setup username and password auth.
@buzz1ebee
Ай бұрын
He's back! Great overview. I've rolled my own auth quite a few times and this is a great guide. Recently I've been using a self hosted zitadel instance for the user management and I have a reusable nestjs module for handling all the zitadel oauth stuff and session management etc. Super easy to add additional auth providers or implement 2fa via settings on zitadel without changing anything at all on my backend which is just basic session cookies storing access and refresh tokens for zitadel.
@rohithk6466
Ай бұрын
Hi Ben this video was pretty useful, kindly keep coming back with these
@devxsadik
Ай бұрын
i missed this type of content bro pls keep doin it
@alexjmohr
Ай бұрын
Personally I still don't buy into using JWTs for auth in the front-end. I think they're more applicable to server to server contexts. The argument that you don't have to make a database call to validate the user's session isn't that strong, since in most requests you're going to hit the database anyway in order to do anything useful. The extra database call isn't that big of a deal. Refresh tokens add unneeded complexity for most projects. It's a LOT simpler to just store a cryptographically unique session ID (like a UUIDv4) in a cookie and use that to look up the session in the DB/Redis. Not hating on the video, I just think people jump to JWTs, refresh tokens, etc because they're fancy and trendy, but they're often misused.
@0xA
Ай бұрын
You are absolutely correct. JWTs irrevocability make them a great target in security assessments. If there is restricted data being hosted by the application (PII), I would never allow JWTs to be used for authentication from a security architecture perspective. Learn it, use it on non-sensitive apps, but don't rely on them to be a truly secure means of authentication. Not to mention the common misconfigurations that often allow them to be altered or bypassed altogether.
@adithyagowda4642
Ай бұрын
It would be easier to use sessions to authorize a user if you already use sessions for other things, like tracking user behaviour, storing useful information like user's wishlist (in e-commerce websites) etc.,. You just need to add one more parameter of userId in the database and you have a working authorization mechanism. But creating a whole new database server (assuming sessions are mostly stored in a separate Redis DB), just for authorizing would seem to be a overkill as compared to using something like JWTs which are much easire to integrate with no added work of managing another database. But again, it largely depends on the use-case of your application.
@adamfarmer7665
8 күн бұрын
If you are not using jwts on high concurrent users you are going to get pegged by lots of db requests on each request because you needed database for validation, and your application will suck. Of course If you are developing an in-house app that will be used by less than 10000 users, you can get by using beefier servers, since you are not paying for the servers anyways.
@SeanCassiere
Ай бұрын
A wild Ben has appeared!
@SalimOfShadow
Ай бұрын
I always really really liked how you explained everything!!! Really enjoyed this quick rundown
@Yaxqb
Ай бұрын
here I have walked literal years wondering why we have refresh tokens. Your explanation is so clear
@KevinNaughtonJr
Ай бұрын
great vid super informative benjamin
@pt_trainer9244
Ай бұрын
Summarized months of learning all of this in a short video, good stuff
@dearlordylord
Ай бұрын
Brilliant, Ben! I was always bamboozled by this access/refresh token stuff, no one explains it clearly. After this video it finally makes sense to me.
@ayushgupta0010
Ай бұрын
My go-to method is to use JWT with a refresh token and token version, make the access token short-lived, like 15 min, and store it in the memory on the frontend.
@kristiannn
Сағат бұрын
you forgot to mention that when using for RS256 algorithm it is the private key used to create a JWT signature, and it's the public key that is used to veirfy the signature
@alessiotucci0
Ай бұрын
Great intro to authentication, Thanks a lot Ben
@DanTheMan-rr3yg
Ай бұрын
great video, you should do a video on the username + password, but do the whole shebang too! Reset password, forgot username, two factor authentication, magic link too, etc.
@CardinalHijack
Ай бұрын
step by step tutorial on doing this, like the old style videos this channel did, would be super cool
@regularyt-pz4ki
Ай бұрын
bro just back like he never left
@gbbelloponce
Ай бұрын
Amazing video man!!! It's literally what I've been looking for lately. I would personally love a video talking about the username/password login approach. Greetings!
@erickshaffer6615
Ай бұрын
PLEASE KEEP THIS GOING, VERY EDUCATIONAL
@_solstice
Ай бұрын
very good video, everything was super clear, maybe this is a bit niche or too specific to be useful but a video about how you'd go about rolling your own oauth provider would be very interesting imo
@V0LAT1LE_
Ай бұрын
The 2 doors in the back are hitting some weird parts in my brain. Its like they are saying red pill or blue pill
@Sindoku
Ай бұрын
Oooohhh crap, our boy Ben Awad is finally back. Welcome back baby, we missed you.
@hoangtrinh3448
Ай бұрын
As a senior software engineer, I found this video is useful
@gabrielbiacchi6169
Ай бұрын
Hell yeah you're back homie
@toTheMuh
7 күн бұрын
5:30 - in a microservice environment you are most likely going to have a token AND a session cache, especially if you are working on a complex business SaaS (software like Salesforce, AWS, SAP, etc.) with RBAC/ACL/etc. The API Gateway will validate the token and then look up the users permissions in the cache. You could store the permissions within the token, yes. BUT that is very complicated. Imagine you have a user and that user has a role with a bunch of permissions. What if the permissions of the role change or the role of the user changes while the user is logged in?
@i-am-artur
Ай бұрын
Thanks for the video a lot! I am currently working on a project with JWT, and was about to read on xss
@yasharma2301
Ай бұрын
One benefit of cookie I think is SSR? JWTs stored in local storage cant be read on SSR since you won't be able to send it in the first document call, while if you use cookies you can fetch user data on the frontend server. Correct me if I am wrong
@DallasLaComb
Ай бұрын
😂😂😂Ben has been trying to perfect authentication for the last 4 years. I was watching his videos from 4 years ago and then seen he made a new post.
@amzabdrahim3350
Ай бұрын
amazing video, please do more. this popped on my suggestions, clicked on it immediately. had to do jwt for a client, i didn't know how to set up the refresh token.
@danielsharp2402
Ай бұрын
For me refresh token is usually not a JWT since accessing the database is happening there anyway. And that gives you the best of both worlds with revoking as well. Usually stored in redis with EX. Also for early MVP services I like to do a Frankenstein approach of letting an access token close to expiry refresh itself (works quite well, but obviously isn't as good as refresh tokens).
@jonacempelule9876
Ай бұрын
For the logic to invalidate the JWTs for ‘Signing out all devices’ why not have a Redis Cache/DB to keep track of blacklisted tokens, and set the expiration of that cached token to 15mins(or however your access token take long to expire). Now in your middleware, to validate the JWT you first check if the access token is blacklisted. Now when a user signs out of all devices, just have the other tokens in the blacklist cache. Your thought?
@marcgentner1322
Ай бұрын
Love it. Practical and simple. I have build the db setup in php but I like your methods on the jwt way
@eleah2665
Ай бұрын
He back! But the room, mic and cuts make it look like he's been kidnapped.
@KazSadeghi
Ай бұрын
This is insane, best auth video / resource I've seen
@lynxcat4life
Ай бұрын
the ThioJoe effect has hit Ben
@timkunze603
Ай бұрын
Fun fact: saying "JWT" takes longer than just saying "JSON Web Token"
@user-fu8pt3hz9l
Ай бұрын
Fun Fact: everyone pronounced these two words now
@krishnabirla16
Ай бұрын
Best web-dev video I saw this week.
@Zayetzo
27 күн бұрын
This was a very good explanation thank you!
@alexleung842
Ай бұрын
Wrong answer. You would use passkeys. Those should become the standard
@blancartembl
Ай бұрын
One way to do it without relying on a sass product its to use Lucia Auth... full fine grained control of the flow without magic like others
@Alphfirm
Ай бұрын
Sweet, thanks! For my situation, a tutorial on expo react native app with using secure storage as you mentioned and session storage would be great!
@TechTube-22
Ай бұрын
Auth with cookies makes you're API only callable via browser, so if you want to use them in a mobile app, you have to change maaaany things
@WillDelish
Ай бұрын
Yep, oath + jwt + cookies be my fav flow right now. I have to use this at work.
@avi12
Ай бұрын
Dev: How do I deal with auth? Ben: Yes
@RyanLynch1
Ай бұрын
welcome back king
@comproprasad6438
Ай бұрын
you can sign the session token as well and store in a cookie
@eedoan
Ай бұрын
The true token is the friends we made along the way
@Niksorus
Ай бұрын
Fantastic, I'm down for a longer video 😄
@user-oc4wj9ey4v
Ай бұрын
This section looks great. And going deep into passwords, how to get credentials, why is not ok to send the token in cookies and get it in headers... Can be good. And in the future, I see you doing a video like this but " Exploring Coolify", host your own "vercel". It would be awesome to see that. Thank you for the information!
@jakeave
Ай бұрын
Good job! I like the explanation of the log out of all devices. Next let's do authorization 😂
@ryank9719
Ай бұрын
A simpler way to invalidate tokens would be to create a table/collection for all your tokens. Then, when a user logouts, you search the table/collection for all tokens associated with that user and delete them.
@Sylvoo01
Ай бұрын
Congrats you have just reinvented regular sessions
@dumbfailurekms
Ай бұрын
Is lucia analogous to passport.js or is it a higher level of abstraction
@petaflop3606
Ай бұрын
the first auth I self-rolled was an OIDC IdP server to connect a third party to our existing session-based auth (not SaaS it was just for one particular partner). It was fiddly at first but once you get it, like most things, it doesn't feel so bad and I'd be much more confident doing it again if I had to
@armaan-ci3nv
Ай бұрын
can you make a more in depth version really focusing on best security practices that owasp has laid out?
@SoreBrain
Ай бұрын
I would have paid for this video more than I paid my auth provider 3 years ago.
@richardwang3541
Ай бұрын
Hey Ben this was super helpful! I was wondering what's your strategy for refreshing tokens? Do you have a /refresh endpoint to handle this? But then how do you know when to call it? For example, say the expiry on your access token was 15 minutes. How does the client know "oh my 15 minutes is up, better go call the /refresh endpoint"? Do you use a timeout or do you poll in the background?
@nigelyong9060
24 күн бұрын
⏱ CHAPTERS ⏱(By TimeSkip AI) 00:00:00 - Introduction to Authentication Setup 00:01:30 - Setting Up Your VPS with Hostinger 00:02:51 - User Account Verification and Security 00:04:30 - Session Storage vs JWTs Explained 00:05:36 - Implementing JWTs for Authentication 00:06:52 - Managing User Sessions and Tokens 00:09:40 - Best Practices for Token Storage 00:11:35 - Front-End User Authentication Checks 00:12:41 - Conclusion and Resources
@akashdeb9823
Ай бұрын
babe wake up ben's new video just dropped
@alimahdi1012
Ай бұрын
Throwback to a very similar video you made 4 years ago.
@joshuasingh854
Ай бұрын
Bro thanks so much for this!! This was very useful and cleared a bunch of stuff for me!! Yes please do the next video if how you set up username/email and password
@trimpta
Ай бұрын
Where was this video when i had to go and do all this research myself
@houssemchr1539
Ай бұрын
Thank you for explication Ben, but how about using OAuth 2.0 ? I think it's the most secure one
@ashrafuzzamankhalid3465
Ай бұрын
Hey Ben, will you please make a video about career choices and their difficulties and how to make sure to learn it...
@vrinfotechies
Ай бұрын
Yoo thanks for the explanation of creating a fully working auth model for my website thanks
@radunicolaeeduard9194
Ай бұрын
I always use keycloak !
@parlor3115
26 күн бұрын
Hope you can also cover how to do Auth with SSR apps like ones created with NextJS. Refresh / Access no longer works or, at least, not in the same way as with SPA's. I think both tokens will be stored in cookies except for mutation requests.
@rod6722
14 күн бұрын
Look into Lucia Auth. It's very straightforward and it has guides for NextJS and a few other frameworks. NextAuth should also be good, but I haven't tried it.
@tanglesites
Ай бұрын
Ben where you been? Good to see you back.
@jeremyshorter2641
Ай бұрын
Please do an email password auth video, I need it. Most useful video you've dropped in a few years tysm
@codewgem
Ай бұрын
You actually have YT. I just saw you on tiktok 😂 now I'm gonna be your subscriber
@zeroliuxiyuan
Ай бұрын
The good old Ben is back
@rjwhite4424
Ай бұрын
Please please do a walkthrough with express and passport with your access token and refresh token method using basic login with email and password
@parkourbee
Ай бұрын
I usually handroll a Magic Link, no passwords to worry about.
@schoolofbillt2656
Ай бұрын
This is so helpful. Thank you for this video!
@FatahChan
Ай бұрын
Ben Awad making a video? what a surprise
@saramshshrestha7641
23 күн бұрын
Welcome Back
@JOJO_THE_PROGRAMMER
Ай бұрын
he is back with tutorials!!!
@antivist5183
16 күн бұрын
Yo how do you set up your oauth? what packages/libraries do you use/recommend? i try to avoid using as many packages as possible cause im stubborn so im curious what the pros/cons are or if they're literally needed.
@N7Tonik
Ай бұрын
I can recommend firebase auth its dirt cheap, very fast (although its session based auth), and simple to setup (no need to manage auth via ur database or redis urself)
@milseq
Ай бұрын
What are the chances that I'm implementing this exact feature in the Google+JWT+Cookie fashion at this very moment for my first personal startup project lol Thanks, this made some things clearer
@PhilippBlum
Ай бұрын
You also could have used Supabase and get this whole Auth with multiple service login out of the box. Yes, self-hosted.
@wchorski
Ай бұрын
I see the benefit and control of rolling your own auth, but the convince of Next-Auth / Auth.js has kept me hooked with being able to do both email/password and OAuth options together. wondering if you have any advice on a hybrid method?
Пікірлер: 331