feat(auth): implement session-based authentication and API token management
- Introduced a new authentication system using session cookies for the web dashboard and API tokens for sync clients. - Replaced the old SERVER_PASSWORD scheme with a more secure API token mechanism. - Added routes for user setup, login, logout, and credential updates. - Implemented middleware to require session and API token for protected routes. - Updated web UI to handle authentication states and provide user feedback. - Enhanced error handling in API requests and responses. - Updated README to reflect new authentication flow and database requirements.
This commit is contained in:
1 parent
240e1fda4a
commit
b150d835a1
18 files changed
+1022
-982
No files matched your search
@@ -1,58 +1,50 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
server:
|
||||
build: .
|
||||
container_name: collabtable-server
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- PORT=3000
|
||||
- NODE_ENV=production
|
||||
# Authentication (optional but recommended)
|
||||
- SERVER_PASSWORD=change_me
|
||||
# Database selection: sqlite | postgres (default sqlite)
|
||||
- DB_CLIENT=sqlite
|
||||
# SQLite path (used when DB_CLIENT=sqlite)
|
||||
- DB_PATH=/data/collabtable.db
|
||||
# Retry DB initialization instead of crashing immediately on startup races
|
||||
- DB_INIT_RETRY_INTERVAL_MS=5000
|
||||
- DB_INIT_RETRY_MAX_ATTEMPTS=0
|
||||
# Clamp future client timestamps during sync to avoid resend loops
|
||||
- SYNC_MAX_FUTURE_SKEW_MS=0
|
||||
# PostgreSQL (used when DB_CLIENT=postgres) - choose either DATABASE_URL or the PG* vars
|
||||
# - DATABASE_URL=postgres://user:password@postgres:5432/collabtable
|
||||
# - PGHOST=postgres
|
||||
# - PGPORT=5432
|
||||
# - PGUSER=postgres
|
||||
# - PGPASSWORD=yourpassword
|
||||
# - PGDATABASE=collabtable
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- sqlite_data:/data
|
||||
networks:
|
||||
- collabtable-network
|
||||
|
||||
# Optional PostgreSQL database
|
||||
# postgres:
|
||||
# image: postgres:16-alpine
|
||||
# container_name: collabtable-postgres
|
||||
# restart: unless-stopped
|
||||
# environment:
|
||||
# - POSTGRES_DB=collabtable
|
||||
# - POSTGRES_USER=postgres
|
||||
# - POSTGRES_PASSWORD=yourpassword
|
||||
# ports:
|
||||
# - "5432:5432"
|
||||
# volumes:
|
||||
# - pg_data:/var/lib/postgresql/data
|
||||
# networks:
|
||||
# - collabtable-network
|
||||
|
||||
volumes:
|
||||
sqlite_data:
|
||||
# pg_data:
|
||||
|
||||
networks:
|
||||
collabtable-network:
|
||||
driver: bridge
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:17-alpine
|
||||
container_name: collabtable-postgres
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- POSTGRES_DB=collabtable
|
||||
- POSTGRES_USER=collabtable
|
||||
- POSTGRES_PASSWORD=collabtable
|
||||
volumes:
|
||||
- pg_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- collabtable-network
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U collabtable"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
||||
server:
|
||||
build: .
|
||||
container_name: collabtable-server
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- PORT=3000
|
||||
- NODE_ENV=production
|
||||
# Session cookie for the admin web dashboard (see src/routes/authRoutes.ts)
|
||||
- COOKIE_SECURE=false
|
||||
# Retry DB initialization instead of crashing immediately on startup races
|
||||
- DB_INIT_RETRY_INTERVAL_MS=5000
|
||||
- DB_INIT_RETRY_MAX_ATTEMPTS=0
|
||||
# Clamp future client timestamps during sync to avoid resend loops
|
||||
- SYNC_MAX_FUTURE_SKEW_MS=0
|
||||
- DATABASE_URL=postgres://collabtable:collabtable@postgres:5432/collabtable
|
||||
ports:
|
||||
- "3000:3000"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- collabtable-network
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
|
||||
networks:
|
||||
collabtable-network:
|
||||
driver: bridge
|
||||
Reference in new issue
Block a user