TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Web Authentication Methods Compared

181 pointsby luordover 4 years ago

22 comments

groundthrowerover 4 years ago
Used jwt for our web app before - changed to session cookies. To make jwt secure for web apps it feels like you are reinventing session authentication.
评论 #25521992 未加载
评论 #25521785 未加载
franky47over 4 years ago
Another interesting method, overkill for most applications but absolutely required for end-to-end encrypted apps where no password must be sent to the server (eg: password managers): the Secure Remote Password (SRP) protocol[1].<p>It&#x27;s a form of zero-knowledge proof-based verification that the password provided during account creation matches the one provided during an authentication challenge, all without transmitting the password at all. As a bonus, it also act as a key exchange on the client and server, that can be used for securing transmissions over untrusted channels (at the cost of having stateful connections).<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Secure_Remote_Password_protocol" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Secure_Remote_Password_protoco...</a>
评论 #25522336 未加载
评论 #25522361 未加载
cratermoonover 4 years ago
Meh. I&#x27;m getting a sense that the author&#x27;s grasp of authentication and authorization protocols is incomplete. I don&#x27;t mean in the sense that the author left out some popular protocols, which is true, but in the sense that there&#x27;s details wrong. For example, oauth and OpenID are mentioned only in the context of social login, and the differences between oauth, oauth2, OpenID and OIDC aren&#x27;t covered (and OIDC is almost entirely unrelated to the original OpenID). Also, the author has a section at the end &quot;GitHub social auth&quot; as if it were somehow different from regular oauth used all over the internet.<p><a href="https:&#x2F;&#x2F;www.wikiwand.com&#x2F;en&#x2F;List_of_OAuth_providers" rel="nofollow">https:&#x2F;&#x2F;www.wikiwand.com&#x2F;en&#x2F;List_of_OAuth_providers</a>
评论 #25523963 未加载
tialaramexover 4 years ago
It makes no sense whatsoever to &quot;compare&quot; Web Authentication methods for humans in 2020 without even mentioning WebAuthn since that&#x27;s literally why it&#x27;s called WebAuthn (Web Authentication) and that&#x27;s exactly what it&#x27;s for.<p>In one sense this is bad news for this comparison, but it&#x27;s also bad news for the general state of security on the web, because this item is 8 hours old and I&#x27;m writing this top level item now, which means for eight hours people who think of themselves as &quot;web developers&quot; didn&#x27;t even ask &quot;Why not WebAuthn?&quot;
评论 #25527794 未加载
评论 #25525118 未加载
1vuio0pswjnm7over 4 years ago
From the section on session-based authentication:<p><a href="https:&#x2F;&#x2F;tools.ietf.org&#x2F;id&#x2F;draft-broyer-http-cookie-auth-00.html" rel="nofollow">https:&#x2F;&#x2F;tools.ietf.org&#x2F;id&#x2F;draft-broyer-http-cookie-auth-00.h...</a><p>&quot;To mitigate replay attacks (re-use of a sniffed cookie), the value of the cookie used for authentication SHOULD NOT contain the users credentials but rather a key associated with the authentication session, and <i>this key SHOULD be renewed (and expired) frequently</i>.&quot;<p>Session cookies are often defined as cookies that expire when the browser is closed. The truth is that session cookies do not necessarily expire when the browser is closed. Indeed they are lost to the browser, but the user can save them to a text file. If they are truly expired then they should no longer work. However, in some cases, the cookie in the text file can be reused to avoid login, long after after the browser is closed and across subsequent reboots. For example, one such case is a very popular webmail provider. Since the provider now forces users to run Javascript in order to login, this technique can be used to check, read and send mail from the command line using clients that do not include a Javascript interpreter. There are many other examples where session cookies can be used after the browser is closed to avoid having to keep logging in. Unless the website is one that logs the user out after a period of inactivity, there is a good chance &quot;sessions cookies&quot; can be used long-term.
评论 #25525439 未加载
评论 #25523862 未加载
flowerladover 4 years ago
Not mentioned: passwordless authentication<p>See:<p><a href="https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;security&#x2F;business&#x2F;identity&#x2F;passwordless" rel="nofollow">https:&#x2F;&#x2F;www.microsoft.com&#x2F;en-us&#x2F;security&#x2F;business&#x2F;identity&#x2F;p...</a><p><a href="https:&#x2F;&#x2F;query.prod.cms.rt.microsoft.com&#x2F;cms&#x2F;api&#x2F;am&#x2F;binary&#x2F;RE2KEup" rel="nofollow">https:&#x2F;&#x2F;query.prod.cms.rt.microsoft.com&#x2F;cms&#x2F;api&#x2F;am&#x2F;binary&#x2F;RE...</a><p>In passwordless authentication, the device creates a public and private key when registered. The private key can only be unlocked using fingerprint or PIN. If an attacker knows the PIN he also needs the device. If he has the device he also needs the PIN.
评论 #25524240 未加载
评论 #25523926 未加载
l0b0over 4 years ago
Good overview, but I&#x27;m not sure I agree with the assertion that OAuth&#x2F;OpenID is unconditionally more secure. It still depends on both the provider and the intermediate site doing things properly, like generating actually random values, not reusing randomness, not leaking tokens, and all the stuff you have to worry about normally.
eatonphilover 4 years ago
With the web developer hat on I most prefer working on apps with cookie based authentication since it makes it easy to use the browser to debug&#x2F;make additional requests. If the cookie already exists I can go to any API url in the browser and it just works. Putting the secret in localstorage or only in app memory makes that not possible.<p>On the API side I prefer to support both cookie and Authorization header so you get the benefits in browser but don&#x27;t overcomplicate the CLI side of things by requiring cookie state.
tester756over 4 years ago
&gt;Tokens cannot be deleted. They can only expire. This means that if the token gets leaked, an attacker can misuse it until expiry. Thus, it&#x27;s important to set token expiry to something very small, like 15 minutes.<p>But can be black listed.
评论 #25523389 未加载
评论 #25523720 未加载
combatentropyover 4 years ago
It calls some of these stateless, but don&#x27;t they all have to run a secondary look-up?<p>For example, in Basic Authentication, you still have to check the username and password against a database, whether that be a file, a relational database, LDAP, etc. For JWT, to verify the signature you must look up the issuer&#x27;s pre-shared or public key.<p>Is it even possible for a request be stateless if it requires authentication?
评论 #25521972 未加载
CharlesWover 4 years ago
Hey auth gurus! I have a newb question for a scenario that this article doesn&#x27;t appear to cover, so I hope folks don&#x27;t mind if I ask it here.<p>Is there any way to authorize a front-end app to use private back-end services without requiring a login? (I have people abusing APIs which were intended to be private, and which may otherwise force me to require user accounts.)
评论 #25523808 未加载
评论 #25523765 未加载
评论 #25523739 未加载
neilvover 4 years ago
Coincidentally, just yesterday I was looking for the usual simple in-server form&amp;session Web site authn functionality for a Rust Web framework (and, ideally, also client certs).<p>I was confused by what this page says is available, and what it didn&#x27;t: <a href="https:&#x2F;&#x2F;www.arewewebyet.org&#x2F;topics&#x2F;auth&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.arewewebyet.org&#x2F;topics&#x2F;auth&#x2F;</a><p>I get why OAuth2&#x2F;OpenID is popular, in a tech professional environment comfortable with leaking information about users, and also desensitized to the risks of a single Web site having numerous third-party service&amp;CDN dynamic dependencies for a page load... but I still expected the basic default authn mechanism to be form&amp;session, and then some of the other mechanisms to build upon some of the same authn (and perhaps autho) session&amp;events&amp;UX foundation.
Justsignedupover 4 years ago
Session based auth is what we used to do in the olden days. It was horrible. Sure it was easy to log in a keep a session cookie, but man... restarting servers = logged out, unless you persisted sessions. Session replication. It adds all sort of complexities after the initial implementation.
评论 #25525617 未加载
forgotmypw17over 4 years ago
I use hybrid basic and cookie auth in my application.<p>Basic auth functions as a captcha and invite code, eliminating users not invited and almost all bots.<p>After that,s done, the user gets a cookie (and a private key in LocalStorage) and is not prompted next time.<p>The beauty of cookies and basic is that the cookie is sent before auth takes place.
评论 #25523026 未加载
darkhornover 4 years ago
It doesn&#x27;t mention client certificates.
评论 #25522540 未加载
评论 #25524817 未加载
评论 #25523477 未加载
slezyrover 4 years ago
&gt; Session-based Auth<p>&gt; It&#x27;s stateful. The server keeps track of each session on the server-side. The session store, used for storing user session information, needs to be shared across multiple services to enable authentication. Because of this, it doesn&#x27;t work well for RESTful services, since REST is a stateless protocol.<p>What stops you from keeping the JWT token in there? In fact, I doubt that it&#x27;s some random session ID and not some encrypted payload that gets decrypted instead of looking it up in the database.
评论 #25521774 未加载
zmmmmmover 4 years ago
It seems like for simple 2-party exchanges, as soon as you are using TLS and assuming you trust it, I&#x27;m not sure what the advantage is of doing anything more than basic authentication? Perhaps if you want to throttle authentications to prevent brute forcing it becomes a problem.<p>For sure, if you have more complex auth needs (more parties, granular access, etc etc) then you can start to justify more complex things ... but I&#x27;m curious what other weaknesses are there in that scheme?
评论 #25524176 未加载
hunter2_over 4 years ago
I find it amusing that this article starts off explaining the difference between authN and authZ and then immediately proceeds to a describe an authN scheme where the authN transaction utilizes a request header called &quot;Authorization&quot; (used in reply to a response header that doesn&#x27;t have this quirk, oddly enough). Would be nice to see a footnote apologizing for what I&#x27;d consider a linguistic blunder on par with &quot;Referer&quot;...
jgalt212over 4 years ago
Basic Authentication is a pain with a web app sitting behind Apache as it strips all &quot;sensitive&quot; headers before passing along the request to the web app.
评论 #25525602 未加载
评论 #25522183 未加载
ape4over 4 years ago
For Digest the article says &quot;Credentials must be sent with every request&quot;... but not really. Once you&#x27;re logged in the server can remember that you are and not ask for it each time. The client can only send it when requested.
评论 #25522873 未加载
评论 #25522907 未加载
uptownover 4 years ago
What’s everyone’s preferred auth library for NodeJS based server use? It’ll be interacting with both a React based front-end from desktop as well as a SwiftUI front end from mobile.
评论 #25523172 未加载
pier25over 4 years ago
&gt; <i>Vulnerable to CSRF attacks</i><p>Is this really still an issue with cookies?<p>We now have cookie options like same-site and secure which AFAIK prevent the vast majority of attacks.