Track and visualize shared IP addresses from Keycloak sessions.
Current config uses GCP hosted PostgreSQL but can be refactored to use other databases.
For GCP setup:
gcloud auth login --update-adc# Setup your venv
python3 -m venv .venv
source .venv/bin/activate.fish
# Install dependencies
pip install -r requirements.txt
# Run
./run.shVisit: http://localhost:8000
- Scheduler - Collects IP data from Keycloak every hour
- Geolocation - Fetches location data (1 req/sec, skips already-fetched IPs)
- Web UI - Shows heatmap with statistics
scheduler.py- Background data collectionweb.py- Web interfacedatabase.py- SQLite operationstemplates/- HTML templatesstatic/- CSS files
Create your .env file with:
DB_INSTANCE_CONNECTION_NAME=your-instance
DB_NAME=your-database
DB_USER=your-user
DB_PASSWORD=your-password
DB_SCHEMA=your-schema
KC_REALM_ID=your-realm-id
This script can be deployed as a sidecar container alongside Keycloak. However, a refactoring of environment variables is needed to match secrets consumed by Keycloak (e.g., using Kubernetes secrets/ConfigMaps instead of .env file).
