Authentication flow
- Client obtains a JWT token from an identity provider (e.g., Auth0, Keycloak, Cognito)
- Client includes the token in gRPC metadata:
Authorization: Bearer <token> - Gateway validates the token signature and claims
- Gateway checks required scopes and namespace access
- If authorized, gateway processes the request
Enabling authentication
Setlemline.gateway.authentication.enabled=true in your configuration:
.lemline.yaml
Configuration parameters
Enable JWT authentication. When
false, all requests are allowed.JWT issuer URL. Must match the
iss claim in tokens.Example: https://auth.example.com/JWT audience. Must match the
aud claim in tokens.Example: lemline-api, https://api.example.comPEM-encoded RSA public key for verifying token signatures. Supports RSA256, RSA384, RSA512.
Authorization model
The gateway uses scope-based and namespace-based authorization:Required scopes
Each RPC requires specific scopes in the JWTscope claim:
| RPC | Required Scope | Description |
|---|---|---|
StartWorkflow | workflow:start | Start workflow instances |
WatchWorkflow | workflow:watch | Stream workflow events |
ListNamespaces | workflow:read | List namespaces |
ListDefinitions | workflow:read | List workflow definitions |
GetDefinition | workflow:read | Get workflow definition |
GetDefinitionStats | workflow:read | Get workflow statistics |
ListInstances | workflow:read | List workflow instances |
GetInstanceTimeline | workflow:read | Get instance timeline |
WatchDefinitionStats | workflow:read | Stream definition stats |
WatchInstances | workflow:read | Stream instance updates |
Namespace access
JWT tokens can restrict access to specific namespaces using thenamespaces claim:
JWT payload
- If
namespacesis present, user can only access those namespaces - If
namespacesis absent, user can access all namespaces (admin access)
Example JWT payloads
Admin user (all namespaces)
Production-only user
Read-only user
Client examples
Using grpcurl with JWT
Using TypeScript (Connect-ES)
Using Python (grpcio)
TLS/SSL configuration
In production, combine JWT authentication with TLS encryption:.lemline.yaml
Error responses
Missing or invalid JWT token
Token lacks required scopes or namespace access
Troubleshooting
Token validation fails
Token validation fails
Symptoms:
UNAUTHENTICATED errors even with valid-looking tokensCheck:- Verify
issuerandaudiencematch JWT claims exactly - Ensure public key is PEM-encoded and matches the signing key
- Check token expiration (
expclaim) - Verify algorithm (RSA256/384/512 supported, not HS256)
Namespace access denied
Namespace access denied
Symptoms:
PERMISSION_DENIED for specific namespacesCheck:- Verify
namespacesclaim includes the target namespace - If no
namespacesclaim, user should have admin access - Ensure namespace name matches exactly (case-sensitive)
Scope errors
Scope errors
Symptoms:
PERMISSION_DENIED: Insufficient scopesCheck:- Verify
scopeclaim includes required scope (e.g.,workflow:start) - Scopes are space-separated in the JWT claim
- Scope names are case-sensitive
Best practices
Use short-lived tokens
Set token expiration (
exp) to 1 hour or less for better securityRotate signing keys
Periodically rotate JWT signing keys and update gateway public key
Principle of least privilege
Grant only required scopes and namespace access per user
Enable TLS in production
Always use TLS encryption with JWT authentication
Next steps
Gateway configuration
Full gateway configuration reference
Start workflows
Start workflow instances via API
TLS setup
Configure TLS encryption
Gateway CLI
Gateway command-line reference