-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
54 lines (40 loc) · 1.85 KB
/
config.py
File metadata and controls
54 lines (40 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# SPDX-License-Identifier: AGPL-3.0-or-later
# Flask configuration for Subsurface Web UI
import os
import sys
class Config:
"""Base configuration."""
# SECRET_KEY must match the flask-auth-proxy app's SECRET_KEY
# to enable shared session authentication between the two apps
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-change-in-production')
# Path to subsurface-cli binary
CLI_PATH = os.environ.get('SUBSURFACE_CLI_PATH', 'subsurface-cli')
# Path to CLI config file (for single-user mode)
CLI_CONFIG_PATH = os.environ.get('SUBSURFACE_CLI_CONFIG', None)
# For multi-tenant mode: base directory for user repos
REPO_BASE_PATH = os.environ.get('SUBSURFACE_REPO_BASE', None)
# Temporary directory for CLI config files (multi-tenant mode)
TEMP_DIR = os.environ.get('SUBSURFACE_TEMP_DIR', '/run/subsurface-webui')
# Development mode: skip authentication
DEV_MODE = os.environ.get('SUBSURFACE_DEV_MODE', 'false').lower() == 'true'
DEV_USER = os.environ.get('SUBSURFACE_DEV_USER', 'dev@localhost')
class DevelopmentConfig(Config):
"""Development configuration."""
DEBUG = True
DEV_MODE = True
class ProductionConfig(Config):
"""Production configuration.
Security requirements:
- SECRET_KEY must be set via environment variable (same as flask-auth-proxy)
- DEV_MODE is always False
- DEBUG is always False
"""
DEBUG = False
DEV_MODE = False
def __init__(self):
super().__init__()
# Security: Fail loudly if SECRET_KEY is not properly configured
if self.SECRET_KEY == 'dev-secret-key-change-in-production':
print("ERROR: SECRET_KEY environment variable must be set in production!", file=sys.stderr)
print("It must match the SECRET_KEY from your flask-auth-proxy configuration.", file=sys.stderr)
sys.exit(1)