Documentation ¶
Overview ¶
Package config includes definitions for the Emissary configuration file, along with adapters for reading/writing from the filesystem or a mongodb database.
Index ¶
- Constants
- func DatabaseConnectInfo() schema.Element
- func DomainSchema() schema.Element
- func OwnerSchema() schema.Element
- func ProviderSchema() schema.Element
- func ReadableFolderSchema() schema.Element
- func SMTPConnectionSchema() schema.Element
- func Schema() schema.Schema
- func WritableFolderSchema() schema.Element
- type CommandLineArgs
- type Config
- func (config Config) AllProviders() []form.LookupCode
- func (config Config) DomainNames() []string
- func (config *Config) GetPointer(name string) (any, bool)
- func (config Config) HTTPPortString() (string, bool)
- func (config Config) HTTPSPortString() (string, bool)
- func (config Config) IsEmpty() bool
- func (config Config) Schema() schema.Schema
- func (config *Config) With(options ...Option)
- type Domain
- type FileStorage
- type MongoStorage
- type Option
- type Owner
- type Provider
- type SMTPConnection
- func (smtp SMTPConnection) GetBoolOK(name string) (bool, bool)
- func (smtp SMTPConnection) GetIntOK(name string) (int, bool)
- func (smtp SMTPConnection) GetStringOK(name string) (string, bool)
- func (smtp SMTPConnection) Server() (*mail.SMTPServer, bool)
- func (smtp *SMTPConnection) SetBool(name string, value bool) bool
- func (smtp *SMTPConnection) SetInt(name string, value int) bool
- func (smtp *SMTPConnection) SetString(name string, value string) bool
- func (smtp SMTPConnection) Validate() error
- type Storage
Constants ¶
const ConfigSourceCommandLine = "COMMAND"
ConfigSourceCommandLine represents that the config file location was specified via the "--config" command line argument
const ConfigSourceDefault = "DEFAULT"
ConfigSourceDefault represents that the config file location was not specified, so the default value of "file://./config.json" was used
const ConfigSourceEnvironment = "ENVIRONMENT"
ConfigSourceEnvironment represents that the config file location was specified via the "EMISSARY_CONFIG" environment variable
const FolderAdapterEmbed = "EMBED"
const FolderAdapterFile = "FILE"
const FolderAdapterGit = "GIT"
const FolderAdapterS3 = "S3"
const StorageTypeFile = "FILE"
StorageTypeFile represents a configuration database stored in a JSON file
const StorageTypeMongo = "MONGODB"
StorageTypeMongo represents a configuration database stored in a MongoDB database
Variables ¶
This section is empty.
Functions ¶
func DatabaseConnectInfo ¶ added in v0.6.0
func DomainSchema ¶
func OwnerSchema ¶
func ProviderSchema ¶
ProviderSchema returns a schema that validates the Provider object
func ReadableFolderSchema ¶
func SMTPConnectionSchema ¶
func WritableFolderSchema ¶
Types ¶
type CommandLineArgs ¶
type CommandLineArgs struct { Source string // Type of configuration file (Command Line | Enviornment Variable | Default) Protocol string // Protocol to use when loading the configuration (MONGODB | FILE) Location string // URI of the configuration file Setup bool // If TRUE, then the server will run in SETUP mode HTTPPort int // Port to use in setup mode (only) }
CommandLineArgs represents the command line arguments passed to the server
func GetCommandLineArgs ¶
func GetCommandLineArgs() CommandLineArgs
GetCommandLineArgs returns the location of the configuration file
func (CommandLineArgs) ConfigOptions ¶ added in v0.6.0
func (args CommandLineArgs) ConfigOptions() []Option
ConfigOptions returns any config modifiers specified in the command line (like --port)
type Config ¶
type Config struct { Domains set.Slice[Domain] `json:"domains"` // Slice of one or more domain configurations Providers set.Slice[Provider] `json:"providers"` // Slice of one or more OAuth client configurations Templates sliceof.Object[mapof.String] `json:"templates"` // Folders containing all stream templates Emails sliceof.Object[mapof.String] `json:"emails"` // Folders containing email templates AttachmentOriginals mapof.String `json:"attachmentOriginals"` // Folder where original attachments will be stored AttachmentCache mapof.String `json:"attachmentCache"` // Folder (possibly memory cache) where cached versions of attachmented files will be stored. Certificates mapof.String `json:"certificates"` // Folder containing the SSL certificate cache for Let's Encrypt AutoSSL ActivityPubCache mapof.String `json:"activityPubCache"` // Connection string for ActivityPub cache database AdminEmail string `json:"adminEmail"` // Email address of the administrator HTTPPort int `json:"httpPort"` // Port to listen on for HTTP requests HTTPSPort int `json:"httpsPort"` // Port to listen on for HTTPS requests DebugLevel string `json:"debugLevel"` // Amount of debugging information to log for the server, using zerolog levels (Trace, Debug, Info, Error, None) Source string `json:"-"` // READONLY: Where did the initial config location come from? (Command Line, Environment Variable, Default) Location string `json:"-"` // READONLY: Location where this config file is read from/to. Not a part of the configuration itself. MongoID primitive.ObjectID `json:"-" bson:"_id"` // Used as unique key for MongoDB }
Config defines all of the domains available on this server
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig return sthe default configuration for this application.
func NewConfig ¶
func NewConfig() Config
NewConfig returns a fully initialized (but empty) Config data structure.
func (Config) AllProviders ¶
func (config Config) AllProviders() []form.LookupCode
func (Config) DomainNames ¶
DomainNames returns an array of domains names in this configuration.
func (*Config) GetPointer ¶ added in v0.6.0
func (Config) HTTPPortString ¶ added in v0.6.0
HTTPPortString returns the HTTP port as a string (prefixed with a colon). This defaults to ":80" if no port is specified.
func (Config) HTTPSPortString ¶ added in v0.6.0
HTTPSPortString returns the HTTPS port as a string (prefixed with a colon). This defaults to ":443" if no port is specified.
type Domain ¶
type Domain struct { DomainID string `json:"domainId" bson:"domainId"` // Unique ID for this domain Label string `json:"label" bson:"label"` // Human-friendly label for administrators Hostname string `json:"hostname" bson:"hostname"` // Domain name of a virtual server ConnectString string `json:"connectString" bson:"connectString"` // MongoDB connect string DatabaseName string `json:"databaseName" bson:"databaseName"` // Name of the MongoDB Database (can be empty string to use default db for the connect string) SMTPConnection SMTPConnection `json:"smtp" bson:"smtp"` // Information for connecting to an SMTP server to send email on behalf of the domain. Owner Owner `json:"owner" bson:"owner"` // Information about the owner of this domain KeyEncryptingKey string `json:"keyEncryptingKey" bson:"keyEncryptingKey"` // Key used to encrypt/decrypt JWT keys stored in the database }
Domain contains all of the configuration data required to operate a single domain.
func (*Domain) GetPointer ¶ added in v0.6.0
type FileStorage ¶
type FileStorage struct {
// contains filtered or unexported fields
}
FileStorage is a file-based storage engine for the server configuration
func NewFileStorage ¶
func NewFileStorage(args *CommandLineArgs) FileStorage
NewFileStorage creates a fully initialized FileStorage instance
func (FileStorage) Subscribe ¶
func (storage FileStorage) Subscribe() <-chan Config
Subscribe returns a channel that will receive the configuration every time it is updated
func (FileStorage) Write ¶
func (storage FileStorage) Write(config Config) error
Write writes the configuration to the filesystem
type MongoStorage ¶
type MongoStorage struct {
// contains filtered or unexported fields
}
MongoStorage is a MongoDB-backed configuration storage
func NewMongoStorage ¶
func NewMongoStorage(args *CommandLineArgs) MongoStorage
NewMongoStorage creates a fully initialized MongoStorage instance
func (MongoStorage) Subscribe ¶
func (storage MongoStorage) Subscribe() <-chan Config
Subscribe returns a channel that will receive the configuration every time it is updated
func (MongoStorage) Write ¶
func (storage MongoStorage) Write(config Config) error
Write writes the configuration to the database
type Option ¶ added in v0.6.0
type Option func(*Config)
func WithHTTPPort ¶ added in v0.6.0
WithHTTPPort overrides the HTTP port used by the server
type Owner ¶
type Owner struct { DisplayName string `json:"displayName" bson:"displayName"` Username string `json:"username" bson:"username"` EmailAddress string `json:"emailAddress" bson:"emailAddress"` PhoneNumber string `json:"phoneNumber" bson:"phoneNumber"` MailingAddress string `json:"mailingAddress" bson:"mailingAddress"` }
type Provider ¶
type Provider struct { ProviderID string `json:"providerId" bson:"providerId"` // Unique identifier for this provider ClientID string `json:"clientId" bson:"clientId"` // Client ID for this provider ClientSecret string `json:"clientSecret" bson:"clientSecret"` // Client Secret for this provider }
Provider represents a single external service provider (typically OAuth2)
func NewProvider ¶
NewProvider returns a fully initialized Provider object
type SMTPConnection ¶
type SMTPConnection struct { Hostname string `json:"hostname"` // Server name to connect to Username string `json:"username"` // Username for authentication Password string `json:"password"` // Password/secret for authentication Port int `json:"port"` // Port to connect to TLS bool `json:"tls"` // If TRUE, then use TLS to connect }
func NewSMTPConnection ¶
func NewSMTPConnection() SMTPConnection
func (SMTPConnection) GetStringOK ¶
func (smtp SMTPConnection) GetStringOK(name string) (string, bool)
func (SMTPConnection) Server ¶
func (smtp SMTPConnection) Server() (*mail.SMTPServer, bool)
Server generates a fully initialized SMTP server object. This object may still be invalid, if the SMTPConnection is not populated with correct information.
func (*SMTPConnection) SetString ¶
func (smtp *SMTPConnection) SetString(name string, value string) bool
func (SMTPConnection) Validate ¶
func (smtp SMTPConnection) Validate() error
Validate confirms that the SMTPConnection matches ths SMTPConnectionSchema