diff --git a/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json b/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json index 8b87163b16..6b9b5bad8c 100644 --- a/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json +++ b/challenges/06-information-security-and-quality-assurance/advanced-express-tools.json @@ -371,8 +371,8 @@ "As a reminder, this project is being built upon the following starter project on Glitch, or cloned from GitHub.", "Going back to the information security section you may remember that storing plaintext passwords is never okay. Now it is time to implement BCrypt to solve this issue.", "
Add BCrypt as a dependency and require it in your server. You will need to handle hashing in 2 key areas: where you handle registering/saving a new account and when you check to see that a password is correct on login.", - "Currently on our registeration route, you insert a user's password into the database like the following: password: req.body.password. An easy way to implement saving a hash instead is to add the following before your database logic var hash = bcrypt.hashSync(req.body.password, 8); and replacing the req.body.password in the database saving with just password: hash. (In our small scale app, it is fine to use sync hashing especially with a low cost of 8 as it wont block the thread very much at all)", - "Finally on our authentication strategy we check for the following in our code before completing the process: if (password !== user.password) { return done(null, false); }. After making the previous changes, now user.password is a hash. Before making a change to the existing code, notice how the statement is checking if the password is NOT equal then return non-authenticated. With this in mind your code could look as follows to properly check the password entered against the hash: if (!bcrypt.compareSync(password, user.password)) { return done(null, false); }", + "Currently on our registeration route, you insert a user's password into the database like the following: password: req.body.password. An easy way to implement saving a hash instead is to add the following before your database logic var hash = bcrypt.hash(req.body.password, 12); and replacing the req.body.password in the database saving with just password: hash.", + "Finally on our authentication strategy we check for the following in our code before completing the process: if (password !== user.password) { return done(null, false); }. After making the previous changes, now user.password is a hash. Before making a change to the existing code, notice how the statement is checking if the password is NOT equal then return non-authenticated. With this in mind your code could look as follows to properly check the password entered against the hash: if (!bcrypt.compare(password, user.password)) { return done(null, false); }", "That is all it takes to implement one of the most important security features when you have to store passwords! Submit your page when you think you've got it right." ], "challengeSeed": [],