Hybrid Authentication System
Design Philosophy: Support multiple authentication methods with a unified interface for route handlers.Authentication Methods
-
Clerk JWT Authentication (for web applications)
-
API Key Authentication (for machine-to-machine)
Authentication Flow Architecture
Middleware Application Pattern
Public Routes (no authentication):Request Context Pattern
After authentication, ALL route handlers receive:API Key Design
API Key Format:cgk_<8_hex_chars>_<16_hex_chars>
cgk_: Cloudgeni Key prefix- First part: Key identifier for database lookup
- Second part: Secret for validation
- API keys inherit permissions from their creator
- Actions are attributed to the real creator user
- Organization scope is enforced at the API key level
- Usage is logged for analytics and security