Тёмный
No video :(

Storing Auth Tokens in LocalStorage 

cdruc
Подписаться 10 тыс.
Просмотров 39 тыс.
50% 1

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 207   
@joeplayer8980
@joeplayer8980 6 месяцев назад
This video shattered my trust in circle-providing npm packages.
@cdruc
@cdruc 6 месяцев назад
🤣🤣🤣🤣
@ruslan_yefimov
@ruslan_yefimov 6 месяцев назад
We can still use ovals though - just be smarter!
@michaelbitzer7295
@michaelbitzer7295 6 месяцев назад
Just use squares and cut of the edges, problem solved.
@benjidaniel5595
@benjidaniel5595 5 месяцев назад
I mean it must be good if it’s had 1 billy trilly billy downloads
@Cloneee
@Cloneee 6 месяцев назад
It's not about cookies or localStorage, it's about how you handle the validation and protecting methods IN YOUR BACKEND SERVER. When using cookies, there's still XSS, man-in-middle, you can't stop them, just slow them down. The more appropriate way to protect your user is stop using stupid packages from npm and try to use an access token with a refresh token, limit the number of refresh tokens per user, save the user's IP, browser information, and try to use the RTR (refresh token rotation) method.
@moosethemucha
@moosethemucha 6 месяцев назад
Thank you
@gadgetboyplaysmc
@gadgetboyplaysmc 6 месяцев назад
For sessions, you wouldn't really need to take care of refresh and access token, right? A refresh token in itself is like a session already.
@mikooovsky
@mikooovsky 5 месяцев назад
this refresh token hype is so funny xd
@Dontcaredidntask-q9m
@Dontcaredidntask-q9m 6 месяцев назад
Saying that a httponly cookie is safe and cant be accessed is extremely misleading and dangerous. They can be accessed by XSS and XHR attacks. Setting a cookie to httponly is one part of your multi-layer defense, on its own its not enough, but combined with other layers it helps make your service more secure
@dealloc
@dealloc 6 месяцев назад
Yes but it's easier to mitigate against XSS attacks as you can restrict the cookie through SameSite policy, unlike any JavaScript-accessible storage medium.
@cdruc
@cdruc 6 месяцев назад
I agree; more layers are better, of course. I'm not sure about XSS and XHR attacks being able to access httpOnly cookies, though. I thought the httpOnly attribute was specifically designed to offer protection against XSS/XHR attacks. Can you expand or point to an article/page/docs demonstrating this?
@vagkalosynakis
@vagkalosynakis 6 месяцев назад
The httpOnly attribute of a cookie is exactly there to prevent XSS attacks, so you can't access it using that one. I haven't seen XHR attacks and looking online right now, I don't seem to find a way to access an httpOnly cookie as well.
@mibi2509
@mibi2509 6 месяцев назад
​@@cdruc I never heard of a way to read httpOnly from JS that was not a bug in its implementation. Idk what they are on about.
@dealloc
@dealloc 6 месяцев назад
@@cdruc The problem is not with XSS specifically (accessing the information directly through JS) but that a script can make a fetch from the website's origin and include the credentials (i.e. HttpOnly cookies). If SameSite is not set to either Lax or Strict, it will include those cookies in the XHR request. By default modern browsers will set the SameSite to Lax if it is not explicitly set to None by the website issuing the cookie. So unless you go out of your way to disable it, your users will be safe (also safe against CSRF attacks).
@JakobTheCoder
@JakobTheCoder 5 месяцев назад
Thank you for this video. I saw these videos (same topic) so often and never understood why it is so important, but your example with the package is so good.
@user-td7et3kf9g
@user-td7et3kf9g 6 месяцев назад
There is another interesting thing that discord does, they store the token in localStorage but: 1. When they load the page the key is deleted from localStorage and loaded in memory 2. When a user leaves the website or closes chrome or the discord app they store it again in localStorage so they can get it on the next load. This mostly works for web applications that don't require opening in new tabs tho, because opening new tabs of your website means it doesn't know the current auth token as it is not in local storage anymore until you close the tab that currently has access to it.
@gnorts_mr_alien
@gnorts_mr_alien 6 месяцев назад
yeah I don't agree. if your web app is compromised by a rogue package, it is game over. even if you have a http only cookie, yes, they might not be able to steal the token exactly, but they can still make requests to your backend through the client browser. the cookie will be sent automatically, and they will do what they want to do regardless. they just won't have the token at hand, they'll be able to use it. this is common advice but security theater. with cookies you will have to start to worry about CSRF etc as well. so no method is without its drawbacks. you need to have a threat model. if your threat model is "infected scripts in my site" then neither cookies, nor local storage will save you.
@DaSchTour
@DaSchTour 5 месяцев назад
An infected script could even load additional javascript that exploits the requests on your page. Do requests to your server and then send the data to another server. If you have untrusted 3rd party scripts on your page nothing will save you. If you do not sanitize user input also anything can happen.
@ouya_expert
@ouya_expert 6 месяцев назад
I remember being onboarded on a government project that stored JWTs in localstorage which required logging in using your national ID. It was a hell of a shock it got through code reviews and the eyes of every dev who went through it.
@MichaelScharf
@MichaelScharf 6 месяцев назад
Well, unless you disallow access to any other domain with using Content Security Policy (CSP): For example `Content-Security-Policy: default-src 'self'; connect-src 'self'` there is no way to send data to another domain
@_f0x604
@_f0x604 6 месяцев назад
Can CORS prevent sending data to another domain name as well?
@saiv46
@saiv46 6 месяцев назад
​​@@_f0x604Nope. CORS is about _downloading_ data.
@trapfethen
@trapfethen 6 месяцев назад
CSP does not govern browser extensions, nor does it protect from relay attacks. Though, the latter requires you to have a relay vulnerability in your server implementation.
@tigerofdoom
@tigerofdoom 6 месяцев назад
@@_f0x604 No, CORS is aimed at stoping Cross-site Request Forgery, tricking the browser into sending the cookies to perform actions on Website B while the user browses Website A. CSP prevents exactly what's described in the video, exfiltrating data from a site with malicious scripts that are injected into the site (XSS).
@MichaelScharf
@MichaelScharf 6 месяцев назад
@@trapfethen yes, but browser extensions can inject any code and just read you password as you type. When you have a node app, you also have to make sure that the server cannot send data to a malicious sie.
@rusty_knife
@rusty_knife 6 месяцев назад
While not entirely wrong, this video is definitely misleading... By this logic, storing tokens anywhere on the client device is insecure. Now there are definitely limits on both ends, but they really shouldn't be defined by the libraries which are under your control. If this is your concern then I have bad news for you: it's probably not much harder to just steal the credentials while logging in, which is obviously even worse. And that's just the tip of the iceberg probably... The real solution is to vet your libraries properly, which is hard yes, but using a compromised library is dangerous no matter where you store your tokens... Also if you say you should use tokens for mobile apps, then what about compromised libraries in the mobile app? And what about the server, how are you gonna hide things from a malicious library there? All that doesn't mean you shouldn't use cookies for authentication if you can though. There are other benefits to that approach - it is basically what they were made for afterall. It's just that they don't really solve the problem described here...
@bartoszkrawczyk4976
@bartoszkrawczyk4976 6 месяцев назад
I see so many articles, like "authentication in React" that says to store it in localStorage. Thanks for making this video, I hope it will reach as many people as possible.
@codokit
@codokit 6 месяцев назад
We need ask react-devs about httpOnly cookies on interviews.
@ieatthighs
@ieatthighs 6 месяцев назад
this video is very misleading
@whatskookin6429
@whatskookin6429 6 месяцев назад
What you should always do, is read your framework of choice docs. Usually they tell you use local storage is not a good idea.
@bartoszkrawczyk4976
@bartoszkrawczyk4976 6 месяцев назад
@@whatskookin6429 Absolutely! When it comes to security, never trust some random tutorials or articles.
@daleryanaldover6545
@daleryanaldover6545 6 месяцев назад
​@@ieatthighswhy is it misleading, it provides a valid POC attack tho.
@MrRiseful
@MrRiseful 6 месяцев назад
Well wow, malware will simply steal password from login form then
@philheathslegalteam
@philheathslegalteam 6 месяцев назад
Exactly. Or just interact with the page on your behalf while serving an absolutely positioned clone of the DOM in front.
@unfilledflag
@unfilledflag 6 месяцев назад
Gonna be hard to do so when using something like OAuth
@MrRiseful
@MrRiseful 6 месяцев назад
@@unfilledflag whatever, the spy script will be stealing all data from owner computer, yet won't be able to login from somewhere else
@Sebastian-rn6pb
@Sebastian-rn6pb 5 месяцев назад
I knew this was a bad idea from hearing it everywhere, but I never understood how the attacks would work. Thank you so much.
@vjzb3
@vjzb3 6 месяцев назад
Super informative and beautifully demonstrated. Thank you for taking the time to make and share with us!
@NicJon
@NicJon 6 месяцев назад
Well where should i then store it? Cookies can get stolen the same way??
@davidwang7489
@davidwang7489 6 месяцев назад
Not HttpOnly cookies. But any malicious JS running on your site can still do a lot of damage. All of these are mitigations.
@atakansenturk563
@atakansenturk563 5 месяцев назад
@@davidwang7489 So what needs to be done?
@omnilothar
@omnilothar 6 месяцев назад
in devtool you can use breakpoint to tick unload, so when closing tab/window, it will prevent that , so you can check the network after
@xorlop
@xorlop 6 месяцев назад
I feel like the actual issues here were installing random packages that are not vetted and injection.
@nugenki
@nugenki 6 месяцев назад
Well done video! The flow on information was really easy for me to follow, with examples and proofs. I will be making this change, and letting others know too, thanks.
@coldicekiller1352
@coldicekiller1352 6 месяцев назад
hash your Auth token with a browser fingerprint and store it, that way you can't spoof it on other computers, there are some libraries that help you do it but its definitely possible with a custom made function.
@gringo5282
@gringo5282 6 месяцев назад
Browser fingerprinting is not reliable and there are a lot of collisions (especially in browsers like Safari on iOS). Trusting a fingerprint is also the equivalent of trusting the client, which is pretty well known as a bad idea. If an attacker has a financial incentive to target your site, they can easily write custom code to spoof the fingerprint itself, thus circumventing the check.
@coldicekiller1352
@coldicekiller1352 6 месяцев назад
@@gringo5282 yeah, its a game of cat and mouse, availability and confidentiality are opposites in terms of cybersecurity and my solution was mostly done to dether "casual" hackers trying to get a simple oauth spoofing technique paired with a token expiration timer, i guess the real answer depends on the sensibility of your data and how secure you want it to be without affecting the user too much, 2fa auth on every single transaction like some crypto exchanges do it comes to mind, lol.
@Gorlik1337
@Gorlik1337 6 месяцев назад
Cookies and tokens are compromised when you have xss. In both scenarios you are fucked-up. Soo this doesn't add more secureness into your app.
@zManuel
@zManuel 6 месяцев назад
Wrong, httpOnly cookies can't be accessed through javascript
@gkiokan
@gkiokan 6 месяцев назад
A long time a go for a very long time this was a good practice. You could also bind the token on a specific IP, so you will be still fine. You could also bind the token with a hardware ID and have another validation mechanism on top of the token match. Everything has it's good and bad side. Even considering the Cookie / Session Auth isn't really sure as you can still steal them with proper tools.
@ieatthighs
@ieatthighs 6 месяцев назад
ITS* good side
@unfilledflag
@unfilledflag 6 месяцев назад
"bind to ip" now you break the site for any mobile user that joins or leaves a wifi network
@gkiokan
@gkiokan 6 месяцев назад
@@unfilledflagthats a good point but still a small edge case. However there are also short lived tokens that could be used with refreshing tokens but this is another hussle and story. So maybe just take the hardware UID to compare if the token is coming from the same device if you really want to make your token a bit more secure.
@ieatthighs
@ieatthighs 6 месяцев назад
edit out the spelling mistake you made @@gkiokan
@playwo9635
@playwo9635 6 месяцев назад
In a production app yeah sure I agree, but for your average hobby developer not necessarily. Its very easy to mess up or just don't know about CSRF and exploiting a site without a CSRF token is a lot easier than finding an XSS vulnerability in a web app built with any modern frontend framework. Supply chain attacks (or just not being careful and installing random packages) is a real threat and if your app is dealing with actually sensitive data you should invest the time to use a cookie based approach 100% of the time
@fipabrate
@fipabrate 6 месяцев назад
Sure, I will use session storage (just kidding). On a serious note, it's worth noting that if you opt for local storage, all tabs end up sharing the same storage space. This means that if you're logged in as a regular user in one tab, and someone else logs in as an admin in another tab, the first tab unexpectedly assumes admin privileges as well. Just something to keep in mind!
@bartwestenenk6088
@bartwestenenk6088 6 месяцев назад
But your second tab will login as your first user, so the admin can never even login.
@fipabrate
@fipabrate 6 месяцев назад
@@bartwestenenk6088 true, but if you logout on second tab and then login as admin
@W4nn3
@W4nn3 6 месяцев назад
The same is true for cookies.
@Toleich
@Toleich 6 месяцев назад
It's important to remember the fulcrum of security. What are you protecting, and who are you protecting it from? Sometimes it's okay to do "bad practices" because the application doesn't require much security. As long as you are consciously making that choice. You need to know the rules before you break the rules.
@priyanshuganatra
@priyanshuganatra 6 месяцев назад
0:19 bro predicted the future 😂
@Jamiered18
@Jamiered18 6 месяцев назад
So what you're saying is I can safely keep tokens in local storage... if I just tell users to keep the dev tools open 😉
@dhuv
@dhuv 6 месяцев назад
I prefer cookies but you cannot make random requests with javascript to other domains. This is especially easy to lock down with CSP. Even though those libraries read local storage, it is difficult to get that out. Maybe with a browser extension but not likely to happen.
@scrimb
@scrimb 6 месяцев назад
neither cookies nor localstorage tokens will be safe from malicious code in one of your npm packages the actual solution is to limit the amount of npm packages you install, and not load your app with a bunch of random packages with 10 downloads
@0.lennart
@0.lennart 6 месяцев назад
What about static frontends without ssr? There is no way to use a httponly cookie because you have to access it from js
@kanishkc.2762
@kanishkc.2762 6 месяцев назад
I hope this goes viral.
@anmoljhamb9024
@anmoljhamb9024 6 месяцев назад
DAMN DUDE. The quality of content is just amazing!! an instant sub from me!
@johnmarkvictorino2788
@johnmarkvictorino2788 6 месяцев назад
So what the solution for this problem? with Vue as SPA and Laravel API as backend
@Gornius
@Gornius 6 месяцев назад
Server should support storing token in secure, readonly cookie. Client should not have access to them. Server sets token in secure httponly cookie in login endpoint and server reads token from that cookie.
@minimovzEt
@minimovzEt 6 месяцев назад
@@Gornius that's a load of bullshit, readonly cookies are not secure in any way
@Gornius
@Gornius 6 месяцев назад
@@minimovzEt Yeah, you're right. I meant httponly.
@mmghv
@mmghv 6 месяцев назад
Cookies are more secure but not 100% safe. if you have an XSS, cookies will not help you much if it's a targeted attack, it won't be as easy as blindly stealing auth tokens from the localStorage but an XSS can still do A LOT.
@codokit
@codokit 6 месяцев назад
XSS can do a lot, but it's another topic about CSRF protection.
@mmghv
@mmghv 6 месяцев назад
@@codokit If you have an XSS, CSRF protection won't matter anymore because attacks will happen from the same site and not "cross-site", the attacker can make the user visit, fill & submit forms that already have CSRF tokens with them, he might even be able to silently craft & send XHR requests with CSRF tokens on behalf of the user, any cookies will also be sent automatically with the requests. in other words, if you have an XSS, you are screwed.
@qbasic16
@qbasic16 6 месяцев назад
​@@mmghvadd CORS
@stephenjayh
@stephenjayh 6 месяцев назад
Thank you kind sir
@untitled8027
@untitled8027 6 месяцев назад
set the secure flag on your session cookies too pls
@AndersonPEM
@AndersonPEM 6 месяцев назад
Now how do you do if the application is decoupled from the backend? :)
@rebok232
@rebok232 6 месяцев назад
Doing it on the server's side can be dangerous too, cause if the server automatically reads the cookie to auth you, then what if someone wants to do csrf on you? And also what if your backend is php and you installed a sketchy library, wouldn't it work cause it's server side or what? Solution: Just install trusted libraries
@SirEdges_Adejo
@SirEdges_Adejo 6 месяцев назад
LoL, you just want to comment 😂
@Simple_OG
@Simple_OG 6 месяцев назад
Ok, i am newbie if not in local storage then where ?
@AjeshDSthegr8
@AjeshDSthegr8 6 месяцев назад
Reverse psychology works, you just earned a sub
@abdhelal
@abdhelal 6 месяцев назад
Nice video. I think also using CSP (connect-src ) could save you from some of these problems
@BolverBlitz
@BolverBlitz 6 месяцев назад
I like your sarcasm, but you should devently make some warnings for new devs. Like you said, cookies are automaticly within every request. So also in the once made by mallicus code or xss So cookies are even more of a issue than localstorage. The "HTTP Only" Cookie was once an attempt to make it secure, but you just call fetch in js and the browser puts in the cookie anyways... Leaking it. However, you should always use the "Content-Security-Policy" Headers, this makes sure nothing can make requests to any webserver you did not manualy allow first. Then one of the only issues i can think of would be a XSS making a public post on your webpage (in case this is possible) with your secrets, but you can simply check if a post contains a currently valid secret and in case it does just don´t generate the post or invalidate the token like many apps already do it.
@basarokke4403
@basarokke4403 6 месяцев назад
Good Topic. But where to store auth Tokens instead of localstorage? Or do you want to say don't use auth tokens? I don't understand your opinion clearly?
@basarokke4403
@basarokke4403 6 месяцев назад
I want my laravel api in a domain. And my quasar-vue app will consum it. My quasar app is a spa and a cordova app! How to handle this the right way?
@hnccox
@hnccox 6 месяцев назад
store them in a cookie which is httpOnly
@cdruc
@cdruc 6 месяцев назад
If you're using Laravel as a JSON API for a web application, do not use tokens - use the regular cookie based authentication as described here: laravel.com/docs/10.x/sanctum#how-it-works-spa-authentication If you're using Laravel as a JSON api for a mobile app, use token based authentication as described here: laravel.com/docs/10.x/sanctum#mobile-application-authentication If you have both a web app AND a mobile app use.... both. Use the cookie based auth routes for the web app login, and use the token based login routes for your mobile app. ---- I'm not familiar with quasar, but from the looks of it, I think you can just use cookies
@bartoszkrawczyk4976
@bartoszkrawczyk4976 6 месяцев назад
Just don't manage your tokens with javascript at all. Set it on the server side in a cookie with httpOnly flag. It will be added to every request automatically, it will be handled by your backend, but won't be accessible via javascript.
@basarokke4403
@basarokke4403 6 месяцев назад
@@bartoszkrawczyk4976 this sounds interesting. Thanks you both! Any resources links where can I see a laravel vue spa example?
@nixjavi7220
@nixjavi7220 6 месяцев назад
great video!
@kinositajona
@kinositajona 6 месяцев назад
Good rule of thumb for beginners. Not going to deny it. But this is irrelevant for any site with even the most simple of Content Security Policies.
@kipchickensout
@kipchickensout 6 месяцев назад
there are third party extensions to show network packages. the one i found was ugly and cumbersome but it worked, and it wasn't detected by the website
@CitizensCommunity
@CitizensCommunity 6 месяцев назад
I love this, so many who think Linux is safe also just trust all their binaries. This is such a problem.
@iRoNYwho
@iRoNYwho 6 месяцев назад
so how to handle tokens if you are not laravel developer? Im using session cookie, and take jwt from it. Is it safe?
@cdruc
@cdruc 6 месяцев назад
the cookie must be httpOnly - if it’s not, it’s just as safe as localstorage. what are you using for backend?
@iRoNYwho
@iRoNYwho 6 месяцев назад
@@cdruc golang echo with, jwt and sessions middleware. thx for httpOnly tip, didnt know
@bautistaigarzabal
@bautistaigarzabal 6 месяцев назад
Hi! right now I have to authenticate my app, and I was thinking about saving the jwt token in the localstorage, but seeing this video I know it's not the right thing to do. The only way I have to use my backend (symfony) is with fetch, I use Axios. How should I do the authentication?
@ieatthighs
@ieatthighs 6 месяцев назад
If you don't want to go with session cookies localStorage is fine
@bautistaigarzabal
@bautistaigarzabal 6 месяцев назад
I want to use session cookies, but my frontend and backend are in different docker containers, different ports, and possibly different domains, do you recommend any guide that i can follow to use session cookies?
@ieatthighs
@ieatthighs 6 месяцев назад
@@bautistaigarzabal I had the exact same situation and I just went with localstorage. It's fine as long as you know the risks. Remember, even discord uses this method
@ieatthighs
@ieatthighs 6 месяцев назад
@@bautistaigarzabal looks like youtube keeps deleting my responses
@MrCh4nk
@MrCh4nk 6 месяцев назад
@@bautistaigarzabal thats fine, you still can exchange cookies between each service, even though they are in different container, port, domain, zone, just set the cors on the server to allow subdomain/domain where you serve your frontend app to allow credentials, then each of requests fired via axios should have withCredentials set to true and you are good to go
@aGj2fiebP3ekso7wQpnd1Lhd
@aGj2fiebP3ekso7wQpnd1Lhd 6 месяцев назад
I've often wondered about the security of local storage when using frames as well because the top page and page can use local storage for communication. Will be encrypting data here going forward.
@ieatthighs
@ieatthighs 6 месяцев назад
encrypting localStorage is pointless
@aGj2fiebP3ekso7wQpnd1Lhd
@aGj2fiebP3ekso7wQpnd1Lhd 6 месяцев назад
@@ieatthighs why?
@ieatthighs
@ieatthighs 6 месяцев назад
@@aGj2fiebP3ekso7wQpnd1Lhd if you intent to keep an access token there it won't prevent an attacker from using it. they just won't know what is inside which is pointless since those tokens are usually random/encoded json of non critical info
@ieatthighs
@ieatthighs 6 месяцев назад
@@aGj2fiebP3ekso7wQpnd1Lhd I explained but youtube deleted my comment. Thank them
@qbasic16
@qbasic16 6 месяцев назад
​@@aGj2fiebP3ekso7wQpnd1LhdWhere are you going to store the (symmetric) encryption key? It's pointless.
@usemt9726
@usemt9726 6 месяцев назад
just create a backend that is REALLY safe, the internet is going on a cookieless path, so local storage is not that bad
@Bat-Georgi
@Bat-Georgi 6 месяцев назад
Ok, so what am I supposed to use instead? Are cookies and session storage any better?
@peteredmonds1712
@peteredmonds1712 6 месяцев назад
Supabase stores the `access_token` and `refresh_token` JWTs in local storage. Is there some reason why this is okay?
@muhamedkarajic
@muhamedkarajic 6 месяцев назад
Great video!
@lightprogrammer
@lightprogrammer 6 месяцев назад
what about sessionStorage?
@陸
@陸 6 месяцев назад
Discord be like:Yeah, let's store user token in localstorage!
@ieatthighs
@ieatthighs 6 месяцев назад
oh so it's the self xss argument, as always. If you are already compromised, it doesn't matter where you store your tokens. And the cookies can be stolen using JS too
@arnhazra
@arnhazra 6 месяцев назад
Very good explaination. But what if a npm package tracks all the requests that I am sending with body header and everything including response. How to be safe from that ?
@mpcref
@mpcref 6 месяцев назад
use deno instead of node.
@tukangeksperimen7844
@tukangeksperimen7844 6 месяцев назад
​@@mpcref why?
@mpcref
@mpcref 6 месяцев назад
@@tukangeksperimen7844to be safe from the concern you're raising.
@lu2000luk
@lu2000luk 6 месяцев назад
Man, unfortunatley i dont handle auth for my app, my DB does and it stores them in localStorage, and, in some parts of my code extracting tokens from it is actually used. For example to auth the same user across different domains. Thanks for the video btw.
@rajikkali2381
@rajikkali2381 6 месяцев назад
No no no. Localstorage is fine. Cookies are no more secure. So tired of hearing this argument on youtube and medium. Even supabase uses this method.
@Andrew-jh2bn
@Andrew-jh2bn 6 месяцев назад
I mean, everything's on a spectrum. Local storage is more vulnerable to compromised JavaScript dependencies then a http only cookie. Of course, depending on how sophisticated the malicious dependency, it could make api calls to your backend while you're visiting the page in your browser, but that would have to be more targeted.
@abdirahmann
@abdirahmann 6 месяцев назад
yeah me too, am tired of hearing this! 😂😂😂🤡
@michaelbitzer7295
@michaelbitzer7295 6 месяцев назад
HttpOnly cookies are more secure.
@mauricebagalwa6923
@mauricebagalwa6923 6 месяцев назад
Noted 😎 !
@Wariowa345
@Wariowa345 6 месяцев назад
where am i supposed to do? cookies seems even worst
@lucsoft
@lucsoft 6 месяцев назад
Sounds like snake oil, if you have XSS then you have already a compromised system. I find local storage more straight forward and I only need to care about XSS not some crazy CSRF or extra security headers.
@gabboman92
@gabboman92 6 месяцев назад
that could also happen in apps...
@hidvpohaidvhozxcvnpzxov7835
@hidvpohaidvhozxcvnpzxov7835 6 месяцев назад
good video
@theblckbird
@theblckbird 6 месяцев назад
Awesome!
@user-su1zh7fx3x
@user-su1zh7fx3x 6 месяцев назад
make sure to tell people how to not store auth tokens, how to know if they already are.
@jbarriossandrea
@jbarriossandrea 6 месяцев назад
Where else should I store my tokens then?😅
@ieatthighs
@ieatthighs 6 месяцев назад
localStorage is enough
@harryhack91
@harryhack91 6 месяцев назад
So you're basically implying that we should go back to a monolith architecture and use Http-only cookies.
@nomadshiba
@nomadshiba 6 месяцев назад
maybe 5% of js is not mine, i write everything
@FabioMafu
@FabioMafu 6 месяцев назад
I believe most devs write everything
@IIKACHOW95
@IIKACHOW95 6 месяцев назад
Guys I think he doesn’t want us to save auth tokens in LocalStorage
@villandoom
@villandoom 6 месяцев назад
Discord be like:
@chrismanning5232
@chrismanning5232 6 месяцев назад
The real message of this video should've been to stop using random ass npm packages lol
@nefrace
@nefrace 6 месяцев назад
"99% of JS code is not even yours" My website has 0 lines of js code right now and it's all mine
@user-et1wp3sf4p
@user-et1wp3sf4p 6 месяцев назад
Simple, don’t use NPM, there I solved it
@aleclippe6213
@aleclippe6213 6 месяцев назад
How does this apply to the Microsoft tech stack and azure ad
@4fortyfour
@4fortyfour 6 месяцев назад
tell this to discord
@AdiktdToLoli
@AdiktdToLoli 6 месяцев назад
i subscribed anyway... what chu gonna do about it huh >:3
@koushikseal
@koushikseal 5 месяцев назад
CSP
@MedChergui
@MedChergui 6 месяцев назад
What if i encrypt the token before i store it and decrypt it when i want to use it ?
@qbasic16
@qbasic16 6 месяцев назад
And where will you store the key for your (symmetric) encryption?
@MedChergui
@MedChergui 6 месяцев назад
@@qbasic16 if i were using SSR this will be at the server.
@qbasic16
@qbasic16 6 месяцев назад
@@MedChergui and what's the point on storing an encrypted token on the server? You still have to authenticate the requests from a (valid) client.
@MedChergui
@MedChergui 6 месяцев назад
@@qbasic16 The encrypted token will be in localStorage (aka Clinet) but the key to decrypt will be in server. Decrypt it then check if the encrypted token does match.
@MedChergui
@MedChergui 6 месяцев назад
@@qbasic16 The encrypted token will be stored in the client, but the key will be in server. The server decrypt the encrypted token and verify the user
@Mempler
@Mempler 6 месяцев назад
nice, but how the fuck are you store secure tokens in a server-less application. I mean literally, you only get an SPA without any code running on the server other than sending a static file. every single solution will expose the token in an easily accessible way.
@RickardBrent
@RickardBrent 6 месяцев назад
Skip the fluff and get to the point.
@milefiori7694
@milefiori7694 6 месяцев назад
Why don't encode your auth token then? Even if its stolen it's meaningless to the attacker
@EpKjelltzer
@EpKjelltzer 6 месяцев назад
Meaningless in what sense? As long as the token is valid proof of authentication, the attacker will be able to use it to impersonate the user they stole it from.
@ieatthighs
@ieatthighs 6 месяцев назад
encode? Then the attacker can just decode the token, what are you talking about
@pali122
@pali122 6 месяцев назад
@@EpKjelltzer But adding the user ip, and browser or extra info should help mitigate those things, plus a refresh token stored on the server. I mean that's the usual JWT pattern. An attacker could decode it but the token should not be valid from anywhere
@TheNovakon
@TheNovakon 6 месяцев назад
To build code above malicious packages is very bad idea. Dislike.
@cdruc
@cdruc 6 месяцев назад
huh?
@ZawHlaingWin-ri1js
@ZawHlaingWin-ri1js 6 месяцев назад
Are u stupid or smth?
@svendpai
@svendpai 6 месяцев назад
Try giving the video a second watch, it seems like you misunderstood the message of the video.
@DerLuukee
@DerLuukee 6 месяцев назад
Bot 😅😂
@xajiraqab
@xajiraqab 6 месяцев назад
document.cookie ? :3
@mehedimi
@mehedimi 6 месяцев назад
You can not access HTTP Only Cookie using document.cookie.
@xajiraqab
@xajiraqab 6 месяцев назад
@@mehedimi if i cant read tokens using js. how can i make refresh token to refresh access token when it expires
@michaelbitzer7295
@michaelbitzer7295 6 месяцев назад
​@@xajiraqabyou simply send a request to the auth server to issue a new token.
@xajiraqab
@xajiraqab 6 месяцев назад
@@michaelbitzer7295 how if u cant read refresh token
@Cloneee
@Cloneee 6 месяцев назад
​@@xajiraqabbrowser will do the job
Далее
How principled coders outperform the competition
11:11
Session-Based Authentication in Golang
23:36
Never* use git pull
4:02
Просмотров 446 тыс.
The BEEFY mini PC - Minisforum AtomMan G7 PT
12:40
Просмотров 177 тыс.
Solving the Dotfiles Problem (And Learning Bash)
8:22
LocalStorage was a mistake...
5:33
Просмотров 48 тыс.
40 APIs Every Developer Should Use (in 12 minutes)
12:23
This UI component library is mind-blowing
8:23
Просмотров 654 тыс.
WHY IS THE HEAP SO SLOW?
17:53
Просмотров 219 тыс.