Skip to content

Commit ca5c506

Browse files
committed
readme added
1 parent ef64d6d commit ca5c506

File tree

2 files changed

+154
-3
lines changed

2 files changed

+154
-3
lines changed

ReadMe.md

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,153 @@
1-
## NodeJS Authentication With Email Verification
1+
# NodeJS Authentication with Email Verification and OAuth
2+
3+
This project provides a robust and secure authentication system for your Node.js applications, featuring email verification, password management, and OAuth integration (Google). It emphasizes security best practices, including token-based authentication with *asymmetric key signing* and password hashing.
4+
5+
## Table of Contents
6+
7+
* [Features](#features)
8+
* [Tech Stack](#tech-stack)
9+
* [Installation](#installation)
10+
* [API Endpoints](#api-endpoints)
11+
* [Contributing](#contributing)
12+
* [License](#license)
13+
14+
15+
## Features <a name="features"></a>
16+
17+
* **User Registration:**
18+
* Email and Password registration with mandatory email verification.
19+
* Google OAuth registration.
20+
* **Email Verification:**
21+
* Time-limited verification links (15 minutes).
22+
* Resend verification email functionality.
23+
* Change email address with verification.
24+
* **Password Management:**
25+
* Secure password hashing using bcrypt.
26+
* Password reset functionality with time-limited reset links (5 minutes).
27+
* Change password functionality.
28+
* **Authentication:**
29+
* Token-based authentication (JWT).
30+
* Short-lived access tokens (15 minutes).
31+
* Long-lived refresh tokens (7 days) for seamless token renewal.
32+
* Access tokens are sent via the `Authorization` header (Bearer token).
33+
* **Security:**
34+
* Protection against common vulnerabilities. (Mention specific protections if implemented, e.g., rate limiting, input validation)
35+
* **Scalability:**
36+
* Designed for scalability using Redis for caching. (Explain what you're caching)
37+
38+
[Go to Table of Contents](#table-of-contents)
39+
40+
## Tech Stack <a name="tech-stack"></a>
41+
42+
* **Backend:**
43+
* Node.js
44+
* Express.js
45+
* Passport.js (for authentication strategies)
46+
* **Database:**
47+
* MySQL (with Sequelize ORM)
48+
* **Caching:**
49+
* Redis
50+
* **Email:**
51+
* AWS SES
52+
* **Authentication & Authorization:**
53+
* JWT (JSON Web Tokens)
54+
* Google OAuth 2.0
55+
* **Validation:**
56+
* Joi
57+
* **Other:**
58+
* Bcrypt (for password hashing)
59+
60+
[Go to Table of Contents](#table-of-contents)
61+
62+
## Installation <a name="installation"></a>
63+
64+
1. **Clone the Repository:**
65+
66+
```bash
67+
git clone https://github.com/rahulstech/node-authentication-with-email-verification.git
68+
69+
cd node-authentication-with-email-verification
70+
````
71+
72+
2. **Environment Variables:**
73+
74+
* Copy `.env-copy` to `.env`.
75+
* Fill in the required credentials:
76+
* Google OAuth Client ID and Secret
77+
* AWS SES credentials (IAM user with SES permissions)
78+
* Redis host and port (defaults are usually fine)
79+
80+
<!-- end list -->
81+
82+
```
83+
# Example .env file
84+
GOOGLE_CLIENT_ID=your_google_client_id
85+
GOOGLE_CLIENT_SECRET=your_google_client_secret
86+
AMAZON_ID=your_aws_iam_id
87+
AMAZON_SECRET=your_aws_iam_secret
88+
AMAZON_REGION=your_aws_region
89+
EMAIL_VERIFICATION_SENDER=your_verified_ses_email
90+
REDIS_HOST=localhost
91+
REDIS_PORT=6379
92+
```
93+
94+
3. **JWT Keys:**
95+
96+
* Generate RSA key pair for JWT signing (using OpenSSL):
97+
98+
<!-- end list -->
99+
100+
```bash
101+
openssl genpkey -algorithm RSA -out jwt_private.pem -pgenopt rsa:key_gen_bits:4096
102+
openssl rsa -in jwt_private.pem -pubout -out jwt_public.pem
103+
```
104+
105+
* Place `jwt_private.pem` and `jwt_public.pem` in the `secrets` directory. *(Create the `secrets` directory if it doesn't exist.)*
106+
107+
4. **Database Setup:**
108+
109+
* Configure MySQL connection in `config/config.json`.
110+
* Create the database and run migrations:
111+
112+
<!-- end list -->
113+
114+
```bash
115+
npx sequelize-cli db:create
116+
npx sequelize-cli db:migrate
117+
```
118+
119+
5. **Install Dependencies:**
120+
121+
<!-- end list -->
122+
123+
```bash
124+
npm install
125+
```
126+
127+
6. **Run the Server:**
128+
129+
<!-- end list -->
130+
131+
```bash
132+
npm run dev # (or npm start if you have that script defined)
133+
```
134+
135+
136+
* The server will typically start on port 5000 (configurable in `.env`).
137+
138+
139+
[Go to Table of Contents](https://www.google.com/url?sa=E&source=gmail&q=#table-of-contents)
140+
141+
## API Endpoints <a name="api-endpoints"></a>
142+
143+
*(Provide a few key API endpoint examples with request methods, URLs, request bodies (if needed), and response examples. This is crucial for developers wanting to use your API.)*
144+
145+
```
146+
POST /auth/register - Register a new user
147+
POST /auth/login - Login a user
148+
GET /auth/verify/:token - Verify email
149+
POST /auth/resend-verification - Resend verification email
150+
# ... (add more endpoints)
151+
```
152+
153+
[Go to Table of Contents](https://www.google.com/url?sa=E&source=gmail&q=#table-of-contents)

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"redis"
2121
],
2222
"author": "Rahul Bagchi",
23-
"license": "ISC",
24-
"description": "",
23+
"description": "node express authentication with email verification",
2524
"dependencies": {
2625
"@aws-sdk/client-ses": "^3.744.0",
2726
"bcrypt": "^5.1.1",

0 commit comments

Comments
 (0)