Documentation
¶
Overview ¶
Package config provides configuration management for agentapi-proxy using viper.
Configuration can be loaded from:
- JSON files (backward compatibility)
- YAML files
- Environment variables with AGENTAPI_ prefix
Environment variable examples:
AGENTAPI_START_PORT=8080 AGENTAPI_AUTH_ENABLED=true AGENTAPI_AUTH_GITHUB_OAUTH_CLIENT_ID=your_client_id AGENTAPI_AUTH_GITHUB_OAUTH_CLIENT_SECRET=your_client_secret AGENTAPI_PERSISTENCE_ENABLED=true AGENTAPI_PERSISTENCE_BACKEND=file
Configuration file search paths:
- Current directory
- $HOME/.agentapi/
- /etc/agentapi/
Configuration file names: config.json, config.yaml, config.yml
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶ added in v0.13.0
type APIKey struct {
Key string `json:"key" mapstructure:"key"`
UserID string `json:"user_id" mapstructure:"user_id"`
Role string `json:"role" mapstructure:"role"`
Permissions []string `json:"permissions" mapstructure:"permissions"`
CreatedAt string `json:"created_at" mapstructure:"created_at"`
ExpiresAt string `json:"expires_at,omitempty" mapstructure:"expires_at"`
}
APIKey represents an API key configuration
func (*APIKey) HasPermission ¶ added in v0.13.0
HasPermission checks if a user has a specific permission
type AuthConfig ¶ added in v0.13.0
type AuthConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"`
Static *StaticAuthConfig `json:"static,omitempty" mapstructure:"static"`
GitHub *GitHubAuthConfig `json:"github,omitempty" mapstructure:"github"`
}
AuthConfig represents authentication configuration
type Config ¶
type Config struct {
// StartPort is the starting port for agentapi servers
StartPort int `json:"start_port" mapstructure:"start_port"`
// Auth represents authentication configuration
Auth AuthConfig `json:"auth" mapstructure:"auth"`
// Persistence represents session persistence configuration
Persistence PersistenceConfig `json:"persistence" mapstructure:"persistence"`
// EnableMultipleUsers enables user-specific directory isolation
EnableMultipleUsers bool `json:"enable_multiple_users" mapstructure:"enable_multiple_users"`
}
Config represents the proxy configuration
func LoadConfig ¶
LoadConfig loads configuration using viper with support for JSON, YAML, and environment variables
func LoadConfigLegacy ¶ added in v1.9.1
LoadConfigLegacy loads configuration from a JSON file (legacy method)
type GitHubAuthConfig ¶ added in v1.0.0
type GitHubAuthConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"`
BaseURL string `json:"base_url" mapstructure:"base_url"`
TokenHeader string `json:"token_header" mapstructure:"token_header"`
UserMapping GitHubUserMapping `json:"user_mapping" mapstructure:"user_mapping"`
OAuth *GitHubOAuthConfig `json:"oauth,omitempty" mapstructure:"oauth"`
}
GitHubAuthConfig represents GitHub OAuth authentication
type GitHubOAuthConfig ¶ added in v1.9.1
type GitHubOAuthConfig struct {
ClientID string `json:"client_id" mapstructure:"client_id"`
ClientSecret string `json:"client_secret" mapstructure:"client_secret"`
Scope string `json:"scope" mapstructure:"scope"`
BaseURL string `json:"base_url,omitempty" mapstructure:"base_url"`
}
GitHubOAuthConfig represents GitHub OAuth2 configuration
type GitHubUserMapping ¶ added in v1.0.0
type GitHubUserMapping struct {
DefaultRole string `json:"default_role" mapstructure:"default_role"`
DefaultPermissions []string `json:"default_permissions" mapstructure:"default_permissions"`
TeamRoleMapping map[string]TeamRoleRule `json:"team_role_mapping" mapstructure:"team_role_mapping"`
}
GitHubUserMapping represents user role mapping configuration
type PersistenceConfig ¶ added in v1.0.0
type PersistenceConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"`
Backend string `json:"backend" mapstructure:"backend"` // "file", "sqlite", "postgres", "s3"
FilePath string `json:"file_path" mapstructure:"file_path"`
SyncInterval int `json:"sync_interval_seconds" mapstructure:"sync_interval_seconds"`
EncryptSecrets bool `json:"encrypt_sensitive_data" mapstructure:"encrypt_sensitive_data"`
SessionRecoveryMaxAge int `json:"session_recovery_max_age_hours" mapstructure:"session_recovery_max_age_hours"` // Max age in hours for session recovery
// S3-specific configuration
S3Bucket string `json:"s3_bucket" mapstructure:"s3_bucket"`
S3Region string `json:"s3_region" mapstructure:"s3_region"`
S3Prefix string `json:"s3_prefix" mapstructure:"s3_prefix"`
S3Endpoint string `json:"s3_endpoint" mapstructure:"s3_endpoint"` // For custom S3-compatible services
S3AccessKey string `json:"s3_access_key" mapstructure:"s3_access_key"`
S3SecretKey string `json:"s3_secret_key" mapstructure:"s3_secret_key"`
}
PersistenceConfig represents session persistence configuration
type StaticAuthConfig ¶ added in v1.0.0
type StaticAuthConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled"`
APIKeys []APIKey `json:"api_keys" mapstructure:"api_keys"`
KeysFile string `json:"keys_file" mapstructure:"keys_file"`
HeaderName string `json:"header_name" mapstructure:"header_name"`
}
StaticAuthConfig represents static API key authentication
type TeamRoleRule ¶ added in v1.0.0
type TeamRoleRule struct {
Role string `json:"role" mapstructure:"role"`
Permissions []string `json:"permissions" mapstructure:"permissions"`
}
TeamRoleRule represents a team-based role rule