Authentication Level-1: Register and Login with just a username and password.
Authentication Level-2:Register and Login with encrypted password with SECRET_KEY:
- Define a long string secret key either by using a random generation function or preferably manually at this stage.
- Create the pgcrypto Extension
- Alter the size of password column to VARCHAR(512) to make sure it will accommodate for the encrypted password
- Adjust the INSERT query in post register route to include the password encryption
- Adjust the post login route to include the decryption process to authenticate the user login credentials
Adding/ Configuring Environment Variables & gitignore
Authentication Level-3:Register and Login using password hashing with md5:
- Install md5 (npm i md5) and import md5
- Remove the Encryption and calling the SECRET_KEY from Register and LOgin routes and replace them with hashing the password using md5 function.
Authentication Level-4:Register & Login using password hashing/ salting with bcrypt:
- Install bcrypt (npm i bcrypt) and import bcrypt. If you face any issue in installation, refer to the GITHUB repos of NPM to search the solution.
- Define the number of salt rounds: const saltRound = 10
- Remove the usage of MD5 from import, Register and Login routes and replace them with the bcrypt hashing/salting function as detailed in the code.
Authentication Level-5: Using passport, express-session & sequelize to add Cookies & sessions to insure authenticate and de-authenticate users credentials with starts and expiries of users login sessions and server restarts:
- Installing & importing the relevant packages express-session, passport, passport-local, sequelize & connect-flash.
- Set up & initialize the session including the cookies properties.
- Set Up Sequelize and create User Model with PostgreSQL
- Initialize and start using passport
- Configure Passport Local Strategy.
- Update register and login routes.
- Adding Secret Route and Logout Route.
Authentication Level-6: OAuth 2.0 & Implement Sign In with Google:
- Create an application on the Google Developers Console.
- Alter our Database Table to suit our app requirement (Add isgoogleaccount column).
- Install & import the required packages ("passport-google-oauth20")
- Configure Google strategy as defined in passport Docs & adjust it to suit our requirements.
- Replace serializing and deserializing functions with the ones defined in passport documentation.
- Download & copy the bootstrap-social.css to our public folder.
- Add the Sign Up with Google Button in Register & login EJS and add the classes relevant to bootstrap-social.css.
- Update the header.ejs with the incorporated CSS file.
- Add “/auth/google” route.
- Add “/auth/google/secrets” route.
Update:
- Change the secrets route to get secrets and render the secrets page.
- Include GET SUBMIT Route to authenticate the user and render the submit page.
- Include POST SUBMIT Route to post the user new secret to the Database and redirect to secrets page.
- Update secrets.ejs to loop through the secrets and show them on client-side