Relay Security Architecture
Relay implements defense-in-depth security for enterprise deployments.
Control
Implementation
OAuth 2.1 with PKCE
Full implementation with S256 code challenges
JWT tokens
HS256 (dev) or RS256 (prod) with configurable expiry
JWKS endpoint
/oauth/jwks for asymmetric key verification
Session cookies
HttpOnly, Secure (prod), SameSite=Strict (prod)
Account lockout
Configurable max attempts + lockout duration
Password hashing
PBKDF2-HMAC-SHA256, 100K iterations
SSO/OIDC
Configurable via RELAY_OAUTH__SSO_* settings
Control
Implementation
Per-user token isolation
Each user's third-party tokens stored separately
Per-connector permissions
Granular tool-level access control
Patroclus integration
Fail-closed per-tool policy checks
Admin role
Separate admin role with elevated permissions
Access requests
Users request access; admins approve/deny
Control
Implementation
Encryption at rest
Fernet (AES-128-CBC) for stored tokens
Encryption in transit
TLS/SSL configurable, HSTS headers
Encryption key
Required in production via RELAY_ENCRYPTION_KEY
Control
Implementation
Rate limiting
Sliding window, Redis-backed for distributed deployments
CSRF protection
Double-submit cookie pattern for web UI forms
Security headers
CSP, X-Frame-Options, X-Content-Type-Options, HSTS
Input validation
Pattern-based injection detection, size limits
IP restrictions
Whitelist/blacklist with CIDR support
Control
Implementation
Audit logging
All security events logged (JSONL format)
Tamper-evidence
Hash-chained audit log entries
Sensitive field redaction
Passwords, tokens, keys redacted in logs
IP privacy
IP addresses SHA-256 hashed in logs
GDPR right-to-erasure
DELETE /auth/me with cascading data deletion
SOC2 alignment
Access controls, audit logging, encryption
Production Deployment Checklist
Revoke compromised tokens: POST /oauth/revoke
Rotate JWT secret and encryption key
Force re-authorization for all clients
Review audit logs for unauthorized access
Disable backend via admin UI or DELETE /admin/backends/{id}
Rotate backend credentials
Audit tool calls via logs
Notify affected users
Identify pattern in audit logs
Add IP to blacklist
Contact abuse team
Security issues: security@example.com