Files
ServerKit/backend/config.py
T
Juan Denis 9def699bee Add firewall management API and service
Introduces backend API endpoints and service logic for managing firewalld and ufw, including status, rules, IP blocking, and installation. Updates CORS settings, improves Windows compatibility in file and FTP services, and adds required dependencies. Frontend changes include new Firewall and PHP pages, updated sidebar, and related styles.
2026-01-17 13:05:39 -05:00

55 lines
1.9 KiB
Python

import os
import sys
from datetime import timedelta
# Default insecure keys that must be changed in production
INSECURE_SECRET_KEYS = [
'dev-secret-key-change-in-production',
'jwt-secret-key-change-in-production',
'change-this-to-a-secure-random-string',
'change-this-to-another-secure-random-string',
]
class Config:
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production')
# Database
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', 'sqlite:///serverkit.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
# JWT
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY', 'jwt-secret-key-change-in-production')
JWT_ACCESS_TOKEN_EXPIRES = timedelta(hours=1)
JWT_REFRESH_TOKEN_EXPIRES = timedelta(days=30)
# CORS - Allow both dev server and Flask server
CORS_ORIGINS = os.environ.get('CORS_ORIGINS', 'http://localhost:5173,http://localhost:5000,http://127.0.0.1:5173,http://127.0.0.1:5000').split(',')
class DevelopmentConfig(Config):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
def __init__(self):
# Validate that secret keys are not default values in production
if self.SECRET_KEY in INSECURE_SECRET_KEYS:
print("FATAL: SECRET_KEY is set to a default insecure value in production mode!", file=sys.stderr)
print("Generate a secure key with: python -c \"import secrets; print(secrets.token_hex(32))\"", file=sys.stderr)
sys.exit(1)
if self.JWT_SECRET_KEY in INSECURE_SECRET_KEYS:
print("FATAL: JWT_SECRET_KEY is set to a default insecure value in production mode!", file=sys.stderr)
print("Generate a secure key with: python -c \"import secrets; print(secrets.token_hex(32))\"", file=sys.stderr)
sys.exit(1)
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}