TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Resources for learning niche aspects of authentication services?

2 点作者 tytho大约 2 年前
Over the course of my career, I&#x27;ve learned a lot about authentication, but I find that there&#x27;s not a lot of resources for things you might need to know if you need to write your own auth service or even learn how one is written.<p>Some aspects that I feel aren&#x27;t talked about as much are things like:<p>- How to store records of personal auth tokens (like GitHub personal tokens)<p>Using JWTs for these kinds of tokens is widely deemed a bad idea because it&#x27;s not revokable (without changing the JWT key and essentially revoking all tokens signed with the same key). What I hear is that just generating a token with cryptographically random bytes is good enough for most applications, but does one just store those bytes raw in the database? Or is a hash stored? Or does the database record have an id and hash (similar to a username&#x2F;password) and the token given to the user is an encoded string that contains the id and raw token? Most things I find when I search &quot;How to store record of token in database&quot; are questions about how to store an auth token given from an OAuth2 handshake or how to store a GitHub token securely. Nothing about how the identity service itself stores a token.<p>- How to store (or not store) records of one-time auth tokens like email auth&#x2F;verification tokens<p>Similar to the above token question, though the threat model seems a little different because they&#x27;re not long-lived tokens.<p>- Best practice for uphashing password hashes<p>I&#x27;ve played around with this idea of needing to rehash password hashes. For example, say you have password hashes a bcrypt hashes with 10 rounds. Then it&#x27;s decided that bcrypt with that many rounds isn&#x27;t great anymore with today&#x27;s hardware and you should bump it up to 14 hashes, or switch to a different algorithm. Next time people login, you could use the old algorithm to validate then hash the password while you have it in plaintext, but what about the users who don&#x27;t sign in? Couldn&#x27;t you instead store the layers of hash rules (like the algorithm, salt, number of rounds without the hash) and the last &quot;layer&quot; be a hash with the latest algorithm? I vaguely remember someone suggesting that somewhere here, but when I tried to implement it, there wasn&#x27;t really a standard format for storing those hashing rules beyond the PHC format that argon2 uses.<p>The goal of learning these sorts of things is not to go off and write my own auth service. At this point, I feel like rolling your own auth is treated a lot like rolling your own crypto: Leave it to the experts. But without expert writings, how are we to learn and maintain existing systems? Or attempt to improve them? Perhaps I&#x27;m just impatient and haven&#x27;t spent the requisite time searching, but I&#x27;m hoping to get some ideas from this community.

2 条评论

nullfield大约 2 年前
You’re looking at a section of the development market that, largely, is somewhat opaque AND has “few” experts vis a vis other disciplines-both for some of the reasons you mention (don’t roll your own) and for things like the difficulty of really doing it well versus people’s (company’s) lack of desire to reinvent the wheel on something that’s working.<p>All this leads to the lack of easily accessible (from a technical side) papers, training, etc., and let’s face it-being hard, plenty of people who can design and document and develop business systems wouldn’t handle the heavy math and dense papers well, or more importantly (and in line with your question) expand those naturally to “best practices”.<p>It’s far cheaper to let Google or Facebook handle your identity management for a cost between close-to-free to mostly-reasonable, and use Okta or the like if you want more control.<p>The best suggestion I can really offer, lame as it feels, is that outside deep immersion into that world and it’s papers and experts one should study open source implementations like Red Hat-backed Keycloak or Apereo CAS to see how they do it in the real world (I’m sure there are others; these just come to mind).
wolverine876大约 2 年前
Authorization or authentication, or both?
评论 #35215772 未加载