2016-09-22 00:45:57 +00:00
|
|
|
package kolide
|
|
|
|
|
2017-01-11 08:27:09 +00:00
|
|
|
import (
|
2017-03-15 15:55:30 +00:00
|
|
|
"context"
|
2017-01-11 08:27:09 +00:00
|
|
|
)
|
2016-09-22 00:45:57 +00:00
|
|
|
|
|
|
|
// AppConfigStore contains method for saving and retrieving
|
|
|
|
// application configuration
|
|
|
|
type AppConfigStore interface {
|
2016-11-04 20:44:38 +00:00
|
|
|
NewAppConfig(info *AppConfig) (*AppConfig, error)
|
|
|
|
AppConfig() (*AppConfig, error)
|
|
|
|
SaveAppConfig(info *AppConfig) error
|
2016-09-22 00:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// AppConfigService provides methods for configuring
|
2019-01-24 17:39:32 +00:00
|
|
|
// the Fleet application
|
2016-09-22 00:45:57 +00:00
|
|
|
type AppConfigService interface {
|
2016-11-04 20:44:38 +00:00
|
|
|
NewAppConfig(ctx context.Context, p AppConfigPayload) (info *AppConfig, err error)
|
|
|
|
AppConfig(ctx context.Context) (info *AppConfig, err error)
|
|
|
|
ModifyAppConfig(ctx context.Context, p AppConfigPayload) (info *AppConfig, err error)
|
2017-01-11 08:27:09 +00:00
|
|
|
SendTestEmail(ctx context.Context, config *AppConfig) error
|
2017-01-20 19:32:10 +00:00
|
|
|
|
|
|
|
// Certificate returns the PEM encoded certificate chain for osqueryd TLS termination.
|
|
|
|
// For cases where the connection is self-signed, the server will attempt to
|
|
|
|
// connect using the InsecureSkipVerify option in tls.Config.
|
|
|
|
CertificateChain(ctx context.Context) (cert []byte, err error)
|
2016-09-22 00:45:57 +00:00
|
|
|
}
|
|
|
|
|
2016-12-22 14:12:34 +00:00
|
|
|
// SMTP settings names returned from API, these map to SMTPAuthType and
|
|
|
|
// SMTPAuthMethod
|
|
|
|
const (
|
|
|
|
AuthMethodNameCramMD5 = "authmethod_cram_md5"
|
2019-01-14 20:35:23 +00:00
|
|
|
AuthMethodNameLogin = "authmethod_login"
|
2016-12-22 14:12:34 +00:00
|
|
|
AuthMethodNamePlain = "authmethod_plain"
|
|
|
|
AuthTypeNameUserNamePassword = "authtype_username_password"
|
|
|
|
AuthTypeNameNone = "authtype_none"
|
|
|
|
)
|
|
|
|
|
2016-12-20 21:54:30 +00:00
|
|
|
type SMTPAuthType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
AuthTypeUserNamePassword SMTPAuthType = iota
|
|
|
|
AuthTypeNone
|
|
|
|
)
|
|
|
|
|
2016-12-22 14:12:34 +00:00
|
|
|
func (a SMTPAuthType) String() string {
|
|
|
|
switch a {
|
|
|
|
case AuthTypeUserNamePassword:
|
|
|
|
return AuthTypeNameUserNamePassword
|
|
|
|
case AuthTypeNone:
|
|
|
|
return AuthTypeNameNone
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-20 21:54:30 +00:00
|
|
|
type SMTPAuthMethod int
|
|
|
|
|
|
|
|
const (
|
|
|
|
AuthMethodPlain SMTPAuthMethod = iota
|
|
|
|
AuthMethodCramMD5
|
2019-01-14 20:35:23 +00:00
|
|
|
AuthMethodLogin
|
2016-12-20 21:54:30 +00:00
|
|
|
)
|
|
|
|
|
2016-12-22 14:12:34 +00:00
|
|
|
func (m SMTPAuthMethod) String() string {
|
|
|
|
switch m {
|
|
|
|
case AuthMethodPlain:
|
|
|
|
return AuthMethodNamePlain
|
|
|
|
case AuthMethodCramMD5:
|
|
|
|
return AuthMethodNameCramMD5
|
2019-01-14 20:35:23 +00:00
|
|
|
case AuthMethodLogin:
|
|
|
|
return AuthMethodNameLogin
|
2016-12-22 14:12:34 +00:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-24 17:39:32 +00:00
|
|
|
// AppConfig holds configuration about the Fleet application.
|
|
|
|
// AppConfig data can be managed by a Fleet API user.
|
2016-11-04 20:44:38 +00:00
|
|
|
type AppConfig struct {
|
2016-12-20 21:54:30 +00:00
|
|
|
ID uint
|
2016-11-16 13:47:49 +00:00
|
|
|
OrgName string `db:"org_name"`
|
|
|
|
OrgLogoURL string `db:"org_logo_url"`
|
|
|
|
KolideServerURL string `db:"kolide_server_url"`
|
2017-01-20 19:48:54 +00:00
|
|
|
|
|
|
|
// EnrollSecret is the config value that must be given by osqueryd hosts
|
|
|
|
// on enrollment.
|
|
|
|
// See https://osquery.readthedocs.io/en/stable/deployment/remote/#remote-authentication
|
|
|
|
EnrollSecret string `db:"osquery_enroll_secret"`
|
|
|
|
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPConfigured is a flag that indicates if smtp has been successfully
|
|
|
|
// tested with the settings provided by an admin user.
|
|
|
|
SMTPConfigured bool `db:"smtp_configured"`
|
|
|
|
// SMTPSenderAddress is the email address that will appear in emails sent
|
2019-01-24 17:39:32 +00:00
|
|
|
// from Fleet
|
2016-12-20 21:54:30 +00:00
|
|
|
SMTPSenderAddress string `db:"smtp_sender_address"`
|
2019-01-24 17:39:32 +00:00
|
|
|
// SMTPServer is the host name of the SMTP server Fleet will use to send mail
|
2016-12-20 21:54:30 +00:00
|
|
|
SMTPServer string `db:"smtp_server"`
|
|
|
|
// SMTPPort port SMTP server will use
|
|
|
|
SMTPPort uint `db:"smtp_port"`
|
|
|
|
// SMTPAuthenticationType type of authentication for SMTP
|
|
|
|
SMTPAuthenticationType SMTPAuthType `db:"smtp_authentication_type"`
|
|
|
|
// SMTPUserName must be provided if SMTPAuthenticationType is UserNamePassword
|
|
|
|
SMTPUserName string `db:"smtp_user_name"`
|
|
|
|
// SMTPPassword must be provided if SMTPAuthenticationType is UserNamePassword
|
|
|
|
SMTPPassword string `db:"smtp_password"`
|
|
|
|
// SMTPEnableSSLTLS whether to use SSL/TLS for SMTP
|
|
|
|
SMTPEnableTLS bool `db:"smtp_enable_ssl_tls"`
|
|
|
|
// SMTPAuthenticationMethod authentication method smtp server will use
|
|
|
|
SMTPAuthenticationMethod SMTPAuthMethod `db:"smtp_authentication_method"`
|
|
|
|
|
|
|
|
// SMTPDomain optional domain for SMTP
|
|
|
|
SMTPDomain string `db:"smtp_domain"`
|
|
|
|
// SMTPVerifySSLCerts defaults to true but can be turned off if self signed
|
|
|
|
// SSL certs are used by the SMTP server
|
|
|
|
SMTPVerifySSLCerts bool `db:"smtp_verify_ssl_certs"`
|
|
|
|
// SMTPEnableStartTLS detects of TLS is enabled on mail server and starts to use it (default true)
|
|
|
|
SMTPEnableStartTLS bool `db:"smtp_enable_start_tls"`
|
2017-05-09 00:43:48 +00:00
|
|
|
// EntityID is a uri that identifies this service provider
|
|
|
|
EntityID string `db:"entity_id"`
|
|
|
|
// IssuerURI is the uri that identifies the identity provider
|
|
|
|
IssuerURI string `db:"issuer_uri"`
|
|
|
|
// IDPImageURL is a link to a logo or other image that is used for UX
|
|
|
|
IDPImageURL string `db:"idp_image_url"`
|
|
|
|
// Metadata contains IDP metadata XML
|
|
|
|
Metadata string `db:"metadata"`
|
|
|
|
// MetadataURL is a URL provided by the IDP which can be used to download
|
|
|
|
// metadata
|
|
|
|
MetadataURL string `db:"metadata_url"`
|
2017-12-22 02:37:32 +00:00
|
|
|
// IDPName is a human friendly name for the IDP
|
2017-05-09 00:43:48 +00:00
|
|
|
IDPName string `db:"idp_name"`
|
|
|
|
// EnableSSO flag to determine whether or not to enable SSO
|
|
|
|
EnableSSO bool `db:"enable_sso"`
|
2017-12-22 02:37:32 +00:00
|
|
|
// FIMInterval defines the interval when file integrity checks will occur
|
2017-08-18 15:37:33 +00:00
|
|
|
FIMInterval int `db:"fim_interval"`
|
2018-02-26 20:54:13 +00:00
|
|
|
// FIMFileAccess defines the FIMSections which will be monitored for file access events as a JSON formatted array
|
|
|
|
FIMFileAccesses string `db:"fim_file_accesses"`
|
2016-12-20 21:54:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ModifyAppConfigRequest contains application configuration information
|
|
|
|
// sent from front end and used to change app config elements.
|
|
|
|
type ModifyAppConfigRequest struct {
|
|
|
|
// TestSMTP is this is set to true, the SMTP configuration will be tested
|
|
|
|
// with the results of the test returned to caller. No config changes
|
|
|
|
// will be applied.
|
|
|
|
TestSMTP bool `json:"test_smtp"`
|
|
|
|
AppConfig AppConfig `json:"app_config"`
|
|
|
|
}
|
|
|
|
|
2017-05-09 00:43:48 +00:00
|
|
|
// SSOSettingsPayload wire format for SSO settings
|
|
|
|
type SSOSettingsPayload struct {
|
|
|
|
// EntityID is a uri that identifies this service provider
|
|
|
|
EntityID *string `json:"entity_id"`
|
|
|
|
// IssuerURI is the uri that identifies the identity provider
|
|
|
|
IssuerURI *string `json:"issuer_uri"`
|
|
|
|
// IDPImageURL is a link to a logo or other image that is used for UX
|
|
|
|
IDPImageURL *string `json:"idp_image_url"`
|
|
|
|
// Metadata contains IDP metadata XML
|
|
|
|
Metadata *string `json:"metadata"`
|
|
|
|
// MetadataURL is a URL provided by the IDP which can be used to download
|
|
|
|
// metadata
|
|
|
|
MetadataURL *string `json:"metadata_url"`
|
2017-12-22 02:37:32 +00:00
|
|
|
// IDPName is a human friendly name for the IDP
|
2017-05-09 00:43:48 +00:00
|
|
|
IDPName *string `json:"idp_name"`
|
|
|
|
// EnableSSO flag to determine whether or not to enable SSO
|
|
|
|
EnableSSO *bool `json:"enable_sso"`
|
|
|
|
}
|
|
|
|
|
2017-01-18 15:05:09 +00:00
|
|
|
// SMTPSettingsPayload is part of the AppConfigPayload which defines the wire representation
|
2016-12-20 21:54:30 +00:00
|
|
|
// of the app config endpoints
|
2017-01-18 15:05:09 +00:00
|
|
|
type SMTPSettingsPayload struct {
|
2018-09-07 22:37:35 +00:00
|
|
|
// SMTPEnabled indicates whether the user has selected that SMTP is
|
|
|
|
// enabled in the UI.
|
|
|
|
SMTPEnabled *bool `json:"enable_smtp"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPConfigured is a flag that indicates if smtp has been successfully
|
|
|
|
// tested with the settings provided by an admin user.
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPConfigured *bool `json:"configured"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPSenderAddress is the email address that will appear in emails sent
|
2019-01-24 17:39:32 +00:00
|
|
|
// from Fleet
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPSenderAddress *string `json:"sender_address"`
|
2019-01-24 17:39:32 +00:00
|
|
|
// SMTPServer is the host name of the SMTP server Fleet will use to send mail
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPServer *string `json:"server"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPPort port SMTP server will use
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPPort *uint `json:"port"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPAuthenticationType type of authentication for SMTP
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPAuthenticationType *string `json:"authentication_type"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPUserName must be provided if SMTPAuthenticationType is UserNamePassword
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPUserName *string `json:"user_name"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPPassword must be provided if SMTPAuthenticationType is UserNamePassword
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPPassword *string `json:"password"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPEnableSSLTLS whether to use SSL/TLS for SMTP
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPEnableTLS *bool `json:"enable_ssl_tls"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPAuthenticationMethod authentication method smtp server will use
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPAuthenticationMethod *string `json:"authentication_method"`
|
2016-12-20 21:54:30 +00:00
|
|
|
|
|
|
|
// SMTPDomain optional domain for SMTP
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPDomain *string `json:"domain"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPVerifySSLCerts defaults to true but can be turned off if self signed
|
|
|
|
// SSL certs are used by the SMTP server
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPVerifySSLCerts *bool `json:"verify_ssl_certs"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPEnableStartTLS detects of TLS is enabled on mail server and starts to use it (default true)
|
2017-01-18 15:05:09 +00:00
|
|
|
SMTPEnableStartTLS *bool `json:"enable_start_tls"`
|
2016-11-04 20:44:38 +00:00
|
|
|
}
|
|
|
|
|
2016-12-20 21:54:30 +00:00
|
|
|
// AppConfigPayload contains request/response format of
|
|
|
|
// the AppConfig endpoints.
|
2016-11-04 20:44:38 +00:00
|
|
|
type AppConfigPayload struct {
|
2017-01-18 15:05:09 +00:00
|
|
|
OrgInfo *OrgInfo `json:"org_info"`
|
|
|
|
ServerSettings *ServerSettings `json:"server_settings"`
|
|
|
|
SMTPSettings *SMTPSettingsPayload `json:"smtp_settings"`
|
2016-12-20 21:54:30 +00:00
|
|
|
// SMTPTest is a flag that if set will cause the server to test email configuration
|
|
|
|
SMTPTest *bool `json:"smtp_test,omitempty"`
|
2017-05-09 00:43:48 +00:00
|
|
|
// SSOSettings single sign settings
|
|
|
|
SSOSettings *SSOSettingsPayload `json:"sso_settings"`
|
2016-11-04 20:44:38 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 17:39:32 +00:00
|
|
|
// OrgInfo contains general info about the organization using Fleet.
|
2016-09-22 00:45:57 +00:00
|
|
|
type OrgInfo struct {
|
2018-05-04 16:53:21 +00:00
|
|
|
OrgName *string `json:"org_name,omitempty"`
|
|
|
|
OrgLogoURL *string `json:"org_logo_url,omitempty"`
|
2016-09-22 00:45:57 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 20:44:38 +00:00
|
|
|
// ServerSettings contains general settings about the kolide App.
|
|
|
|
type ServerSettings struct {
|
2018-05-04 16:53:21 +00:00
|
|
|
KolideServerURL *string `json:"kolide_server_url,omitempty"`
|
|
|
|
EnrollSecret *string `json:"osquery_enroll_secret,omitempty"`
|
2016-09-22 00:45:57 +00:00
|
|
|
}
|
2016-10-13 18:21:47 +00:00
|
|
|
|
2016-10-17 14:01:14 +00:00
|
|
|
type OrderDirection int
|
|
|
|
|
|
|
|
const (
|
|
|
|
OrderAscending OrderDirection = iota
|
|
|
|
OrderDescending
|
|
|
|
)
|
|
|
|
|
2016-10-13 18:21:47 +00:00
|
|
|
// ListOptions defines options related to paging and ordering to be used when
|
|
|
|
// listing objects
|
|
|
|
type ListOptions struct {
|
|
|
|
// Which page to return (must be positive integer)
|
|
|
|
Page uint
|
|
|
|
// How many results per page (must be positive integer, 0 indicates
|
|
|
|
// unlimited)
|
|
|
|
PerPage uint
|
2016-10-17 14:01:14 +00:00
|
|
|
// Key to use for ordering
|
|
|
|
OrderKey string
|
|
|
|
// Direction of ordering
|
|
|
|
OrderDirection OrderDirection
|
2016-10-13 18:21:47 +00:00
|
|
|
}
|