This guide covers all configuration options for Subzero Zero Trust API Gateway.
Subzero supports multiple configuration methods (in order of precedence):
- Command-line arguments (highest priority)
- Environment variables
- Configuration file
- Default values (lowest priority)
export AUTH0_DOMAIN="your-tenant.auth0.com"
export AUTH0_CLIENT_ID="your_client_id"
export AUTH0_AUDIENCE="https://your-api"
export FGA_STORE_ID="your_fga_store_id"
python -m subzeroCreate subzero_config.py:
c = get_config()
# Authentication
c.Settings.AUTH0_DOMAIN = "your-tenant.auth0.com"
c.Settings.AUTH0_CLIENT_ID = "your_client_id"
c.Settings.AUTH0_AUDIENCE = "https://your-api"
# Performance
c.Settings.CACHE_CAPACITY = 20000
c.Settings.MAX_CONNECTIONS = 2000
# Security
c.Settings.ENABLE_BOT_DETECTION = True
c.Settings.THREAT_DETECTION_ENABLED = TrueRun with config:
python -m subzero --config=subzero_config.py- Type: String
- Required: Yes
- Environment:
SUBZERO_AUTH0_DOMAINorAUTH0_DOMAIN - Description: Auth0 tenant domain
- Example:
"your-tenant.auth0.com"
- Type: String
- Required: Yes
- Environment:
SUBZERO_AUTH0_CLIENT_IDorAUTH0_CLIENT_ID - Description: Auth0 client ID for the gateway application
- Example:
"abc123xyz"
- Type: String
- Required: No (for Private Key JWT)
- Environment:
SUBZERO_AUTH0_CLIENT_SECRETorAUTH0_CLIENT_SECRET - Description: Auth0 client secret (if using client credentials flow)
- Security: Never commit this value
- Type: String
- Required: Yes
- Environment:
SUBZERO_AUTH0_AUDIENCEorAUTH0_AUDIENCE - Description: API identifier (audience) for token validation
- Example:
"https://api.your-company.com"
- Type: String
- Required: No
- Environment:
AUTH0_MANAGEMENT_API_TOKEN - Description: Token for Auth0 Management API access
- Use case: Dynamic client registration, user management
- Type: String
- Required: Yes (if using FGA)
- Environment:
SUBZERO_FGA_STORE_IDorFGA_STORE_ID - Description: Auth0 FGA store identifier
- Example:
"01HXXX..."
- Type: String
- Required: Yes (if using FGA)
- Environment:
SUBZERO_FGA_CLIENT_IDorFGA_CLIENT_ID - Description: FGA client credentials
- Type: String
- Required: Yes (if using FGA)
- Environment:
SUBZERO_FGA_CLIENT_SECRETorFGA_CLIENT_SECRET - Description: FGA client secret
- Security: Never commit this value
- Type: String
- Required: No
- Default:
"https://api.us1.fga.dev" - Environment:
SUBZERO_FGA_API_URLorFGA_API_URL - Description: Auth0 FGA API endpoint
- Options:
"https://api.us1.fga.dev"(US)"https://api.eu1.fga.dev"(EU)"https://api.au1.fga.dev"(Australia)
- Type: Integer
- Default:
10000 - Environment:
SUBZERO_CACHE_CAPACITY - Description: Maximum number of items in memory cache
- Recommendation:
- Small: 5,000-10,000
- Medium: 10,000-50,000
- Large: 50,000-100,000
- Type: Integer
- Default:
1000 - Environment:
SUBZERO_MAX_CONNECTIONS - Description: Maximum concurrent connections
- Recommendation: Set to expected concurrent users × 1.5
- Type: Boolean
- Default:
True - Environment:
SUBZERO_ENABLE_MULTIPROCESSING - Description: Enable multi-core utilization for CPU-bound tasks
- Note: Set to
Falseif running in containers with CPU limits
- Type: Float
- Default:
30.0 - Environment:
SUBZERO_REQUEST_TIMEOUT - Description: Request timeout in seconds
- Recommendation: 5-30 seconds for APIs
- Type: String
- Required: No (in-memory cache used if not set)
- Default:
None - Environment:
SUBZERO_REDIS_URLorREDIS_URL - Description: Redis connection URL for distributed caching
- Format:
"redis://[user:password@]host:port/db" - Examples:
"redis://localhost:6379/0""redis://user:pass@redis.example.com:6379/0""rediss://redis.example.com:6380/0"(TLS)
- Type: String
- Required: No
- Environment:
SUBZERO_REDIS_PASSWORDorREDIS_PASSWORD - Description: Redis authentication password
- Security: Use strong password, never commit
- Type: Integer
- Default:
50 - Environment:
SUBZERO_REDIS_MAX_CONNECTIONS - Description: Maximum Redis connection pool size
- Type: Boolean
- Default:
True - Environment:
SUBZERO_ENABLE_BOT_DETECTION - Description: Enable ML-based bot detection
- Type: Boolean
- Default:
True - Environment:
SUBZERO_THREAT_DETECTION_ENABLED - Description: Enable advanced threat detection (fraud, ATO, etc.)
- Type: Boolean
- Default:
True - Environment:
SUBZERO_XAA_ENABLED - Description: Enable XAA protocol for AI agent authentication
- Type: Integer
- Default:
5 - Environment:
SUBZERO_XAA_MAX_DELEGATION_DEPTH - Description: Maximum token delegation chain depth
- Type: Boolean
- Default:
True - Environment:
SUBZERO_RATE_LIMIT_ENABLED - Description: Enable rate limiting
- Type: Integer
- Default:
100 - Environment:
SUBZERO_RATE_LIMIT_REQUESTS - Description: Requests per window per user
- Type: Integer
- Default:
60 - Environment:
SUBZERO_RATE_LIMIT_WINDOW - Description: Rate limit window in seconds
- Type: String
- Default:
"INFO" - Environment:
SUBZERO_LOG_LEVEL - Description: Logging level
- Options:
DEBUG,INFO,WARNING,ERROR,CRITICAL
- Type: String
- Default:
"json" - Environment:
SUBZERO_LOG_FORMAT - Description: Log output format
- Options:
"json"- Structured JSON (production)"text"- Human-readable (development)
- Type: String
- Required: No
- Environment:
SUBZERO_AUDIT_LOG_FILE - Description: Path to audit log file
- Example:
"/var/log/subzero/audit.log" - Note: Requires write permissions
- Type: Boolean
- Default:
True - Environment:
SUBZERO_PROMETHEUS_ENABLED - Description: Enable Prometheus metrics endpoint
- Type: Integer
- Default:
9090 - Environment:
SUBZERO_PROMETHEUS_PORT - Description: Prometheus metrics port
- Type: Boolean
- Default:
False - Environment:
SUBZERO_OTEL_ENABLED - Description: Enable OpenTelemetry tracing
- Type: String
- Required: If
OTEL_ENABLED=True - Environment:
SUBZERO_OTEL_ENDPOINT - Description: OpenTelemetry collector endpoint
- Example:
"http://otel-collector:4317"
- Type: String
- Default:
"0.0.0.0" - Environment:
SUBZERO_HOST - Description: Bind address for HTTP server
- Production: Use
"0.0.0.0"to accept connections from any interface
- Type: Integer
- Default:
8000 - Environment:
SUBZERO_PORT - Description: HTTP server port
- Type: Integer
- Default: CPU cores × 2
- Environment:
SUBZERO_WORKERS - Description: Number of worker processes (for production)
- Type: Boolean
- Default:
True - Environment:
SUBZERO_ENABLE_CORS - Description: Enable CORS support
- Type: String (comma-separated)
- Default:
"*" - Environment:
SUBZERO_ALLOWED_ORIGINS - Description: Allowed CORS origins
- Production: Set specific origins, not
"*" - Example:
"https://app.example.com,https://admin.example.com"
- Type: Boolean
- Default:
True(dev),False(prod) - Environment:
SUBZERO_ENABLE_SWAGGER_UI - Description: Enable Swagger UI at
/docs
- Type: Boolean
- Default:
True - Environment:
SUBZERO_ENABLE_HEALTH_CHECKS - Description: Enable health check endpoints (
/health,/ready)
# .env.development
AUTH0_DOMAIN=dev-tenant.auth0.com
LOG_LEVEL=DEBUG
LOG_FORMAT=text
ENABLE_SWAGGER_UI=True
CACHE_CAPACITY=1000# .env.staging
AUTH0_DOMAIN=staging-tenant.auth0.com
LOG_LEVEL=INFO
LOG_FORMAT=json
REDIS_URL=redis://staging-redis:6379/0
CACHE_CAPACITY=10000# .env.production
AUTH0_DOMAIN=prod-tenant.auth0.com
LOG_LEVEL=WARNING
LOG_FORMAT=json
REDIS_URL=rediss://prod-redis:6380/0
CACHE_CAPACITY=50000
MAX_CONNECTIONS=5000
WORKERS=8
ALLOWED_ORIGINS=https://app.example.com
ENABLE_SWAGGER_UI=False
PROMETHEUS_ENABLED=True
OTEL_ENABLED=TrueSubzero validates configuration on startup:
from subzero.config.defaults import Settings
# Load and validate configuration
settings = Settings()
# Check required fields
assert settings.AUTH0_DOMAIN, "AUTH0_DOMAIN is required"
assert settings.AUTH0_CLIENT_ID, "AUTH0_CLIENT_ID is required"Missing required configuration:
ValidationError: AUTH0_DOMAIN: Field required
Solution: Set the AUTH0_DOMAIN environment variable or in config file.
Redis connection failed:
ConnectionRefusedError: [Errno 111] Connection refused
Solution:
- Check Redis is running
- Verify
REDIS_URLis correct - Check network connectivity
Auth0 validation errors:
JWTError: Unable to verify token
Solution:
- Verify
AUTH0_DOMAINis correct - Check
AUTH0_AUDIENCEmatches token audience - Ensure token is not expired
-
Use environment variables in production
- Never commit secrets to version control
- Use secret management systems (Vault, AWS Secrets Manager)
-
Enable structured logging
- Use
LOG_FORMAT=jsonin production - Ship logs to centralized logging system
- Use
-
Configure Redis for production
- Use Redis for distributed caching
- Enable TLS (
rediss://) - Set authentication password
-
Tune performance settings
- Adjust
CACHE_CAPACITYbased on memory - Set
MAX_CONNECTIONSto expected load - Enable multiprocessing for CPU-bound tasks
- Adjust
-
Enable monitoring
- Use Prometheus for metrics
- Enable OpenTelemetry tracing
- Monitor cache hit ratios
Last updated: 2025-10-02