Authentication & Authorization
Switchyard uses a hybrid authentication approach combining the Switchyard framework with Supabase Auth, providing enterprise-grade security with Role-Based Access Control (RBAC).Architecture Overview
Key Components
| Component | Purpose |
|---|---|
| Supabase Auth | User authentication, session management, password reset |
| Supabase RBAC Tables | Roles, permissions, and their assignments |
| Switchyard Auth Provider | Bridge between Supabase and Switchyard’s auth system |
| Auth Middleware | Validates authentication on protected routes |
| Authorization Middleware | Checks permissions before allowing access |
Authentication Flows
Standard Login (Admin UI)
1
Enter Credentials
User enters email and password in the login form
2
Supabase Validates
Frontend calls Supabase Auth API which validates credentials and returns a JWT
3
Switchyard Session
Frontend calls Switchyard auth endpoint with the Supabase token, which creates a session
4
Authenticated Requests
Subsequent requests include the session cookie automatically
Bearer Token (API/Mobile)
For programmatic access:Service Account (Robots/Scripts)
For automated systems:Environment Variables
| Variable | Description | Required |
|---|---|---|
SUPABASE_URL | Your Supabase project URL | Yes |
SUPABASE_ANON_KEY | Public anon key for client-side auth | Yes |
SUPABASE_SERVICE_ROLE_KEY | Service role key for admin operations | Yes |
SUPABASE_JWT_SECRET | JWT secret for token verification | Optional |
Actor Types
The system supports multiple actor types:| Actor Type | Description | Auth Methods | Typical Use |
|---|---|---|---|
user | Admin users | supabase, emailpass | Admin dashboard |
customer | Store customers | emailpass | Storefront (future) |
api-key | API key auth | api-key | External integrations |