configprovider

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterAll

func RegisterAll()

RegisterAll loads and registers all config-driven providers. Embedded defaults are loaded first, then user-defined providers from ~/.moat/providers/. Go providers (registered via init()) take precedence over config-driven providers with the same name. Safe to call multiple times; only the first call has any effect.

Types

type ConfigProvider

type ConfigProvider struct {
	// contains filtered or unexported fields
}

ConfigProvider implements provider.CredentialProvider using a YAML-defined ProviderDef.

func NewConfigProvider

func NewConfigProvider(def ProviderDef, source string) *ConfigProvider

NewConfigProvider creates a new ConfigProvider from a definition.

func (*ConfigProvider) Cleanup

func (p *ConfigProvider) Cleanup(cleanupPath string)

Cleanup is a no-op for config providers.

func (*ConfigProvider) ConfigureProxy

func (p *ConfigProvider) ConfigureProxy(proxy provider.ProxyConfigurer, cred *provider.Credential)

ConfigureProxy sets up proxy headers for this credential. When inject.header is configured, injects the credential as an HTTP header. Otherwise, sets up token substitution — the proxy replaces the placeholder token in URL paths, Authorization headers, and request bodies. This is used for APIs like Telegram Bot API where the token is embedded in the URL path.

func (*ConfigProvider) ContainerEnv

func (p *ConfigProvider) ContainerEnv(cred *provider.Credential) []string

ContainerEnv returns environment variables to set in the container. The env var is always set to a placeholder — the real token is injected by the proxy at the network layer (either via header injection or token substitution).

func (*ConfigProvider) ContainerMounts

func (p *ConfigProvider) ContainerMounts(cred *provider.Credential, containerHome string) ([]provider.MountConfig, string, error)

ContainerMounts returns mounts needed for this credential (none for config providers).

func (*ConfigProvider) Description

func (p *ConfigProvider) Description() string

Description returns the provider description.

func (*ConfigProvider) Grant

Grant acquires credentials from environment variables or interactive prompt.

func (*ConfigProvider) ImpliedDependencies

func (p *ConfigProvider) ImpliedDependencies() []string

ImpliedDependencies returns nil (no implied dependencies for config providers).

func (*ConfigProvider) Name

func (p *ConfigProvider) Name() string

Name returns the provider identifier.

func (*ConfigProvider) Source

func (p *ConfigProvider) Source() string

Source returns "builtin" or "custom" depending on origin.

type InjectConfig

type InjectConfig struct {
	Header string `yaml:"header"`
	Prefix string `yaml:"prefix,omitempty"`
}

InjectConfig defines how credentials are injected into HTTP requests.

type ProviderDef

type ProviderDef struct {
	Name         string          `yaml:"name"`
	Description  string          `yaml:"description"`
	Aliases      []string        `yaml:"aliases,omitempty"`
	Hosts        []string        `yaml:"hosts"`
	Inject       InjectConfig    `yaml:"inject"`
	SourceEnv    []string        `yaml:"source_env,omitempty"`
	ContainerEnv string          `yaml:"container_env,omitempty"`
	Validate     *ValidateConfig `yaml:"validate,omitempty"`
	Prompt       string          `yaml:"prompt,omitempty"`
}

ProviderDef defines a credential provider via YAML configuration.

func (ProviderDef) HasHeaderInjection

func (d ProviderDef) HasHeaderInjection() bool

HasHeaderInjection returns true if the provider injects credentials via HTTP headers. When false and hosts are configured, the provider uses token substitution instead — the proxy replaces placeholder tokens in URL paths, headers, and request bodies.

type ValidateConfig

type ValidateConfig struct {
	URL    string `yaml:"url"`
	Method string `yaml:"method,omitempty"` // default: GET
	Header string `yaml:"header,omitempty"` // default: inject.header
	Prefix string `yaml:"prefix,omitempty"` // default: inject.prefix
}

ValidateConfig defines an optional endpoint for token validation.

Jump to

Keyboard shortcuts

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