nexusagent-redis commited on
Commit
1c7fa67
·
1 Parent(s): b2ef754

Correct Basic Auth configuration in entrypoint.sh and remove workers warning

Browse files
Files changed (1) hide show
  1. entrypoint.sh +14 -13
entrypoint.sh CHANGED
@@ -68,25 +68,26 @@ redis-server --dir /data --dbfilename dump.rdb --save 60 1 --protected-mode no &
68
  echo "[SAOS BOOT] Launching background backup & Git-Archiver sync daemon..."
69
  python3 -u /app/backup.py > /var/log/backup.log 2>&1 &
70
 
71
- # 5. Inject NANCY_REDIS_SECRET into webdis.json basic auth
72
- if [ -n "$NANCY_REDIS_SECRET" ]; then
73
- echo "[SAOS BOOT] Securing Webdis endpoint using custom Basic Auth credential secrets..."
74
- # Format: Basic Authentication username=nancy_admin, password=NANCY_REDIS_SECRET
75
- # We replace webdis.json basic auth settings. In Webdis, basic auth is configured via HTTP Basic Auth in headers or JSON-RPC.
76
- # To implement Basic Auth in Webdis, we add the basic_auth array inside webdis.json!
77
- # Webdis supports "http_basic_auth": ["user:password"] at root level.
78
- # Let's dynamically patch webdis.json to inject the credentials!
79
- python3 -c "
80
  import os, json
81
  with open('/app/webdis.json', 'r') as f:
82
  data = json.load(f)
83
- data['http_basic_auth'] = [f'nancy_admin:{os.getenv(\"NANCY_REDIS_SECRET\")}']
 
 
 
 
 
 
 
 
 
 
84
  with open('/app/webdis.json', 'w') as f:
85
  json.dump(data, f, indent=2)
86
  "
87
- else
88
- echo "[WARNING] NANCY_REDIS_SECRET missing! Webdis REST server is running unsecured!"
89
- fi
90
 
91
  # 6. Boot Webdis REST Gateway in the foreground to keep the Hugging Face container alive
92
  echo "[SAOS BOOT] Starting Webdis HTTP REST gateway on port 7860..."
 
68
  echo "[SAOS BOOT] Launching background backup & Git-Archiver sync daemon..."
69
  python3 -u /app/backup.py > /var/log/backup.log 2>&1 &
70
 
71
+ # 5. Secure Webdis configuration and clean unexpected parameters
72
+ echo "[SAOS BOOT] Cleaning configuration and securing Webdis REST gateway..."
73
+ python3 -c "
 
 
 
 
 
 
74
  import os, json
75
  with open('/app/webdis.json', 'r') as f:
76
  data = json.load(f)
77
+ if 'workers' in data:
78
+ del data['workers']
79
+ secret = os.getenv(\"NANCY_REDIS_SECRET\", \"\")
80
+ if secret:
81
+ print('[SAOS BOOT] Injecting custom Basic Auth credentials into Webdis ACL.')
82
+ for entry in data.get(\"acl\", []):
83
+ if entry.get(\"http_profile\") == \"nancy_admin\":
84
+ del entry[\"http_profile\"]
85
+ entry[\"http_basic_auth\"] = f\"nancy_admin:{secret}\"
86
+ else:
87
+ print('[WARNING] NANCY_REDIS_SECRET missing! Webdis REST server is running unsecured!')
88
  with open('/app/webdis.json', 'w') as f:
89
  json.dump(data, f, indent=2)
90
  "
 
 
 
91
 
92
  # 6. Boot Webdis REST Gateway in the foreground to keep the Hugging Face container alive
93
  echo "[SAOS BOOT] Starting Webdis HTTP REST gateway on port 7860..."