config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Inmemory DatabaseType = "inmemory"
	Mysql    DatabaseType = "mysql"

	Plain LogStyle = "plain"
	ECS   LogStyle = "ecs" // default
)

Variables

View Source
var (
	ErrorConfigArgumentMissing = errors.New("configuration file argument missing. Please specify using -config argument. Aborting")
	ErrorConfigFile            = errors.New("failed to read or parse configuration file. Aborting")
)

Functions

func AddAutoBcc

func AddAutoBcc() string

func AuthServiceBaseUrl

func AuthServiceBaseUrl() string

func CorsAllowOrigin

func CorsAllowOrigin() string

func DatabaseMysqlConnectString

func DatabaseMysqlConnectString() string

func EmailFrom

func EmailFrom() string

func EmailFromPassword

func EmailFromPassword() string

func EnableTestingMigrateDatabase

func EnableTestingMigrateDatabase()

EnableTestingMigrateDatabase is for tests

func FixedApiToken

func FixedApiToken() string

func IsCorsDisabled

func IsCorsDisabled() bool

func LoadTestingConfigurationFromPathOrAbort

func LoadTestingConfigurationFromPathOrAbort(configFilenameForTests string)

LoadTestingConfigurationFromPathOrAbort is for tests to set a hardcoded yaml configuration

func LoggingSeverity

func LoggingSeverity() string

func MailDevMails

func MailDevMails() []string

func MailDevMode

func MailDevMode() bool

func MailLogOnly

func MailLogOnly() bool

func MessageIdDomain added in v0.1.2

func MessageIdDomain() string

func MigrateDatabase

func MigrateDatabase() bool

func OidcAccessTokenCookieName

func OidcAccessTokenCookieName() string

func OidcAdminGroup

func OidcAdminGroup() string

func OidcAllowedAudience

func OidcAllowedAudience() string

func OidcAllowedIssuer

func OidcAllowedIssuer() string

func OidcIdTokenCookieName

func OidcIdTokenCookieName() string

func OidcKeySet

func OidcKeySet() []*rsa.PublicKey

func ParseCommandLineFlags

func ParseCommandLineFlags()

ParseCommandLineFlags is exposed separately so you can skip it for tests

func ServerAddr

func ServerAddr() string

func ServerIdleTimeout

func ServerIdleTimeout() time.Duration

func ServerReadTimeout

func ServerReadTimeout() time.Duration

func ServerWriteTimeout

func ServerWriteTimeout() time.Duration

func SmtpHost

func SmtpHost() string

func SmtpPort

func SmtpPort() int

func StartupLoadConfiguration

func StartupLoadConfiguration() error

func UseEcsLogging

func UseEcsLogging() bool

Types

type Application

type Application struct {
	Server   ServerConfig   `yaml:"server"`
	Mail     MailConfig     `yaml:"mail"`
	Database DatabaseConfig `yaml:"database"`
	Security SecurityConfig `yaml:"security"`
	Logging  LoggingConfig  `yaml:"logging"`
}

Application is the root configuration type

func Configuration

func Configuration() *Application

type CorsConfig

type CorsConfig struct {
	DisableCors bool   `yaml:"disable"`
	AllowOrigin string `yaml:"allow_origin"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Use        DatabaseType `yaml:"use"`
	Username   string       `yaml:"username"`
	Password   string       `yaml:"password"`
	Database   string       `yaml:"database"`
	Parameters []string     `yaml:"parameters"`
}

DatabaseConfig configures which db to use (mysql, inmemory) and how to connect to it (needed for mysql only)

type DatabaseType

type DatabaseType string

func DatabaseUse

func DatabaseUse() DatabaseType

type FixedTokenConfig

type FixedTokenConfig struct {
	Api string `yaml:"api"` // shared-secret for server-to-server backend authentication
}

type LogStyle

type LogStyle string

type LoggingConfig

type LoggingConfig struct {
	Style    LogStyle `yaml:"style"`
	Severity string   `yaml:"severity"`
}

LoggingConfig configures logging

type MailConfig

type MailConfig struct {
	LogOnly         bool     `yaml:"log_only"`
	DevMode         bool     `yaml:"dev_mode"`
	DevMails        []string `yaml:"dev_mails"`
	AddAutoBcc      string   `yaml:"add_auto_bcc"`
	From            string   `yaml:"from"`
	FromPass        string   `yaml:"from_password"`
	Host            string   `yaml:"smtp_host"`
	Port            string   `yaml:"smtp_port"`
	MessageIdDomain string   `yaml:"message_id_domain"`
}

MailConfig contains values for the mail server

type OpenIdConnectConfig

type OpenIdConnectConfig struct {
	IdTokenCookieName     string   `yaml:"id_token_cookie_name"`     // optional, but must both be set, then tokens are read from cookies
	AccessTokenCookieName string   `yaml:"access_token_cookie_name"` // optional, but must both be set, then tokens are read from cookies
	TokenPublicKeysPEM    []string `yaml:"token_public_keys_PEM"`    // a list of public RSA keys in PEM format, see https://github.com/Jumpy-Squirrel/jwks2pem for obtaining PEM from openid keyset endpoint
	AdminGroup            string   `yaml:"admin_group"`              // the group claim that supplies admin rights
	AuthService           string   `yaml:"auth_service"`             // base url, usually http://localhost:nnnn, will skip userinfo checks if unset
	Audience              string   `yaml:"audience"`
	Issuer                string   `yaml:"issuer"`
}

type SecurityConfig

type SecurityConfig struct {
	Fixed FixedTokenConfig    `yaml:"fixed_token"`
	Oidc  OpenIdConnectConfig `yaml:"oidc"`
	Cors  CorsConfig          `yaml:"cors"`
}

SecurityConfig configures everything related to security

type ServerConfig

type ServerConfig struct {
	Address      string `yaml:"address"`
	Port         string `yaml:"port"`
	ReadTimeout  int    `yaml:"read_timeout_seconds"`
	WriteTimeout int    `yaml:"write_timeout_seconds"`
	IdleTimeout  int    `yaml:"idle_timeout_seconds"`
}

ServerConfig contains all values for http configuration

Jump to

Keyboard shortcuts

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