Skip to content

Commit 775a687

Browse files
committed
feat: adding single sign-in option(google & github)
1 parent 524a2df commit 775a687

File tree

15 files changed

+522
-46
lines changed

15 files changed

+522
-46
lines changed

backend/.env.example

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
MONGO_URI = mongodb://localhost:27017/PeerCall
2+
PORT = 3000
3+
JWT_SECRET = secret12peercall
4+
FRONTEND_URL = http://localhost:5173
5+
6+
GITHUB_CLIENT_ID = put yours
7+
GITHUB_CLIENT_SECRET put yours
8+
GOOGLE_CLIENT_ID = put yours
9+
GOOGLE_CLIENT_SECRET = put yours
10+
GOOGLE_CALLBACK_URL = http://localhost:3000/api/auth/google/callback
11+
GITHUB_CALLBACK_URL = http://localhost:3000/api/auth/github/callback

backend/package-lock.json

Lines changed: 166 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"jsonwebtoken": "^9.0.2",
2020
"mongodb": "^6.20.0",
2121
"mongoose": "^8.19.2",
22+
"passport": "^0.7.0",
23+
"passport-github2": "^0.1.12",
24+
"passport-google-oauth20": "^2.0.0",
2225
"socket.io": "^4.8.1",
2326
"zod": "^4.1.12"
2427
},
@@ -27,10 +30,13 @@
2730
"@types/express": "^5.0.3",
2831
"@types/jsonwebtoken": "^9.0.10",
2932
"@types/node": "^24.9.1",
33+
"@types/passport": "^1.0.17",
34+
"@types/passport-github2": "^1.2.9",
35+
"@types/passport-google-oauth20": "^2.0.16",
3036
"@types/socket.io": "^3.0.1",
3137
"nodemon": "^3.1.10",
3238
"ts-node": "^10.9.2",
3339
"ts-node-dev": "^2.0.0",
3440
"typescript": "^5.9.3"
3541
}
36-
}
42+
}

backend/src/app.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ import authRoutes from "./routes/authRoutes.js";
44
import healthRoutes from "./routes/healthRoutes.js";
55
import { errorHandler } from "./middleware/errorHandler.js";
66
import roomRoutes from "./routes/roomRoutes.js";
7-
7+
import passport from "passport";
8+
import "./utils/passport.js"
9+
import cors from "cors";
810
dotenv.config();
911
const app = express();
1012

1113
app.use(express.json());
1214

15+
app.use(
16+
cors({
17+
origin: process.env.FRONTEND_URL || "http://localhost:5173",
18+
credentials: true,
19+
})
20+
);
21+
//initialize passport
22+
app.use(passport.initialize());
1323
// Routes
1424
app.use("/api/auth", authRoutes);
1525
app.use("/api/health", healthRoutes);

0 commit comments

Comments
 (0)