This project contains a source file for a server primarily for performing 1-factor authentication (1FA). The server can be deployed with minimum configuration (see about How to Setup the Project) on any platform for Node.js.
There are 4 main things I made sure to do in order to make to project complied with the security standards/practices.
-
Hasing password with bcrypt
-
Validating user inputs (both username and password)
-
Use prepared statement to prevent SQL injection
-
Sign JWT with a long, random string
If you want to increase the level of security, make sure the website uses HTTPS instead of HTTP, and DO NOT use user account with more than enough privilege for your database.
-
Express.js (
express) -
mysql2(for MySQL) -
JWT (
jsonwebtoken)
-
Clone the project using
git clonecommand.git clone https://github.com/ChanathipK/one-factor-authen.git -
Run
npm installcommand. Note that you have to install Node.js which will get younpmCLI tool automatically. -
Create an environment variable file, either
.env.developmentor.env.production.Example
.env.developmentDB_HOST='127.0.0.1' DB_PORT='3306' MYSQL_USERNAME='root' MYSQL_PASS='1234' DATABASE='express_auth_sample' CORS_ORIGIN='http://127.0.0.1' SERVER_PORT='5000' SECRET='...'