| title | Security |
|---|---|
| description | Gateway authentication, Runbeam Cloud authorisation, and secret handling. |
| status | active |
| updated | 2026-10-24 |
| type | Security |
JWT authentication for gateway middleware:
- Prefer RS256 with an RSA public key (PEM). Do not use HS256 in production
- Enforce algorithm strictly; never accept a token signed with a different algorithm
- Validate exp, nbf, iat with minimal leeway (e.g., 60 seconds)
- Validate iss and aud where applicable
- Map all verification failures to HTTP 401 Unauthorized
- Startup safety: the middleware panics if RS256 keys are missing and HS256 is not explicitly enabled
The Management API /authorize endpoint uses a different JWT flow for authorizing Harmony with Runbeam Cloud:
- User Authentication: The user runs
runbeam loginand receives a JWT. - Token Validation: Harmony validates the JWT with RS256 only. It reads the
kidfrom the token header and the issuer from theissclaim. It fetches the signing key from the JWKS endpoint at the issuer's base URL and caches it forproxy.jwks_cache_duration_hours. It then checks the signature and expiry. Harmony passes no trusted issuer list, so the SDK accepts a token from any issuer whose JWKS it can fetch. It logs a security warning when it does this. - Token Exchange: Harmony calls the Runbeam Cloud API to exchange the user JWT for a machine-scoped token. It uses the
apiURL of the primary provider. - Token Storage: Harmony stores the machine token, encrypted, at
~/.runbeam/<proxy_id>/runbeam/auth.json.
No shared secret is involved. Harmony needs network access to the issuer's JWKS endpoint.
- Token Storage: Machine tokens are stored encrypted in JSON format
- Path:
~/.runbeam/<proxy_id>/runbeam/auth.json - Contains: machine_token, expires_at, gateway_id, abilities, issued_at (encrypted with age X25519)
- File permissions: the SDK does not set them. It sets 0600 only on a generated
encryption.key. Restrict access to~/.runbeamyourself.
- Path:
- Encryption Key: To keep the stored token across container restarts, set
RUNBEAM_ENCRYPTION_KEYand put~/.runbeamon a persistent volume. See Managing Secrets. - Never hardcode secrets in configuration files
- Expiry: Machine tokens expire after 30 days (configured server-side)
- Renewal: Must re-run
runbeam harmony:authorizebefore expiry - Revocation: Tokens can be revoked via Runbeam Cloud API
- Validation: Check
is_valid()method before using stored tokens
- Run Harmony with least-privilege user account
- Restrict network access to Management API (bind to 127.0.0.1)
- Use firewall rules to limit access to management port
- Rotate machine tokens regularly (before 30-day expiry)
- Monitor token usage via Runbeam Cloud dashboard
- Never log actual token values (only metadata)
- API Communication: All Runbeam Cloud API calls use HTTPS (in production)
- Token Transmission: JWT tokens only sent in Authorization headers
- Error Handling:
/authorizereturns the underlying error text to the client, for exampleInvalid or expired token: <details>andAuthorization failed: <details>. Restrict access to the management network. - Rate Limiting: Runbeam Cloud enforces rate limits on authorization endpoint
How to generate, store, rotate, and protect secret values. See Managing Secrets. For the full list of environment variables, see Environment Variables.
Example secure production deployments for Docker, Kubernetes, and AWS ECS, with an encryption key rotation procedure. See Production Deployment Security.