ubuntu593 commited on
Commit
b5d236b
·
verified ·
1 Parent(s): 96d4b52

Update api.py

Browse files

Remove default and static key

Files changed (1) hide show
  1. api.py +2 -3
api.py CHANGED
@@ -21,7 +21,6 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(level
21
  logger = logging.getLogger("API")
22
 
23
  # Securely load the key from Hugging Face environment variables, with a default fallback key
24
- DEFAULT_KEY = "autoalt-secret-key-2026"
25
  SECRET_KEY = os.getenv("AUTOALT_SECRET_KEY")
26
 
27
  def verify_key(
@@ -35,7 +34,7 @@ def verify_key(
35
  raise HTTPException(status_code=401, detail="Unauthorized: X-AutoAlt-Key header is missing")
36
 
37
  # Block if the header value does not match authorized keys
38
- authorized_keys = {k for k in [SECRET_KEY, DEFAULT_KEY, "testkey123"] if k}
39
  if token not in authorized_keys:
40
  raise HTTPException(status_code=403, detail="Forbidden: Invalid X-AutoAlt-Key")
41
 
@@ -233,7 +232,7 @@ def get_system_status(domain: Optional[str] = None):
233
  # If a domain is provided, we check its connectivity specifically
234
  stats = SystemMonitor.get_system_stats(target_url=domain)
235
  stats["auth_configured"] = bool(os.getenv("AUTOALT_SECRET_KEY"))
236
- stats["active_key_source"] = "Custom Hugging Face Secret" if os.getenv("AUTOALT_SECRET_KEY") else f"Default Secret ({DEFAULT_KEY})"
237
  return stats
238
 
239
  @app.post("/api/scanstart")
 
21
  logger = logging.getLogger("API")
22
 
23
  # Securely load the key from Hugging Face environment variables, with a default fallback key
 
24
  SECRET_KEY = os.getenv("AUTOALT_SECRET_KEY")
25
 
26
  def verify_key(
 
34
  raise HTTPException(status_code=401, detail="Unauthorized: X-AutoAlt-Key header is missing")
35
 
36
  # Block if the header value does not match authorized keys
37
+ authorized_keys = {k for k in [SECRET_KEY] if k}
38
  if token not in authorized_keys:
39
  raise HTTPException(status_code=403, detail="Forbidden: Invalid X-AutoAlt-Key")
40
 
 
232
  # If a domain is provided, we check its connectivity specifically
233
  stats = SystemMonitor.get_system_stats(target_url=domain)
234
  stats["auth_configured"] = bool(os.getenv("AUTOALT_SECRET_KEY"))
235
+ stats["active_key_source"] = "Custom Hugging Face Secret" if os.getenv("AUTOALT_SECRET_KEY") else f"Default Secret None"
236
  return stats
237
 
238
  @app.post("/api/scanstart")