QUICK START
Get GuardFlow running in your FastAPI application in 3 simple steps.
INSTALL SDK
pip install guardflow-fastapiSTART REDIS
docker run -d -p 6379:6379 redis:alpineADD MIDDLEWARE
See code below →
COMPLETE EXAMPLE
from fastapi import FastAPI
from guardflow import GuardFlowMiddleware
app = FastAPI()
# Add GuardFlow protection
app.add_middleware(
GuardFlowMiddleware,
api_key="gf_live_your_api_key",
studio_url="https://guardflow-v1.onrender.com",
redis_url="redis://localhost:6379"
)
@app.get("/")
async def protected_endpoint():
return {"message": "Protected by GuardFlow"}INSTALLATION
SYSTEM REQUIREMENTS
INSTALL FROM PYPI
pip install guardflow-fastapiOr with development dependencies:
pip install "guardflow-fastapi[dev]"DOCKER COMPOSE SETUP
version: '3.8'
services:
redis:
image: redis:7-alpine
container_name: guardflow_cache
ports:
- "6379:6379"
volumes:
- redis_data:/data
app:
build: .
ports:
- "8000:8000"
depends_on:
- redis
environment:
- GUARDFLOW_API_KEY=gf_live_your_api_key
- GUARDFLOW_REDIS_URL=redis://redis:6379
volumes:
redis_data:SECURITY FEATURES
DNA FINGERPRINTING
Identifies attackers by their unique request patterns. Analyzes header sequences, presence vectors, and protocol behaviors.
ZERO-LATENCY
Async "fire & forget" telemetry ensures your application performance is never impacted by security processing.
PII REDACTION
Automatically detects and redacts sensitive data before telemetry leaves your infrastructure. GDPR compliant.
HONEYPOT TRAPS
Invisible endpoints that trigger instant global bans when accessed. Catches reconnaissance and automated attacks.
HOW DNA FINGERPRINTING WORKS
Traditional security looks at what attackers send. GuardFlow analyzes how they send it.
# Example: Two identical requests, different DNA
Request A: User-Agent → Accept → Accept-Language → Connection
Request B: Accept → User-Agent → Connection → Accept-Language
# Result: Completely different fingerprints
Fingerprint A: sha256("UA|AC|AL|CN") = "a1b2c3..."
Fingerprint B: sha256("AC|UA|CN|AL") = "x9y8z7..."CONFIGURATION
BASIC CONFIGURATION
from fastapi import FastAPI
from guardflow import GuardFlowMiddleware
app = FastAPI()
app.add_middleware(
GuardFlowMiddleware,
# Required Settings
api_key="gf_live_your_api_key",
studio_url="https://guardflow-v1.onrender.com",
redis_url="redis://localhost:6379",
# Security Configuration
block_threshold=80, # Threat score 0-100
enable_fingerprinting=True, # DNA identification
enable_honeypots=True, # Deception traps
# Privacy Configuration
redact_pii=True, # Smart PII redaction
redact_headers=[
"Authorization",
"Cookie",
"X-API-Key"
],
# Performance Configuration
async_reporting=True, # Zero-latency telemetry
rate_limit_window=60, # Seconds
rate_limit_max_requests=100, # Per window
)ENVIRONMENT VARIABLES
# .env file
GUARDFLOW_API_KEY=gf_live_your_api_key
GUARDFLOW_STUDIO_URL=https://guardflow-v1.onrender.com
GUARDFLOW_REDIS_URL=redis://localhost:6379
GUARDFLOW_BLOCK_THRESHOLD=80
GUARDFLOW_ENABLE_FINGERPRINTING=true
GUARDFLOW_ENABLE_HONEYPOTS=true
GUARDFLOW_REDACT_PII=trueADVANCED CONFIGURATION
from guardflow import GuardFlowMiddleware
from guardflow.fingerprint import CustomFingerprinter
# Custom fingerprinting rules
fingerprinter = CustomFingerprinter()
fingerprinter.add_header_weight("X-Custom-Header", 0.8)
fingerprinter.add_pattern_rule(r"bot|crawler", threat_boost=0.3)
app.add_middleware(
GuardFlowMiddleware,
api_key="gf_live_your_api_key",
studio_url="https://guardflow-v1.onrender.com",
redis_url="redis://localhost:6379",
# Custom fingerprinter
fingerprinter=fingerprinter,
# Redis clustering
redis_cluster=True,
redis_ssl=True,
# Webhook integration
webhook_url="https://your-app.com/security-webhook",
webhook_events=["high_threat", "honeypot_trigger"],
)DEPLOYMENT
DOCKERFILE
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]KUBERNETES
apiVersion: apps/v1
kind: Deployment
metadata:
name: fastapi-app
spec:
replicas: 3
template:
spec:
containers:
- name: app
image: your-app:latest
ports:
- containerPort: 8000
env:
- name: GUARDFLOW_API_KEY
valueFrom:
secretKeyRef:
name: guardflow-secrets
key: api-keyBEST PRACTICES
READY TO PROTECT YOUR APP?
Join thousands of developers using GuardFlow to secure their FastAPI applications.
NO CREDIT CARD • 100K REQUESTS/MONTH FREE • CANCEL ANYTIME