๐ Supernal TTS Security Documentation
Overviewโ
This document outlines the security measures implemented in the Supernal TTS API to ensure safe, reliable, and compliant operation in production environments.
Table of Contentsโ
- Authentication & Authorization
- Rate Limiting
- Input Validation
- Security Headers
- Data Protection
- Deployment Security
- Security Checklist
Authentication & Authorizationโ
API Key Authenticationโ
The API uses Bearer token authentication with API keys prefixed with sk-tts-:
curl -X POST https://api.supernal-tts.com/v1/generate \
-H "Authorization: Bearer sk-tts-xxxxx" \
-H "Content-Type: application/json" \
-d '{"text": "Hello world"}'
API Key Features:โ
- Bcrypt hashing: Keys are hashed with bcrypt (10 rounds) before storage
- Scopes: Each key has configurable scopes (read, write, admin)
- Rate limits: Per-key rate limiting
- Expiration: Optional expiration dates
- Usage tracking: Last used timestamp
Creating API Keys (Development):โ
// Set CREATE_TEST_KEYS=true in development
// Keys will be printed to console on startup
JWT Authenticationโ
Alternative authentication using JWT tokens:
curl -X POST https://api.supernal-tts.com/v1/generate \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
-H "Content-Type: application/json" \
-d '{"text": "Hello world"}'
JWT Features:โ
- Standard JWT with HS256 signing
- Contains user ID, email, and roles
- Configurable expiration
- Role-based access control
Development Modeโ
For development, authentication can be disabled:
REQUIRE_AUTH=false npm start
Rate Limitingโ
Tiered Rate Limitingโ
Different rate limits for different scenarios:
| Tier | Limit | Window | Use Case |
|---|---|---|---|
| Global | 100 req/min | 60s | Per IP address |
| Authenticated | 1000 req/min | 60s | Per API key |
| Generation | 10 req/min | 60s | TTS generation |
| Strict | 10 req/min | 60s | Unauthenticated |
Rate Limit Headersโ
All responses include rate limit information:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 2024-01-01T00:01:00Z
Retry-After: 60
Redis Supportโ
For distributed rate limiting across multiple instances:
REDIS_URL=redis://localhost:6379 npm start
Bypassing Rate Limitsโ
Admin users automatically bypass rate limits. Custom rate limits can be set per API key.