fix: remaining security and deployment hardening (#6 #7 #10)

#7 Transport Security:
- Removed legacy _ssl_ctx alias from config.py
- proxy.py now uses _internal_ssl_ctx directly (explicitly scoped)
- No global TLS bypass remains

#10 Deployment Hardening:
- Inventory Dockerfile: non-root (node user), health check, production deps
- Budget Dockerfile: non-root (node user), health check, npm ci, multi-stage ready
- Frontend-v2 Dockerfile: multi-stage build, non-root (node user), health check
- Added /health endpoints to inventory and budget (before auth middleware)
- All 6 containers now run as non-root with health checks

All services verified: gateway, trips, fitness, inventory, budget, frontend
This commit is contained in:
Yusuf Suleman
2026-03-29 09:35:39 -05:00
parent 0ed8f1f83e
commit 72747668f9
8 changed files with 102 additions and 23 deletions

View File

@@ -2,13 +2,17 @@ FROM node:20-alpine
WORKDIR /app
COPY package.json ./
RUN npm install --production
COPY package.json package-lock.json ./
RUN npm ci --production
COPY server.js ./
RUN mkdir -p /app/data
RUN mkdir -p /app/data && chown -R node:node /app/data
EXPOSE 3001
ENV NODE_ENV=production
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD wget -qO- http://localhost:3001/health || exit 1
USER node
CMD ["node", "server.js"]

View File

@@ -11,6 +11,9 @@ const app = express();
app.use(cors());
app.use(express.json());
// Health check (before auth middleware)
app.get('/health', (req, res) => res.json({ status: 'ok', ready }));
// API key auth middleware — require X-API-Key header on all routes
const SERVICE_API_KEY = process.env.SERVICE_API_KEY || '';
if (SERVICE_API_KEY) {

View File

@@ -2,17 +2,15 @@ FROM node:18-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
RUN npm install --production
# Install dependencies
RUN npm install
COPY server.js ./
# Copy application files
COPY . .
# Expose port
EXPOSE 3000
ENV NODE_ENV=production
# Start the application
HEALTHCHECK --interval=30s --timeout=5s --retries=3 CMD wget -qO- http://localhost:3000/health || exit 1
USER node
CMD ["node", "server.js"]

View File

@@ -27,6 +27,9 @@ app.use(express.json());
// Allow form-encoded payloads from NocoDB webhook buttons
app.use(express.urlencoded({ extended: true }));
// Health check (before auth middleware)
app.get('/health', (req, res) => res.json({ status: 'ok' }));
// API key auth middleware — require X-API-Key header on all routes
const SERVICE_API_KEY = process.env.SERVICE_API_KEY || '';
if (SERVICE_API_KEY) {