Skip to content

Commit 54ae7c1

Browse files
committed
first commit
0 parents commit 54ae7c1

26 files changed

+1040
-0
lines changed

.env-copy

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Google OAuth
2+
3+
GOOGLE_CLIENT_ID= # Google OAuth client id
4+
GOOGLE_CLIENT_SECRET= # Google OAuth client secret
5+
6+
# Amazon SES
7+
8+
AMAZON_ID= # IAM user id
9+
AMAZON_SECRET= # IAM user secret
10+
AMAZON_REGION= # SES region
11+
EMAIL_VERIFICATION_SENDER= # one of the SES verified identity
12+
13+
# Bcrypt
14+
15+
BCRYPT_ROUNDS=12
16+
17+
# Server
18+
19+
SERVER_HOST=localhost
20+
SERVER_PORT=5000
21+
22+
# Redis
23+
24+
REDIS_HOST=localhost
25+
REDIS_PORT=6379
26+
27+
# JWT
28+
29+
JWT_ALGORITHM=RS256
30+
JWT_PUBLIC_KEY=secrets/jwt_public.pem
31+
JWT_PRIVATE_KEY=secrets/jwt_private.pem
32+
ACCESS_TOKEN_EXPIRY=60s

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*/*.pem
2+
.env
3+
package-lock.json
4+
node_modules/

.sequelizerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const path = require('node:path');
2+
3+
module.exports = {
4+
'config': path.resolve(__dirname, 'config', 'config.json'),
5+
'models-path': path.resolve(__dirname, 'src', 'models'),
6+
'migrations-path': path.resolve(__dirname, 'migrations'),
7+
'seeders-path': path.resolve(__dirname, 'seeders'),
8+
}

ReadMe.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
## NodeJS Authentication With Email Verification

config/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"development": {
3+
"username": "root",
4+
"password": "root",
5+
"database": "oauth_passport",
6+
"host": "localhost",
7+
"port": 33601,
8+
"dialect": "mysql"
9+
}
10+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
await queryInterface.createTable('Users', {
7+
id: {
8+
type: Sequelize.INTEGER,
9+
autoIncrement: true,
10+
primaryKey: true,
11+
},
12+
email: {
13+
type: Sequelize.STRING(320),
14+
allowNull: false,
15+
unique: true
16+
},
17+
password: {
18+
type: Sequelize.STRING(64)
19+
}
20+
})
21+
},
22+
23+
async down (queryInterface, Sequelize) {
24+
await queryInterface.dropTable('Users')
25+
}
26+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
await queryInterface.addColumn('Users', 'displayName', {
7+
type: Sequelize.STRING(30),
8+
allowNull: false,
9+
})
10+
},
11+
12+
async down (queryInterface, Sequelize) {
13+
await queryInterface.removeColumn('Users', 'displayName')
14+
}
15+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
await queryInterface.addColumn('Users', 'refreshToken', {
7+
type: Sequelize.TEXT
8+
})
9+
},
10+
11+
async down (queryInterface, Sequelize) {
12+
await queryInterface.removeColumn('Users', 'refreshToken')
13+
}
14+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
'use strict';
2+
3+
/** @type {import('sequelize-cli').Migration} */
4+
module.exports = {
5+
async up (queryInterface, Sequelize) {
6+
await queryInterface.addColumn('Users', 'verified', {
7+
type: Sequelize.BOOLEAN,
8+
allowNull: false,
9+
defaultValue: false
10+
})
11+
},
12+
13+
async down (queryInterface, Sequelize) {
14+
await queryInterface.removeColumn('Users', 'verified')
15+
}
16+
};

package.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "node-authentication-with-email-verification",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"scripts": {
6+
"oauth": "node --env-file-if-exists=.env --watch src/"
7+
},
8+
"keywords": [
9+
"node",
10+
"nodejs",
11+
"express",
12+
"authentication",
13+
"oauth",
14+
"google oauth",
15+
"jwt",
16+
"jsonwebtoken",
17+
"passport",
18+
"email verification",
19+
"aws ses",
20+
"redis"
21+
],
22+
"author": "Rahul Bagchi",
23+
"license": "ISC",
24+
"description": "",
25+
"dependencies": {
26+
"@aws-sdk/client-ses": "^3.744.0",
27+
"bcrypt": "^5.1.1",
28+
"express": "^4.21.2",
29+
"express-rate-limit": "^7.5.0",
30+
"joi": "^17.13.3",
31+
"jsonwebtoken": "^9.0.2",
32+
"mysql2": "^3.12.0",
33+
"passport": "^0.7.0",
34+
"passport-google-oauth20": "^2.0.0",
35+
"passport-jwt": "^4.0.1",
36+
"passport-local": "^1.0.0",
37+
"redis": "^4.7.0",
38+
"sequelize": "^6.37.5",
39+
"sequelize-cli": "^6.6.2"
40+
}
41+
}

0 commit comments

Comments
 (0)