Add static API-key auth, dockerize service, publish façade docs
- sms/auth.py: verify_api_key dependency (Bearer/X-API-Key, SHA-256 hash compare via secrets.compare_digest, fail-closed 503 if no hash). All routes gated via a protected router; /health stays open for probes. - config.py: new sms_api_key_hash setting (VOIPMS_SMS_API_KEY_HASH). - Dockerfile + .dockerignore + docker-compose.yml: lean python:3.13-slim image; secrets injected via env_file, never baked in; host-localhost-only port mapping (SMS_PORT override); /health healthcheck. - .env.example: committed template (placeholders only, no secrets). - sms/docs/sms-facade.dokuwiki.txt: abstraction API reference (published to the apidoc wiki at voipms:sms-facade). - README: Authentication section, Docker section, 401/503 error rows. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
docker-compose.yml
Normal file
22
docker-compose.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
# voip.ms SMS/MMS API façade.
|
||||
# Secrets live in the host .env (gitignored) and are injected here via env_file;
|
||||
# they are never baked into the image.
|
||||
services:
|
||||
sms:
|
||||
build: .
|
||||
image: sms-api-wrapper:latest
|
||||
container_name: sms-api
|
||||
# Host-localhost only. To expose on the LAN, change to "8000:8000"
|
||||
# (access is still gated by the VOIPMS_SMS_API_KEY_HASH API key).
|
||||
# Override the host port with SMS_PORT (e.g. SMS_PORT=8001 in .env) if 8000 is taken.
|
||||
ports:
|
||||
- "127.0.0.1:${SMS_PORT:-8000}:8000"
|
||||
env_file:
|
||||
- .env
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health').read()"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
Reference in New Issue
Block a user