Code
Clone this repository
Search code…
Voight-Kampff Authentication Service
Voight-Kampff - Named after the empathy test from Philip K. Dick's "Do Androids Dream of Electric Sheep?" and the Blade Runner universe, this authentication service distinguishes between legitimate users and unauthorized entities through API key validation.
A standalone API key authentication service built with Flask and SQLite.
Overview
Voight-Kampff is a lightweight authentication service that provides:
- User management with web interface
- API key generation and validation
- Secure authentication system
- Administrative interface
- Integrated SQLite database
Installation and Quick Start
Prerequisites
- Docker
- Docker Compose
Getting Started
-
Clone or copy the voight-kampff directory
-
Configure the environment
cd voight-kampff cp .env.example .env -
Generate a secure secret key
python3 -c "import secrets; print(secrets.token_urlsafe(64))" -
Edit the .env file with your values
- Replace
VK_SECRET_KEYwith the generated key - Configure admin credentials (
VK_ADMIN_USERNAME,VK_ADMIN_PASSWORD,VK_ADMIN_EMAIL)
- Replace
-
Start the service
docker-compose up -d -
Access the service
- Web interface: http://localhost:8080
- Login with the configured admin credentials
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
VK_ADMIN_USERNAME |
Initial admin username | - |
VK_ADMIN_PASSWORD |
Initial admin password | - |
VK_ADMIN_EMAIL |
Initial admin email | - |
VK_SECRET_KEY |
Secret key for sessions | - |
VK_SESSION_EXPIRE_HOURS |
Session expiration duration | 24 |
VK_DB_PATH |
Database file path | /data/voight-kampff.db |
Volumes
./data:/data- SQLite database storage./config:/config- Configuration files (optional)
Usage
Web Interface
- Login with admin credentials
- Create users
- Generate API keys
- Manage permissions
API
The service exposes endpoints for:
- API key validation
- User management
- Authentication
Maintenance
Backup
# Backup the database
cp ./data/voight-kampff.db ./backups/voight-kampff-$(date +%Y%m%d).db
Logs
# View logs
docker-compose logs voight-kampff
# Follow logs in real-time
docker-compose logs -f voight-kampff
Updates
# Stop the service
docker-compose down
# Rebuild the image
docker-compose build
# Restart
docker-compose up -d
Security
- Use strong passwords for admin accounts
- Generate a unique secret key for each installation
- Regularly backup the database
- Monitor access logs
- Use HTTPS in production with a reverse proxy
Development
For local development:
# Install dependencies
pip install -r requirements.txt
# Configure environment variables
export VK_SECRET_KEY="your-secret-key"
export VK_ADMIN_USERNAME="admin"
# ... other variables
# Run the application
python app/main.py
Support
For issues or questions:
- Check logs with
docker-compose logs voight-kampff - Ensure all environment variables are configured
- Verify that port 8080 is not used by another service