config

package
v0.0.0-...-185ace6 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	Secure            bool          `json:"secure" default:"true"`
	RequestIDHeader   string        `json:"request_id_header" split_words:"true" validate:"required"`
	ExternalURL       string        `json:"external_url" split_words:"true"`
	AllowedLogoutURLs []string      `json:"allowed_logout_urls" split_words:"true"`
	CSRF              *CSRFConfig   `json:"csrf" validate:"dive"`
	JWT               *JWTConfig    `json:"jwt" validate:"dive"`
	Mailer            *MailerConfig `json:"mailer" validate:"dive"`
	Cookie            *CookieConfig `json:"cookie" validate:"dive"`
	DisableSignup     bool          `json:"disable_signup" split_words:"true"`
}

type CSRFConfig

type CSRFConfig struct {
	Enabled bool   `json:"enabled" default:"true"`
	AuthKey string `json:"auth_key" split_words:"true" validate:"required,gte=32"`
}

CSRFConfig holds all the CSRF related configuration.

type Config

type Config struct {
	SiteURL  string          `json:"site_url" split_words:"true"`
	Logger   *logger.Config  `json:"logger"`
	Debug    *DebugConfig    `json:"debug" validate:"dive"`
	HTTP     *HTTPConfig     `json:"http" validate:"dive"`
	Hashers  *HashersConfig  `json:"hashers" validate:"dive"`
	Database *DatabaseConfig `json:"database" validate:"dive"`
	API      *APIConfig      `json:"api" validate:"dive"`
	SMTP     *SMTPConfig     `json:"smtp" validate:"dive"`
}

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig loads configuration.

func (*Config) ApplyDefaults

func (config *Config) ApplyDefaults()

ApplyDefaults sets defaults for a configuration.

func (*Config) Merge

func (config *Config) Merge(c *Config) (*Config, error)

Merge merges present configuration with another one.

func (*Config) Validate

func (config *Config) Validate() error

Validate validates configuration.

type CookieConfig

type CookieConfig struct {
	Key             string `json:"key" validate:"required,gt=1"`
	DurationSeconds int    `json:"duration" envconfig:"duration" default:"86400"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Type        string              `json:"type" validate:"required"`
	JSONMutexDB *jsonmutexdb.Config `json:"jsonmutexdb"`
	LevelDB     *leveldb.Config     `json:"leveldb"`
}

type DebugConfig

type DebugConfig struct {
	Enabled bool   `json:"enabled" default:"true"`
	Addr    string `json:"addr" default:":6060"`
}

type EmailContentConfig

type EmailContentConfig struct {
	Confirmation string `json:"confirmation"`
	Recovery     string `json:"recovery"`
	EmailChange  string `json:"email_change" split_words:"true"`
}

EmailContentConfig holds the configuration for emails, both subjects and template URLs.

type HTTPConfig

type HTTPConfig struct {
	Addr string `json:"addr" default:":8080"`
}

type HashersConfig

type HashersConfig struct {
	Argon2 *hash.HasherArgon2Config `json:"argon2" required:"true"`
}

type JWTConfig

type JWTConfig struct {
	ClaimsNamespace string        `json:"claims_namespace" split_words:"true" validate:"required,gte=3"`
	Exp             int           `json:"exp" default:"3600"`
	Aud             string        `json:"aud"`
	AcceptableSkew  time.Duration `json:"acceptable_skew" split_words:"true" required:"true" default:"30s"`
	DefaultKey      string        `json:"default_key" split_words:"true" validate:"required"`
	KeysJSON        string        `json:"-" envconfig:"keys" validate:"required"`
}

JWTConfig holds all the JWT related configuration.

type MailerConfig

type MailerConfig struct {
	Autoconfirm  bool               `json:"autoconfirm" default:"false"`
	ValidateHost bool               `json:"validate_host" split_words:"true" default:"false"`
	Subjects     EmailContentConfig `json:"subjects"`
	Templates    EmailContentConfig `json:"templates"`
	URLPaths     EmailContentConfig `json:"url_paths" split_words:"true"`
}

type SMTPConfig

type SMTPConfig struct {
	MaxFrequency time.Duration `json:"max_frequency" split_words:"true" default:"5m"`
	Host         string        `json:"host"`
	Port         int           `json:"port,omitempty" default:"587"`
	User         string        `json:"user"`
	Pass         string        `json:"-"`
	AdminEmail   string        `json:"admin_email" split_words:"true"`
}

Jump to

Keyboard shortcuts

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