aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/config.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/config.py')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/config.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/config.py b/packages/meshbay-hub/src/meshbay_hub/config.py
index 39fdc52..e61e69e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/config.py
+++ b/packages/meshbay-hub/src/meshbay_hub/config.py
@@ -74,6 +74,13 @@ class CaptchaConfig:
# so the hostname Google sees is not the hub's and never can be. See
# docs/captcha.md ยง6.
allowed_hosts: list[str] = field(default_factory=list)
+ # A solve from a page Google cannot attribute to a domain reports an empty
+ # hostname โ€” `app://meshbay` does, measured live, and so does any other
+ # non-web client. No `allowed_hosts` entry can match that, and a blank
+ # entry is not the answer: the parser drops blanks because in a TOML list
+ # a blank is a typo far more often than an intention. Hence a named flag,
+ # which also states the trade at the place it is made.
+ allow_unattributed_host: bool = False
@property
def enabled(self) -> bool:
@@ -122,6 +129,8 @@ def load_config(path: Path | None = None) -> HubConfig:
cfg.captcha.secret_key = cap.get("secret_key", cfg.captcha.secret_key)
if hosts := cap.get("allowed_hosts"):
cfg.captcha.allowed_hosts = [str(h).strip() for h in hosts if str(h).strip()]
+ if "allow_unattributed_host" in cap:
+ cfg.captcha.allow_unattributed_host = bool(cap["allow_unattributed_host"])
break
# Env var overrides
@@ -143,5 +152,7 @@ def load_config(path: Path | None = None) -> HubConfig:
cfg.captcha.secret_key = captcha_secret
if captcha_hosts := os.environ.get("MESHBAY_CAPTCHA_ALLOWED_HOSTS"):
cfg.captcha.allowed_hosts = [h.strip() for h in captcha_hosts.split(",") if h.strip()]
+ if unattributed := os.environ.get("MESHBAY_CAPTCHA_ALLOW_UNATTRIBUTED_HOST"):
+ cfg.captcha.allow_unattributed_host = unattributed.lower() in ("1", "true", "yes")
return cfg