Skip to content

Commit cef69ad

Browse files
committed
feat: add configurable cookie security and login rate limiting
- Added LOGIN_ATTEMPT_SALT environment variable for secure rate limiting hash generation - Introduced AUTH_COOKIE_SECURE flag to support CDN SSL termination scenarios - Updated nginx config to properly set X-Forwarded-Proto for CDN deployments
1 parent 33fdf25 commit cef69ad

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

.env.docker.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,21 @@ JWT_SECRET=
1212
ADMIN_USERNAME=admin
1313
ADMIN_PASSWORD=
1414

15+
# Login Security Configuration
16+
# Required: high-entropy salt used to hash login attempt identifiers (protects rate limiting)
17+
# Generate with: openssl rand -base64 48
18+
LOGIN_ATTEMPT_SALT=
19+
20+
# Cookie Security
21+
# Set to false if using CDN with SSL termination (BunnyCDN, Cloudflare, etc.)
22+
# AND your nginx config sets X-Forwarded-Proto to https
23+
# Default: true (cookies only sent over HTTPS)
24+
# AUTH_COOKIE_SECURE=false
25+
1526
# Optional: CORS Configuration
1627
# Comma-separated list of allowed frontend origins
1728
# Default: http://localhost:8489
29+
# Production example: https://yourdomain.com
1830
# FRONTEND_ORIGINS=http://localhost:8489,https://yourdomain.com
1931

2032
# Optional: Rust log level

.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ DATABASE_URL=sqlite:./database.db
1212
# For testing only: use a strong random string in production!
1313
JWT_SECRET=your-super-secret-jwt-key-min-32-chars-change-me-in-production
1414

15+
# Cookie Security
16+
# Set to false if using CDN with SSL termination (BunnyCDN, Cloudflare, etc.)
17+
# AND your nginx config sets X-Forwarded-Proto to https
18+
# Default: true (cookies only sent over HTTPS)
19+
# AUTH_COOKIE_SECURE=true
20+
1521
# Server Configuration
1622
# Port on which the backend server will run
1723
PORT=8489

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ services:
2222
- FRONTEND_ORIGINS=${FRONTEND_ORIGINS:-http://localhost:8489}
2323
- ADMIN_USERNAME=${ADMIN_USERNAME:?ADMIN_USERNAME must be set in environment}
2424
- ADMIN_PASSWORD=${ADMIN_PASSWORD:?ADMIN_PASSWORD must be set in environment}
25+
- LOGIN_ATTEMPT_SALT=${LOGIN_ATTEMPT_SALT:?LOGIN_ATTEMPT_SALT must be set in environment}
26+
- AUTH_COOKIE_SECURE=${AUTH_COOKIE_SECURE:-true}
2527
volumes:
2628
- backend-data:/data
2729
networks:

nginx-configs/host-reverse-proxy.conf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ server {
4747
proxy_set_header Host $host;
4848
proxy_set_header X-Real-IP $remote_addr;
4949
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50-
proxy_set_header X-Forwarded-Proto $scheme;
50+
# WICHTIG: Bei SSL Termination durch CDN (BunnyCDN, Cloudflare, etc.)
51+
# muss dies auf 'https' gesetzt werden, damit Cookies richtig funktionieren
52+
proxy_set_header X-Forwarded-Proto https;
5153
proxy_set_header X-Forwarded-Host $host;
5254
proxy_set_header X-Forwarded-Port $server_port;
5355

0 commit comments

Comments
 (0)