The Eryph Ruby Client uses OAuth2 with JWT assertions for authentication. This guide covers how to set up and configure authentication for different environments.
Eryph uses OAuth2 client credentials flow with JWT assertions for API authentication. The Ruby client automatically discovers and uses configured credentials from multiple sources.
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────────┐
│ Configuration │ │ Private Key │ │ JWT Assertion │
│ Discovery │───▶│ Signing │───▶│ Token Exchange │
│ │ │ │ │ │
│ • Multi-store │ │ • RSA signing │ │ • Access token │
│ • Auto-detect │ │ • Client claims │ │ • Token refresh │
└─────────────────┘ └──────────────────┘ └─────────────────────┘
The client searches for credentials in this order:
- Current Directory:
./.eryph/{config_name}.config - User Store: Platform-specific user directory
- Windows:
%APPDATA%\.eryph\ - Unix:
~/.config/.eryph/
- Windows:
- System Store: Platform-specific system directory
- Windows:
%PROGRAMDATA%\.eryph\ - Unix:
/etc/.eryph/
- Windows:
First, create a client in your Eryph Identity instance:
# Using Eryph PowerShell (if available)
New-EryphClient -Name "my-ruby-client" -Description "Ruby API Client"
# Or using the Identity API directlyThis will generate:
- Client ID
- RSA private key (PEM format)
- Client certificate (for reference)
Create a configuration file in JSON format:
Windows Example (%APPDATA%\.eryph\default.config):
{
"version": "1.0",
"identity": {
"endpoint": "https://identity.mycompany.com"
},
"compute": {
"endpoint": "https://compute.mycompany.com"
},
"clients": [
{
"id": "client-id-from-identity",
"name": "my-ruby-client",
"private_key_file": "C:\\Users\\username\\.eryph\\keys\\client.key"
}
],
"default_client": "client-id-from-identity"
}Unix Example (~/.config/.eryph/default.config):
{
"version": "1.0",
"identity": {
"endpoint": "https://identity.mycompany.com"
},
"compute": {
"endpoint": "https://compute.mycompany.com"
},
"clients": [
{
"id": "client-id-from-identity",
"name": "my-ruby-client",
"private_key_file": "/home/username/.eryph/keys/client.key"
}
],
"default_client": "client-id-from-identity"
}Save the private key to the location specified in your configuration:
client.key (PEM format):
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA1234567890abcdef...
[Your private key content]
...
-----END RSA PRIVATE KEY-----
Important Security Notes:
- Keep private keys secure and never commit them to version control
- Use appropriate file permissions (600 on Unix systems)
- Consider using dedicated service accounts for production
You can manage multiple environments with different configuration files:
File: ~/.config/.eryph/default.config
{
"version": "1.0",
"identity": {
"endpoint": "https://identity.mycompany.com"
},
"compute": {
"endpoint": "https://compute.mycompany.com"
},
"clients": [...],
"default_client": "default-client-id"
}Usage:
client = Eryph.compute_client('default')
# Or simply:
client = Eryph.compute_client # Uses 'default' automaticallyFile: ~/.config/.eryph/local.config
{
"version": "1.0",
"identity": {
"endpoint": "https://localhost:8080/identity"
},
"compute": {
"endpoint": "https://localhost:8080/compute"
},
"clients": [...],
"default_client": "local-client-id"
}Usage:
client = Eryph.compute_client('local')For local development with eryph-zero, the client automatically discovers running instances without any configuration files:
How it works:
- Scans for running processes - Checks application data directories for eryph-zero lock files
- Validates processes - Confirms processes are actually running by checking PIDs
- Extracts endpoints - Gets identity and compute endpoints from process metadata
- Uses system client - Automatically uses system client credentials from the running instance
Usage:
# Auto-discover local eryph-zero instance (Windows only)
client = Eryph.compute_client('zero')Requirements:
- Eryph-zero running locally (Windows only)
- Administrator privileges (for system client access)
- No configuration file needed - auto-discovery is built-in
For local development, system clients are automatically discovered:
# Local configuration - may use system client as fallback (requires admin/root)
client = Eryph.compute_client('local')
# Zero configuration - automatically uses system client (Windows only, requires admin)
client = Eryph.compute_client('zero')System client credentials are extracted from running Eryph processes when available.
Test your authentication setup:
# Test basic connection
client = Eryph.compute_client('default')
if client.test_connection
puts "✅ Authentication successful"
else
puts "❌ Authentication failed"
end
# Check token details
puts "Access token preview: #{client.access_token[0..20]}..."
puts "Configuration: #{client.config_name}"For development environments with self-signed certificates:
client = Eryph.compute_client('local',
ssl_config: {
verify_ssl: false,
verify_hostname: false
}
)Specify different OAuth2 scopes:
client = Eryph.compute_client('default',
scopes: ['compute:read', 'compute:write', 'projects:admin']
)Use custom logging:
require 'logger'
logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG
client = Eryph.compute_client('default', logger: logger)Problem: Client cannot find any configured credentials.
Solutions:
- Check configuration file exists and is valid JSON
- Verify file permissions
- Check private key file path and permissions
- Ensure default_client points to valid client ID
Problem: Private key cannot be parsed.
Solutions:
- Verify key is in PEM format
- Check file is not corrupted
- Ensure key matches client certificate
- Regenerate key if necessary
Problem: Cannot obtain access token from identity server.
Solutions:
- Verify identity endpoint URL
- Check client ID is registered in Identity
- Verify private key matches registered client
- Check network connectivity to identity server
- Ensure client has required scopes
Problem: SSL/TLS verification errors.
Solutions:
- For development: disable SSL verification
- For production: install proper certificates
- Check certificate chain and root CA
- Verify hostname matches certificate
Problem: Cannot access system client.
Solutions:
- Run as Administrator (Windows) or root (Unix)
- Use user-configured client instead of system client
- Check eryph-zero is running and accessible
-
Private Key Security:
- Never commit private keys to version control
- Use strict file permissions (600 on Unix)
- Store keys in secure locations
- Rotate keys regularly
-
Configuration Management:
- Use separate configurations for different environments
- Don't hardcode credentials in application code
- Use environment variables for sensitive configuration
-
Network Security:
- Use HTTPS endpoints in production
- Validate SSL certificates in production
- Consider network segmentation for API access
-
Access Control:
- Use least-privilege principle for OAuth2 scopes
- Monitor and audit API access
- Use dedicated service accounts for automation
- Configuration Guide - Advanced configuration management
- Getting Started - Basic usage examples
- Operation Tracking - Advanced operation monitoring