Documentation
¶
Index ¶
- func RegisterAll()
- type ConfigProvider
- func (p *ConfigProvider) Cleanup(cleanupPath string)
- func (p *ConfigProvider) ConfigureProxy(proxy provider.ProxyConfigurer, cred *provider.Credential)
- func (p *ConfigProvider) ContainerEnv(cred *provider.Credential) []string
- func (p *ConfigProvider) ContainerMounts(cred *provider.Credential, containerHome string) ([]provider.MountConfig, string, error)
- func (p *ConfigProvider) Description() string
- func (p *ConfigProvider) Grant(ctx context.Context) (*provider.Credential, error)
- func (p *ConfigProvider) ImpliedDependencies() []string
- func (p *ConfigProvider) Name() string
- func (p *ConfigProvider) Source() string
- type InjectConfig
- type ProviderDef
- type ValidateConfig
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 ¶
func (p *ConfigProvider) Grant(ctx context.Context) (*provider.Credential, error)
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 ¶
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.