This is an automated email from the ASF dual-hosted git repository.

sbp pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git


The following commit(s) were added to refs/heads/main by this push:
     new e08a872  Allow setting a server key from secrets configuration
e08a872 is described below

commit e08a8726bd4276592f77bd73bda9d3fd8df2e268
Author: Sean B. Palmer <[email protected]>
AuthorDate: Wed Oct 8 20:12:00 2025 +0100

    Allow setting a server key from secrets configuration
---
 atr/config.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/atr/config.py b/atr/config.py
index b1da58f..ca6b0e5 100644
--- a/atr/config.py
+++ b/atr/config.py
@@ -31,7 +31,13 @@ def _config_secrets(key: str, state_dir: str, default: str | 
None = None, cast:
     try:
         repo_ini = decouple.RepositoryIni(secrets_path)
         config_obj = decouple.Config(repo_ini)
-        return config_obj.get(key, default=default, cast=cast)
+        sentinel = object()
+        value = config_obj.get(key, default=sentinel, cast=cast)
+        if value is sentinel:
+            return decouple.config(key, default=default, cast=cast)
+        if isinstance(value, str) or (value is None):
+            return value
+        return None
     except FileNotFoundError:
         return decouple.config(key, default=default, cast=cast)
 
@@ -54,7 +60,7 @@ class AppConfig:
     TEMPLATES_AUTO_RELOAD = False
     USE_BLOCKBUSTER = False
     JWT_SECRET_KEY = _config_secrets("JWT_SECRET_KEY", STATE_DIR, 
default=None, cast=str) or secrets.token_hex(128 // 8)
-    SECRET_KEY = decouple.config("SECRET_KEY", default=secrets.token_hex(128 
// 8))
+    SECRET_KEY = _config_secrets("SECRET_KEY", STATE_DIR, default=None, 
cast=str) or secrets.token_hex(128 // 8)
     WTF_CSRF_ENABLED = decouple.config("WTF_CSRF_ENABLED", default=True, 
cast=bool)
     DOWNLOADS_STORAGE_DIR = os.path.join(STATE_DIR, "downloads")
     FINISHED_STORAGE_DIR = os.path.join(STATE_DIR, "finished")


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to