I'm just diving into web development and working on projects to showcase in my portfolio, but I've hit a major obstacle: authentication. I'm using the PERN stack and want to implement user sign-in functionality, ensuring that the data they submit is stored in the database. It seems like everyone else knows how to tackle authentication effortlessly, but I find it really confusing and daunting. Any advice on the best way to learn about authentication would be super helpful!
5 Answers
Try building OAuth 2 from scratch; it's simpler than it looks and will really help you understand the underlying principles of authentication.
Here's a path I’d recommend: first, grasp the basic flow of username and password authentication. Then, focus on understanding password hashing and its importance. Next, try implementing basic sign-in without relying on any frameworks. Once you're comfortable, look into OAuth for social sign-ins, and eventually, learn a robust authentication framework. Trust me, creating your own auth is something I’d strongly advise against!
Start by creating a simple authentication form where you check the user's plain password against the one stored in the database. Once you nail that, learn how to securely hash the passwords—like using Argon2—and how to compare hashed passwords. After that, you can dive into keeping the user's authenticated state with cookies. This will give you a solid foundation in authentication!
I tackled this by reading the OAuth 2.0 specification—it's dense, but worth it! From there, I had tons of questions which led to many web searches. I used those searches to gather resources and built things alongside my learning. If possible, I'd suggest sticking with OAuth and moving away from traditional passwords, as it's becoming the newer standard.
Check out the 'Copenhagen Book' and the Lucia Auth guide—both are fantastic resources for learning about authentication.
Related Questions
How To Get Your Domain Unblocked From Facebook
How To Find A String In a Directory of Files Using Linux