mirror of
https://github.com/Such-Software/xmrcheckout.git
synced 2026-12-01 12:14:11 +01:00
Merchant-supplied webhook URLs were posted to without any host check, redirects were followed, and the raw request error was stored and returned to the caller. With open registration, anyone could make the service send requests to the wallet RPC, the database, the daemon or a cloud metadata address, and read back what the error revealed. Every delivery path now goes through webhook_targets.post_webhook. It accepts only http and https URLs without embedded credentials, requires every resolved address to be public, and never follows redirects (a 3xx is a failed delivery). WEBHOOK_ALLOWED_PRIVATE_HOSTS names exact hosts that may resolve privately, for receivers reached over a LAN. Stored delivery errors carry only the refusal reason or the exception class.
59 lines
2.3 KiB
Python
59 lines
2.3 KiB
Python
import os
|
|
|
|
|
|
def _get_bool_env(name: str, default: bool = False) -> bool:
|
|
value = os.getenv(name)
|
|
if value is None or value == "":
|
|
return default
|
|
return value.strip().lower() in {"1", "true", "yes", "on"}
|
|
|
|
|
|
def _get_env(name: str, default: str | None = None) -> str:
|
|
value = os.getenv(name, default)
|
|
if value is None or value == "":
|
|
raise RuntimeError(f"Missing required environment variable: {name}")
|
|
return value
|
|
|
|
|
|
DATABASE_URL = _get_env("DATABASE_URL")
|
|
|
|
API_KEYS = [
|
|
key.strip()
|
|
for key in os.getenv("API_KEYS", "").split(",")
|
|
if key.strip()
|
|
]
|
|
|
|
API_KEY_ENCRYPTION_KEY = _get_env("API_KEY_ENCRYPTION_KEY")
|
|
INVOICE_RECONCILE_INTERVAL_SECONDS = int(os.getenv("INVOICE_RECONCILE_INTERVAL_SECONDS", "30"))
|
|
INVOICE_DEFAULT_EXPIRY_HOURS = int(os.getenv("INVOICE_DEFAULT_EXPIRY_HOURS", "1"))
|
|
LATE_PAYMENT_LOOKBACK_HOURS = int(os.getenv("LATE_PAYMENT_LOOKBACK_HOURS", "48"))
|
|
DONATION_EXPIRY_MINUTES = int(os.getenv("DONATION_EXPIRY_MINUTES", "30"))
|
|
DONATION_ACTIVE_INVOICE_LIMIT = int(os.getenv("DONATION_ACTIVE_INVOICE_LIMIT", "25"))
|
|
RATE_PROVIDER = os.getenv("RATE_PROVIDER", "kraken")
|
|
DONATIONS_ENABLED = _get_bool_env("DONATIONS_ENABLED", False)
|
|
OPEN_REGISTRATION = _get_bool_env("OPEN_REGISTRATION", True)
|
|
|
|
MONERO_WALLET_RPC_URLS = [
|
|
url.strip()
|
|
for url in os.getenv("MONERO_WALLET_RPC_URLS", "").split(",")
|
|
if url.strip()
|
|
]
|
|
MONERO_WALLET_RPC_USER = os.getenv("MONERO_WALLET_RPC_USER", "")
|
|
MONERO_WALLET_RPC_PASSWORD = os.getenv("MONERO_WALLET_RPC_PASSWORD", "")
|
|
MONERO_WALLET_RPC_WALLET_PASSWORD = os.getenv("MONERO_WALLET_RPC_WALLET_PASSWORD", "")
|
|
MONERO_DAEMON_URL = os.getenv("MONERO_DAEMON_URL")
|
|
MONERO_WALLET_RPC_WALLET_DIR = os.getenv("MONERO_WALLET_RPC_WALLET_DIR", "")
|
|
FOUNDER_PAYMENT_ADDRESS = os.getenv("FOUNDER_PAYMENT_ADDRESS", "")
|
|
FOUNDER_VIEW_KEY = os.getenv("FOUNDER_VIEW_KEY", "")
|
|
QR_STORAGE_DIR = os.getenv("QR_STORAGE_DIR", "/qr")
|
|
ADMIN_API_KEY = os.getenv("ADMIN_API_KEY", "").strip()
|
|
|
|
# Webhook targets must resolve to public addresses. Hostnames listed here may
|
|
# resolve to private addresses, for a merchant receiver reached over a LAN.
|
|
# Exact hostnames, comma separated; empty refuses every private target.
|
|
WEBHOOK_ALLOWED_PRIVATE_HOSTS = frozenset(
|
|
host.strip().lower().rstrip(".")
|
|
for host in os.getenv("WEBHOOK_ALLOWED_PRIVATE_HOSTS", "").split(",")
|
|
if host.strip()
|
|
)
|