A FastAPI-based web server that updates IP addresses in environment files based on authenticated requests.
- Validates users against a predefined list
- Updates IP addresses in a specified .env file
- Executes a post-update script after successful updates
- Uses FastAPI for modern, async web handling
- Python 3.9 or higher
- uv package manager
- Clone the repository
- Install dependencies using uv:
uv venv source .venv/bin/activate # On Unix/macOS # or .venv\Scripts\activate # On Windows uv pip install -e .
Copy .env.example to .env and configure the following variables:
VALID_USERS: Comma-separated list of valid usernamesENV_FILE_PATH: Path to the .env file to updatePOST_UPDATE_SCRIPT: Path to the post-update script to execute
Start the server:
uvicorn update_ip_endpoint.main:app --host 0.0.0.0 --port 8000Updates the IP address for a validated user.
Headers:
X-Token-User-Name: Username to validateX-Forwarded-For: Client IP address
Response:
{
"status": "success",
"message": "Updated IP for username"
}This project uses Ruff for linting and formatting. To run the linter:
ruff check .To format code:
ruff format .