Documentation ¶
Overview ¶
Package plugin provides support for the SFTPGo plugin system
Index ¶
- Constants
- Variables
- func Initialize(configs []Config, logLevel string) error
- type AuthConfig
- type Config
- type KMSConfig
- type KeyboardAuthRequest
- type KeyboardAuthResponse
- type Manager
- func (m *Manager) Authenticate(username, password, ip, protocol string, pkey string, ...) ([]byte, error)
- func (m *Manager) Cleanup()
- func (m *Manager) ExecuteKeyboardInteractiveStep(req *KeyboardAuthRequest) (*KeyboardAuthResponse, error)
- func (m *Manager) GetMetadataFolders(storageID, from string, limit int) ([]string, error)
- func (m *Manager) GetModificationTime(storageID, objectPath string, isDir bool) (int64, error)
- func (m *Manager) GetModificationTimes(storageID, objectPath string) (map[string]int64, error)
- func (m *Manager) HasAuthScope(scope int) bool
- func (m *Manager) HasAuthenticators() bool
- func (m *Manager) HasMetadater() bool
- func (m *Manager) HasNotifiers() bool
- func (m *Manager) IsIPBanned(ip string) bool
- func (m *Manager) NotifyFsEvent(event *notifier.FsEvent)
- func (m *Manager) NotifyProviderEvent(event *notifier.ProviderEvent, object Renderer)
- func (m *Manager) ReloadFilter()
- func (m *Manager) RemoveMetadata(storageID, objectPath string) error
- func (m *Manager) SearchFsEvents(searchFilters *eventsearcher.FsEventSearch) ([]byte, []string, []string, error)
- func (m *Manager) SearchProviderEvents(searchFilters *eventsearcher.ProviderEventSearch) ([]byte, []string, []string, error)
- func (m *Manager) SetModificationTime(storageID, objectPath string, mTime int64) error
- type NotifierConfig
- type Renderer
Constants ¶
const ( AuthScopePassword = 1 AuthScopePublicKey = 2 AuthScopeKeyboardInteractive = 4 AuthScopeTLSCertificate = 8 )
Supported auth scopes
Variables ¶
var ( // Handler defines the plugins manager Handler Manager // ErrNoSearcher defines the error to return for events searches if no plugin is configured ErrNoSearcher = errors.New("no events searcher plugin defined") // ErrNoMetadater returns the error to return for metadata methods if no plugin is configured ErrNoMetadater = errors.New("no metadata plugin defined") )
Functions ¶
func Initialize ¶
Initialize initializes the configured plugins
Types ¶
type AuthConfig ¶
type AuthConfig struct { // Scope defines the scope for the authentication plugin. // - 1 means passwords only // - 2 means public keys only // - 4 means keyboard interactive only // - 8 means TLS certificates only // you can combine the scopes, for example 3 means password and public key, 5 password and keyboard // interactive and so on Scope int `json:"scope" mapstructure:"scope"` }
AuthConfig defines configuration parameters for auth plugins
type Config ¶
type Config struct { // Plugin type Type string `json:"type" mapstructure:"type"` // NotifierOptions defines options for notifiers plugins NotifierOptions NotifierConfig `json:"notifier_options" mapstructure:"notifier_options"` // KMSOptions defines options for a KMS plugin KMSOptions KMSConfig `json:"kms_options" mapstructure:"kms_options"` // AuthOptions defines options for authentication plugins AuthOptions AuthConfig `json:"auth_options" mapstructure:"auth_options"` // Path to the plugin executable Cmd string `json:"cmd" mapstructure:"cmd"` // Args to pass to the plugin executable Args []string `json:"args" mapstructure:"args"` // SHA256 checksum for the plugin executable. // If not empty it will be used to verify the integrity of the executable SHA256Sum string `json:"sha256sum" mapstructure:"sha256sum"` // If enabled the client and the server automatically negotiate mTLS for // transport authentication. This ensures that only the original client will // be allowed to connect to the server, and all other connections will be // rejected. The client will also refuse to connect to any server that isn't // the original instance started by the client. AutoMTLS bool `json:"auto_mtls" mapstructure:"auto_mtls"` // contains filtered or unexported fields }
Config defines a plugin configuration
type KMSConfig ¶
type KMSConfig struct { Scheme string `json:"scheme" mapstructure:"scheme"` EncryptedStatus string `json:"encrypted_status" mapstructure:"encrypted_status"` }
KMSConfig defines configuration parameters for kms plugins
type KeyboardAuthRequest ¶
type KeyboardAuthRequest struct { RequestID string `json:"request_id"` Step int `json:"step"` Username string `json:"username,omitempty"` IP string `json:"ip,omitempty"` Password string `json:"password,omitempty"` Answers []string `json:"answers,omitempty"` Questions []string `json:"questions,omitempty"` }
KeyboardAuthRequest defines the request for a keyboard interactive authentication step
type KeyboardAuthResponse ¶
type KeyboardAuthResponse struct { Instruction string `json:"instruction"` Questions []string `json:"questions"` Echos []bool `json:"echos"` AuthResult int `json:"auth_result"` CheckPwd int `json:"check_password"` }
KeyboardAuthResponse defines the response for a keyboard interactive authentication step
func (*KeyboardAuthResponse) Validate ¶
func (r *KeyboardAuthResponse) Validate() error
Validate returns an error if the KeyboardAuthResponse is invalid
type Manager ¶
type Manager struct { // List of configured plugins Configs []Config `json:"plugins" mapstructure:"plugins"` // contains filtered or unexported fields }
Manager handles enabled plugins
func (*Manager) Authenticate ¶
func (m *Manager) Authenticate(username, password, ip, protocol string, pkey string, tlsCert *x509.Certificate, authScope int, userAsJSON []byte, ) ([]byte, error)
Authenticate tries to authenticate the specified user using an external plugin
func (*Manager) ExecuteKeyboardInteractiveStep ¶
func (m *Manager) ExecuteKeyboardInteractiveStep(req *KeyboardAuthRequest) (*KeyboardAuthResponse, error)
ExecuteKeyboardInteractiveStep executes a keyboard interactive step
func (*Manager) GetMetadataFolders ¶
GetMetadataFolders returns the folders that metadata is associated with
func (*Manager) GetModificationTime ¶
GetModificationTime returns the modification time for the specified path
func (*Manager) GetModificationTimes ¶
GetModificationTimes returns the modification times for all the files within the specified folder
func (*Manager) HasAuthScope ¶
HasAuthScope returns true if there is an auth plugin that support the specified scope
func (*Manager) HasAuthenticators ¶
HasAuthenticators returns true if there is at least an auth plugin
func (*Manager) HasMetadater ¶
HasMetadater returns true if a metadata plugin is defined
func (*Manager) HasNotifiers ¶
HasNotifiers returns true if there is at least a notifier plugin
func (*Manager) IsIPBanned ¶
IsIPBanned returns true if the IP filter plugin does not allow the specified ip. If no IP filter plugin is defined this method returns false
func (*Manager) NotifyFsEvent ¶
NotifyFsEvent sends the fs event notifications using any defined notifier plugins
func (*Manager) NotifyProviderEvent ¶
func (m *Manager) NotifyProviderEvent(event *notifier.ProviderEvent, object Renderer)
NotifyProviderEvent sends the provider event notifications using any defined notifier plugins
func (*Manager) ReloadFilter ¶
func (m *Manager) ReloadFilter()
ReloadFilter sends a reload request to the IP filter plugin
func (*Manager) RemoveMetadata ¶
RemoveMetadata deletes the metadata stored for the specified object
func (*Manager) SearchFsEvents ¶
func (m *Manager) SearchFsEvents(searchFilters *eventsearcher.FsEventSearch) ([]byte, []string, []string, error)
SearchFsEvents returns the filesystem events matching the specified filters
func (*Manager) SearchProviderEvents ¶
func (m *Manager) SearchProviderEvents(searchFilters *eventsearcher.ProviderEventSearch) ([]byte, []string, []string, error)
SearchProviderEvents returns the provider events matching the specified filters
type NotifierConfig ¶
type NotifierConfig struct { FsEvents []string `json:"fs_events" mapstructure:"fs_events"` ProviderEvents []string `json:"provider_events" mapstructure:"provider_events"` ProviderObjects []string `json:"provider_objects" mapstructure:"provider_objects"` RetryMaxTime int `json:"retry_max_time" mapstructure:"retry_max_time"` RetryQueueMaxSize int `json:"retry_queue_max_size" mapstructure:"retry_queue_max_size"` }
NotifierConfig defines configuration parameters for notifiers plugins