Fix security vulnerabilities. Add logging
This commit is contained in:
51
README.md
51
README.md
@@ -109,15 +109,46 @@ data/
|
||||
|
||||
## Configuration
|
||||
|
||||
All settings are read from environment variables.
|
||||
All settings are read from environment variables (centralised in `src/core/config.py`).
|
||||
|
||||
### Security
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `SECRET_KEY` | Random 32 bytes | JWT signing key and Fernet encryption key. **Set this explicitly in production.** |
|
||||
| `ADMIN_USERNAME` | `admin` | Username for the initial admin account |
|
||||
| `ADMIN_PASSWORD` | *(none)* | Password for the initial admin account. If unset, no seed account is created. |
|
||||
| `APP_PORT` | `8000` | HTTP port the server listens on |
|
||||
| `DATABASE_URL` | `sqlite:///data/gates.db` | SQLAlchemy database URL |
|
||||
| `SECRET_KEY` | *(required)* | JWT signing key and Fernet encryption key. The application will refuse to start if this is not set. Use a long random string (`openssl rand -hex 32`). |
|
||||
|
||||
### Admin seed account
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `ADMIN_USERNAME` | `admin` | Username for the initial admin account created on first run. |
|
||||
| `ADMIN_PASSWORD` | *(none)* | Password for the initial admin account. If unset, no seed account is created. Minimum 12 characters. |
|
||||
|
||||
### Server
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `APP_PORT` | `8000` | HTTP port the server listens on. |
|
||||
|
||||
### Database
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `DATABASE_URL` | `sqlite:///data/gates.db` | SQLAlchemy database URL. |
|
||||
|
||||
### Network / reverse proxy
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `CORS_ORIGINS` | *(empty — no cross-origin requests)* | Comma-separated list of allowed CORS origins, e.g. `https://gates.example.com`. |
|
||||
| `TRUSTED_PROXY_IPS` | `127.0.0.1` | Comma-separated list of reverse-proxy IPs whose `X-Forwarded-For` header is trusted for client IP resolution. |
|
||||
|
||||
### Logging
|
||||
|
||||
| Variable | Default | Description |
|
||||
|---|---|---|
|
||||
| `LOG_LEVEL` | `INFO` | Logging verbosity. One of `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`. |
|
||||
| `LOG_FILE` | `/var/log/lagomaregates.log` | Path to the rotating log file (10 MB, 5 backups). Set to an empty string to disable file logging. |
|
||||
|
||||
## Running with Docker Compose
|
||||
|
||||
@@ -126,7 +157,7 @@ All settings are read from environment variables.
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
The default `docker-compose.yml` starts the service on port `8000` with the initial admin credentials `admin` / `changeme`. Change `ADMIN_PASSWORD` and set a strong `SECRET_KEY` before deploying.
|
||||
The default `docker-compose.yml` starts the service on port `8000`. Set a strong `SECRET_KEY` and, optionally, `ADMIN_USERNAME` / `ADMIN_PASSWORD` before deploying.
|
||||
|
||||
The `./data` directory is mounted into the container so the SQLite database persists across restarts.
|
||||
|
||||
@@ -137,11 +168,11 @@ python -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
export SECRET_KEY="change-me"
|
||||
export SECRET_KEY="$(openssl rand -hex 32)"
|
||||
export ADMIN_USERNAME="admin"
|
||||
export ADMIN_PASSWORD="changeme"
|
||||
export ADMIN_PASSWORD="changeme-at-least-12"
|
||||
|
||||
uvicorn src.main:app --reload --port 8000
|
||||
uvicorn src.main:app --port 8000
|
||||
```
|
||||
|
||||
The application is then available at:
|
||||
|
||||
Reference in New Issue
Block a user