99
1010
1111class 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
89101settings = Settings () # type: ignore[call-arg]
0 commit comments