- Accounts: account and admin pages in Cross Events' layout (top bar, sidebar, a page per section, dark footer); quick links to the church's sites (GET /me/apps); nightly pg_dump backups with Admin -> Backups (run, keep, download, audited; heartbeat lastBackupAt); a fuller built-in privacy notice with headings and bullets; a fixed favicon. /backups/ ignored (anchored, so src/backups is kept). - Contracts 1.11.0: people.removeDemo (only @example.com, never an admin). - Events: uploads served from the folder they're saved in (a backend started outside backend/ answered 404 for a logo it had just saved); Branding checks the file loads before saving; logout waits for the sign-out call so Accounts signs out too; set-demo removes the last demo's people from Accounts. Tests: Accounts 62 + e2e 8, Events 782, contracts 225; npm run check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.3 KiB
JavaScript
30 lines
1.3 KiB
JavaScript
// Where uploaded files live, and how they're served (3.3.0). One folder for saving and serving:
|
|
// backend/public/uploads, the same from src/ and dist/. Before 3.3.0 the files were served from
|
|
// "public/uploads" relative to wherever the process was started, so a backend started from
|
|
// another folder saved a logo in one place and answered 404 for it from another.
|
|
const path = require('path');
|
|
const express = require('express');
|
|
|
|
const UPLOADS_DIR = path.join(__dirname, '..', '..', 'public', 'uploads');
|
|
|
|
/** The folder for one kind of upload (e.g. "branding"), made if it isn't there yet. */
|
|
function uploadsDir(sub) {
|
|
const dir = path.join(UPLOADS_DIR, sub);
|
|
require('fs').mkdirSync(dir, { recursive: true });
|
|
return dir;
|
|
}
|
|
|
|
// Uploaded branding assets can include SVGs, which may embed <script>/event handlers. Serving
|
|
// them inline lets a malicious upload run script in the site's origin if opened directly, so pin
|
|
// the safe response headers (no inline execution, no MIME-sniffing to HTML/script) on every file.
|
|
function serveUploads() {
|
|
return express.static(UPLOADS_DIR, {
|
|
setHeaders: (res) => {
|
|
res.setHeader('Content-Security-Policy', "default-src 'none'; style-src 'unsafe-inline'; sandbox");
|
|
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
},
|
|
});
|
|
}
|
|
|
|
module.exports = { UPLOADS_DIR, uploadsDir, serveUploads };
|