2024-05-29 23:45:56 +02:00
|
|
|
import passport from "passport";
|
|
|
|
import session from "express-session";
|
|
|
|
import { initialize } from "./passport-config";
|
|
|
|
import auth from "../routes/auth/auth-controller";
|
|
|
|
import { Express } from "express";
|
|
|
|
|
|
|
|
export function connect(app: Express) {
|
|
|
|
app.use(session({
|
2024-05-30 01:03:15 +02:00
|
|
|
secret: import.meta.env.VITE_SESSION_SECRET || "default-secret",
|
2024-05-29 23:45:56 +02:00
|
|
|
resave: false,
|
|
|
|
saveUninitialized: false
|
|
|
|
}));
|
|
|
|
|
|
|
|
app.use(passport.initialize());
|
|
|
|
app.use(passport.authenticate(['headerapikey', 'session'], {
|
|
|
|
session: false, // Only set a session on the login request.
|
|
|
|
}));
|
|
|
|
|
|
|
|
initialize(passport);
|
|
|
|
|
|
|
|
app.use("/auth", auth);
|
|
|
|
}
|