From 74675fae945e885fb8053724d1ebae5c005e579d Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 25 Jul 2025 18:42:31 +0000 Subject: [PATCH] settings: Use get_secret for altcha_hmac. When building tarballs, we do not have development secrets. --- zerver/views/registration.py | 4 ++-- zproject/computed_settings.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/views/registration.py b/zerver/views/registration.py index f804305859..28d5e782f2 100644 --- a/zerver/views/registration.py +++ b/zerver/views/registration.py @@ -1269,7 +1269,7 @@ def create_realm(request: HttpRequest, creation_key: str | None = None) -> HttpR # When settings.OPEN_REALM_CREATION is enabled, anyone can create a new realm, # with a few restrictions on their email address. if request.method == "POST": - if settings.USING_CAPTCHA: + if settings.USING_CAPTCHA and settings.ALTCHA_HMAC_KEY: form: RealmCreationForm = CaptchaRealmCreationForm(data=request.POST, request=request) else: form = RealmCreationForm(request.POST) @@ -1343,7 +1343,7 @@ def create_realm(request: HttpRequest, creation_key: str | None = None) -> HttpR initial_data = { "realm_default_language": default_language_code, } - if settings.USING_CAPTCHA: + if settings.USING_CAPTCHA and settings.ALTCHA_HMAC_KEY: form = CaptchaRealmCreationForm(request=request, initial=initial_data) else: form = RealmCreationForm(initial=initial_data) diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py index c2bc31f7bc..ee349f80a7 100644 --- a/zproject/computed_settings.py +++ b/zproject/computed_settings.py @@ -469,7 +469,7 @@ else: TOR_EXIT_NODE_FILE_PATH = "/var/lib/zulip/tor-exit-nodes.json" if USING_CAPTCHA: - ALTCHA_HMAC_KEY = get_mandatory_secret("altcha_hmac") + ALTCHA_HMAC_KEY = get_secret("altcha_hmac") else: ALTCHA_HMAC_KEY = ""