Adds in authentication system and overhauls the navigation bar to be built dynamically.
This commit is contained in:
parent
7e98b5345d
commit
28c054de22
21 changed files with 1531 additions and 56 deletions
|
@ -11,6 +11,8 @@
|
|||
*/
|
||||
import express from 'express'
|
||||
import compression from 'compression'
|
||||
import session from 'express-session'; // Added for session management
|
||||
import { v4 as uuidv4 } from 'uuid'; // Added for generating session IDs
|
||||
import {
|
||||
defineSsrCreate,
|
||||
defineSsrListen,
|
||||
|
@ -21,9 +23,18 @@ import {
|
|||
|
||||
import prisma from './database.js'; // Import the prisma client instance
|
||||
import apiRoutes from './routes/api.js';
|
||||
import authRoutes from './routes/auth.js'; // Added for WebAuthn routes
|
||||
import cron from 'node-cron';
|
||||
import { generateAndStoreMantisSummary } from './services/mantisSummarizer.js';
|
||||
|
||||
// Define Relying Party details (Update with your actual details)
|
||||
export const rpID = process.env.NODE_ENV === 'production' ? 'your-production-domain.com' : 'localhost';
|
||||
export const rpName = 'StylePoint';
|
||||
export const origin = process.env.NODE_ENV === 'production' ? `https://${rpID}` : `http://${rpID}:9100`;
|
||||
|
||||
// In-memory store for challenges (Replace with a persistent store in production)
|
||||
export const challengeStore = new Map();
|
||||
|
||||
/**
|
||||
* Create your webserver and return its instance.
|
||||
* If needed, prepare your webserver to receive
|
||||
|
@ -34,6 +45,19 @@ import { generateAndStoreMantisSummary } from './services/mantisSummarizer.js';
|
|||
export const create = defineSsrCreate((/* { ... } */) => {
|
||||
const app = express()
|
||||
|
||||
// Session middleware configuration
|
||||
app.use(session({
|
||||
genid: (req) => uuidv4(), // Use UUIDs for session IDs
|
||||
secret: process.env.SESSION_SECRET || 'a-very-strong-secret-key', // Use an environment variable for the secret
|
||||
resave: false,
|
||||
saveUninitialized: true,
|
||||
cookie: {
|
||||
secure: process.env.NODE_ENV === 'production', // Use secure cookies in production
|
||||
httpOnly: true,
|
||||
maxAge: 1000 * 60 * 60 * 24 // 1 day
|
||||
}
|
||||
}));
|
||||
|
||||
// Initialize the database (now synchronous)
|
||||
try {
|
||||
console.log('Prisma Client is ready.'); // Log Prisma readiness
|
||||
|
@ -72,6 +96,7 @@ export const create = defineSsrCreate((/* { ... } */) => {
|
|||
|
||||
// Add API routes
|
||||
app.use('/api', apiRoutes);
|
||||
app.use('/auth', authRoutes); // Added WebAuthn auth routes
|
||||
|
||||
// place here any middlewares that
|
||||
// absolutely need to run before anything else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue