Authentication protects your Edge Server HTTP APIs by requiring clients to provide valid credentials. Edge Server uses API keys for authentication, combined with permission sets for authorization.Documentation Index
Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Edge Server authentication involves three components:- Identity: Defines who can access the API (with a credential like an API key)
- PermissionSet: Defines what actions are allowed
- HttpServer: Specifies which identities can authenticate
Generating API Keys
Use the Edge Server CLI to generate secure API keys:- Generated Private Key: The secret key that clients use to authenticate (keep this secure)
- Secure Public Hash: The base64-encoded hash to store in your configuration
Validating API Keys
To verify that an API key matches its hash:- Verifying credentials before deployment
- Troubleshooting authentication issues
Configuring Authentication
Step 1: Create a Permission Set
Define what actions authenticated clients can perform:Step 2: Create an Identity
Add the API key hash and reference the permission set:The
credential.api_key field contains the hash (not the original key). The original key is what clients send in HTTP requests.Step 3: Protect Your HTTP Server
Complete configuration with authentication:Using API Keys in HTTP Requests
Clients authenticate by including the API key in theAuthorization header:
Authorization: Bearer <your-api-key>
Multiple Identities
You can configure multiple identities with different API keys:Disabling Authentication (Not Recommended)
To disable authentication entirely:Best Practices
Key Generation
- Use the CLI: Always generate keys using
ditto-edge-server api-key generaterather than creating them manually - One key per client: Generate unique API keys for each client or service
- Validate before deploying: Use
ditto-edge-server api-key validateto verify keys work before updating production configs
Key Storage
- Store keys securely: Use environment variables, secrets managers, or secure vaults for API keys
- Never commit keys: Don’t commit API keys to version control (add them to
.gitignore)
Key Rotation
To rotate an API key:- Generate a new key:
ditto-edge-server api-key generate - Create a new Identity with the new hash
- Add the new Identity to the HTTP server’s
authlist (keeping the old one temporarily) - Update clients to use the new key
- Verify clients are using the new key
- Remove the old Identity from the
authlist - Restart Edge Server to apply changes
Access Control
- Use descriptive IDs: Give identities meaningful
idvalues for audit logs (e.g.,"production-api","monitoring-service") - Separate permission sets: Create distinct permission sets for different roles (even if they currently have the same permissions)
- Principle of least privilege: Plan to grant minimum necessary permissions when granular controls become available
Troubleshooting
Authentication Fails
If clients receive 401 Unauthorized errors:- Verify the key is correct: Use
ditto-edge-server api-key validateto check the key matches the hash - Check the Identity resource ID: Ensure the HTTP server’s
authlist references the correct Identity resource name - Verify the header format: Ensure the request uses
Authorization: Bearer <key>format - Check Edge Server logs: Look for authentication-related errors in the server logs
Key Validation Fails
Ifditto-edge-server api-key validate reports the key is invalid:
- Check for whitespace: Ensure there’s no extra whitespace in the key or hash
- Verify the hash format: Hashes should be base64-encoded strings starting with the algorithm identifier
- Regenerate if needed: If unsure, generate a new key-hash pair and update your configuration