Live data from Hacker News

What's the best way to do authentication in modern applications

neciudan.dev

11–20 of 22 posts

Re: What's the best way to do authentication in modern applications

#11
If I use short-lived JWTs and localstorage, am I such a bad person? Are you truly increasing the blast radius?

Is there someone in another part of the world that would like hacking you only if you’re not using httpOnly cookies, happy to know that you used localstorage?

Re: What's the best way to do authentication in modern applications

#12
post #5

I struggle to underdress why this slop content gets to the front page. It’s likely close to 100% ai made. I really want this era of AI generated writing that reads so poorly to end. Or at least society should be ashamed of publishing this content.

They use bots to promote their content to the front page and downvote any comments criticizing them. I observe this pattern consistently on this website.

Re: What's the best way to do authentication in modern applications

#13
smells a bit like AI, or AI helped article. Still, some points are explained quite clearly. Knew most of it, but still, some parts where a good reminder. I would always try to use bullet prooven framworks and NOT reinvent the wheel. Best way to go in 2026. There is simply too much angles of attack and knowing myself I would miss something.

Re: What's the best way to do authentication in modern applications

#14
post #5

I struggle to underdress why this slop content gets to the front page. It’s likely close to 100% ai made. I really want this era of AI generated writing that reads so poorly to end. Or at least society should be ashamed of publishing this content.

If the slop wasn't bad enough, halfway down the page you get a newsletter signup lightbox - the use of which ought to be a felony in my opinion.

Re: What's the best way to do authentication in modern applications

#15
post #5

I struggle to underdress why this slop content gets to the front page. It’s likely close to 100% ai made. I really want this era of AI generated writing that reads so poorly to end. Or at least society should be ashamed of publishing this content.

It was clear from the first ChatGPT release that the best application for LLMs is spam.

Re: What's the best way to do authentication in modern applications

#16
post #9

localStorage is very much fine and arguably superior to cookies for authentication tokens. First of all, once you have achieved JS execution on a target origin, you can send requests, open up malicious "login" prompts and generally control everything the user sees and does. The article mentions this, but plays it down with no good arguments. Much more importantly however, is that the cookie standards are a mess! The…

Cookies also don't work on mobile, so you inevitably have to maintain 2 different login flows.

But they're still the superior choice for authN on the web, because if you want to, you CAN configure cookies to be secure. Yes, attackers can ride the session, but it's dependent on the user being on the tab and you being able to consistently execute JS. Client-side compromise (ie attacker controls the entire browser) is not feasible to defend against anyway.

The main issue with JWT+localStorage is you can actually execute one-off JS, exfiltrate the token and come back later. I've _never_ seen a well-executed JWT+localStorage implementation in 10 or so years, because teams inevitably realise they can't reliably revoke sessions (another advantage of cookies) and then start giving out long-lived access tokens but adding them to the database. Or some variation of that.

Re: What's the best way to do authentication in modern applications

#17

smells a bit like AI, or AI helped article. Still, some points are explained quite clearly. Knew most of it, but still, some parts where a good reminder. I would always try to use bullet prooven framworks and NOT reinvent the wheel. Best way to go in 2026. There is simply too much angles of attack and knowing myself I would miss something.

> "Still, some points are explained quite clearly."

My experience with "AI" is that if you ask the right questions in the right way (and give it access to accurate information to build it's answers from) it's actually really good at explaining things "quite clearly".

Re: What's the best way to do authentication in modern applications

#18
post #9

localStorage is very much fine and arguably superior to cookies for authentication tokens. First of all, once you have achieved JS execution on a target origin, you can send requests, open up malicious "login" prompts and generally control everything the user sees and does. The article mentions this, but plays it down with no good arguments. Much more importantly however, is that the cookie standards are a mess! The…

localStorage is not sent to the server when you request a document. So now you threw out the ability to do server-side rendering. This is only fine if you've got a application that always requires authentication, otherwise you risk server vs client mismatch, needless roundtrips, and DOM rewrites.

Re: What's the best way to do authentication in modern applications

#19
post #9

localStorage is very much fine and arguably superior to cookies for authentication tokens. First of all, once you have achieved JS execution on a target origin, you can send requests, open up malicious "login" prompts and generally control everything the user sees and does. The article mentions this, but plays it down with no good arguments. Much more importantly however, is that the cookie standards are a mess! The…

localStorage is not sent to the server when you request a document. So now you threw out the ability to do server-side rendering. This is only fine if you've got a application that always requires authentication, otherwise you risk server vs client mismatch, needless roundtrips, and DOM rewrites.

Of course it isn't. localStorage is used for SPAs.

Re: What's the best way to do authentication in modern applications

#20

smells a bit like AI, or AI helped article. Still, some points are explained quite clearly. Knew most of it, but still, some parts where a good reminder. I would always try to use bullet prooven framworks and NOT reinvent the wheel. Best way to go in 2026. There is simply too much angles of attack and knowing myself I would miss something.

> "Still, some points are explained quite clearly." My experience with "AI" is that if you ask the right questions in the right way (and give it access to accurate information to build it's answers from) it's actually really good at explaining things "quite clearly".

Agreed, I often ask for schemas/explanations.
Post reply on HN