linuxrouter/docker/routlin-dash/app/settings.py

23 lines
670 B
Python
Raw Normal View History

2026-06-06 14:55:29 -04:00
import os
def is_production():
2026-06-07 14:21:40 -04:00
return not os.environ.get('DEV_MODE', '').lower() in ('1', 'true', 'yes')
2026-06-06 14:55:29 -04:00
def is_pro():
return bool(os.environ.get('LICENSE', '').strip())
2026-06-07 00:50:49 -04:00
def get_credentials_key():
"""Return a Fernet-compatible key derived from the CREDENTIALS_KEY environment variable,
or None if not set. SHA-256 hashes the raw string to produce 32 bytes, which are then
URL-safe base64-encoded as required by Fernet."""
import base64
import hashlib
key_str = os.environ.get('CREDENTIALS_KEY', '')
if not key_str:
return None
raw = hashlib.sha256(key_str.encode()).digest()
return base64.urlsafe_b64encode(raw)