Skip to content

Commit c45f0db

Browse files
authored
Merge pull request #67 from mrsabath/slack-resercher-secret
✨ Read CLIENT_SECRET from a local file instead of Env. variable
2 parents 21bc50d + b8185e3 commit c45f0db

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • a2a/slack_researcher/slack_researcher

a2a/slack_researcher/slack_researcher/config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010

1111
class Settings(BaseSettings):
12+
# static path for client secret file
13+
secret_file_path: str = "/shared/secret.txt"
14+
1215
LOG_LEVEL: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] = Field(
1316
os.getenv("LOG_LEVEL", "DEBUG"),
1417
description="Application log level",
@@ -60,7 +63,7 @@ class Settings(BaseSettings):
6063
description="Client ID to authenticate to OAuth server"
6164
)
6265
CLIENT_SECRET: Optional[str] = Field(
63-
os.getenv("CLIENT_SECRET", None),
66+
None,
6467
description="Client secret to authenticate to OAuth server"
6568
)
6669
TARGET_AUDIENCE: Optional[str] = Field(
@@ -84,6 +87,15 @@ def validate_extra_headers(self) -> "Settings":
8487
except json.JSONDecodeError:
8588
raise ValueError("EXTRA_HEADERS must be a valid JSON string")
8689

90+
# --- Load CLIENT_SECRET from file ---
91+
try:
92+
with open(self.secret_file_path, "r") as f:
93+
self.CLIENT_SECRET = f.read().strip()
94+
except FileNotFoundError:
95+
logging.warning(f"CLIENT_SECRET file not found at {self.secret_file_path}")
96+
except Exception as e:
97+
logging.error(f"Error reading CLIENT_SECRET file: {e}")
98+
8799
return self
88100

89101
settings = Settings() # type: ignore[call-arg]

0 commit comments

Comments
 (0)