config

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

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

func (apiKey *APIKey) HasPermission(permission string) bool

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"`
	APIKeys    []APIKey `json:"api_keys" mapstructure:"api_keys"`
	KeysFile   string   `json:"keys_file" mapstructure:"keys_file"`
	HeaderName string   `json:"header_name" mapstructure:"header_name"`
}

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"`
}

Config represents the proxy configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration from a JSON file

func (*Config) ValidateAPIKey added in v0.13.0

func (c *Config) ValidateAPIKey(key string) (*APIKey, bool)

ValidateAPIKey validates an API key and returns user information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL