We do not want to store user passwords as plain text in our database. We'll use an encryption library to build secure password hashes for users.
- [Narrator] Hi, and welcome.…In the previous video, we created a basic…login and registration user interface…for our library application.…In this video, we'll create a User object…to store in the database…with an encrypted password hash.…To get started, we'll download and install…the bcrypt library.…Next, we'll define what users should look like…in the database.…Finally, we'll create and store…new User objects when a user registers with the site.…Let's get started.…When authenticating users,…we want to avoid storing any direct password information.…
Instead of storing the user's password,…we'll use bcrypt to generate…a salted password hash,…which we'll use to compare the password…and verify our user's identity.…To install bcrypt, let's open a terminal…and type go get going.org/x/crypto/bcrypt.…This may take a moment,…depending on your computer hardware and network speeds.…Now let's open up our main.go file.…In the import list, let's add a line…for going.org/x/crypto/bcrypt.…Now that we have bcrypt ready to go,…we should define the User object…
Go is on the rise. This open-source programming language (created by Google!) comes with a strong and accessible standard library, and provides a growing ecosystem of tools, libraries, and frameworks that can help you build web applications fast. Go for Web Development gets you started with the language, opening with the classic "Hello world" exercise and culminating in a web application with a strongly designed database back end, useful middleware, UI with an intelligent search function, multi-user authentication, and more.
First, learn how to build a web server with Go's extensive standard library. Explore the concepts behind a single-page web application and learn how to create a dynamic user interface, manipulate a database, and use powerful encryption algorithms to implement an authentication system. Next, you'll incorporate more functionality by calling out to external libraries from the database. Finally, it all comes together into an optimized package you can deploy into the wild with Heroku.
- Creating a route in Go
- Using templates
- Building database connections
- Collecting data
- Using web middleware
- Using the Ace template engine
- Integrating HTTP routers like gorilla/mux
- Authenticating users
- Optimizing a Go codebase