conf

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 12 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureLogging

func ConfigureLogging(config *LoggingConfig) (*logrus.Entry, error)

func ConfigureTracing

func ConfigureTracing(tc *TracingConfig)

Types

type Configuration

type Configuration struct {
	SiteURL       string                `json:"site_url" split_words:"true" required:"true"`
	JWT           JWTConfiguration      `json:"jwt"`
	SMTP          SMTPConfiguration     `json:"smtp"`
	Mailer        MailerConfiguration   `json:"mailer"`
	External      ProviderConfiguration `json:"external"`
	DisableSignup bool                  `json:"disable_signup" split_words:"true"`
	Webhook       WebhookConfig         `json:"webhook" split_words:"true"`
	Cookie        struct {
		Key      string `json:"key"`
		Duration int    `json:"duration"`
	} `json:"cookies"`
}

Configuration holds all the per-instance configuration.

func LoadConfig

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

LoadConfig loads per-instance configuration.

func (*Configuration) ApplyDefaults

func (config *Configuration) ApplyDefaults()

ApplyDefaults sets defaults for a Configuration

func (*Configuration) Scan

func (config *Configuration) Scan(src interface{}) error

func (*Configuration) Value

func (config *Configuration) Value() (driver.Value, error)

type DBConfiguration

type DBConfiguration struct {
	Driver         string `json:"driver" required:"true"`
	URL            string `json:"url" envconfig:"DATABASE_URL" required:"true"`
	Namespace      string `json:"namespace"`
	MigrationsPath string `json:"migrations_path" split_words:"true" default:"./migrations"`
}

DBConfiguration holds all the database related configuration.

type EmailContentConfiguration

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

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

type EmailProviderConfiguration

type EmailProviderConfiguration struct {
	Disabled bool `json:"disabled"`
}

type GlobalConfiguration

type GlobalConfiguration struct {
	API struct {
		Host            string
		Port            int `envconfig:"PORT" default:"8081"`
		Endpoint        string
		RequestIDHeader string `envconfig:"REQUEST_ID_HEADER"`
	}
	DB                DBConfiguration
	External          ProviderConfiguration
	Logging           LoggingConfig `envconfig:"LOG"`
	OperatorToken     string        `split_words:"true" required:"true"`
	MultiInstanceMode bool
	Tracing           TracingConfig
	SMTP              SMTPConfiguration
	RateLimitHeader   string `split_words:"true"`
}

GlobalConfiguration holds all the configuration that applies to all instances.

func LoadGlobal

func LoadGlobal(filename string) (*GlobalConfiguration, error)

LoadGlobal loads configuration from file and environment variables.

type JWTConfiguration

type JWTConfiguration struct {
	Secret           string `json:"secret" required:"true"`
	Exp              int    `json:"exp"`
	Aud              string `json:"aud"`
	AdminGroupName   string `json:"admin_group_name" split_words:"true"`
	DefaultGroupName string `json:"default_group_name" split_words:"true"`
}

JWTConfiguration holds all the JWT related configuration.

type LoggingConfig

type LoggingConfig struct {
	Level            string                 `mapstructure:"log_level" json:"log_level"`
	File             string                 `mapstructure:"log_file" json:"log_file"`
	DisableColors    bool                   `mapstructure:"disable_colors" split_words:"true" json:"disable_colors"`
	QuoteEmptyFields bool                   `mapstructure:"quote_empty_fields" split_words:"true" json:"quote_empty_fields"`
	TSFormat         string                 `mapstructure:"ts_format" json:"ts_format"`
	Fields           map[string]interface{} `mapstructure:"fields" json:"fields"`
}

type MailerConfiguration

type MailerConfiguration struct {
	Autoconfirm bool                      `json:"autoconfirm"`
	Subjects    EmailContentConfiguration `json:"subjects"`
	Templates   EmailContentConfiguration `json:"templates"`
	URLPaths    EmailContentConfiguration `json:"url_paths"`
}

type OAuthProviderConfiguration

type OAuthProviderConfiguration struct {
	ClientID    string `json:"client_id" split_words:"true"`
	Secret      string `json:"secret"`
	RedirectURI string `json:"redirect_uri" split_words:"true"`
	URL         string `json:"url"`
	Enabled     bool   `json:"enabled"`
}

OAuthProviderConfiguration holds all config related to external account providers.

func (*OAuthProviderConfiguration) Validate

func (o *OAuthProviderConfiguration) Validate() error

type ProviderConfiguration

type ProviderConfiguration struct {
	Bitbucket   OAuthProviderConfiguration `json:"bitbucket"`
	Github      OAuthProviderConfiguration `json:"github"`
	Gitlab      OAuthProviderConfiguration `json:"gitlab"`
	Google      OAuthProviderConfiguration `json:"google"`
	Facebook    OAuthProviderConfiguration `json:"facebook"`
	Email       EmailProviderConfiguration `json:"email"`
	Saml        SamlProviderConfiguration  `json:"saml"`
	RedirectURL string                     `json:"redirect_url"`
}

type SMTPConfiguration

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

type SamlProviderConfiguration

type SamlProviderConfiguration struct {
	Enabled     bool   `json:"enabled"`
	MetadataURL string `json:"metadata_url" envconfig:"METADATA_URL"`
	APIBase     string `json:"api_base" envconfig:"API_BASE"`
	Name        string `json:"name"`
	SigningCert string `json:"signing_cert" envconfig:"SIGNING_CERT"`
	SigningKey  string `json:"signing_key" envconfig:"SIGNING_KEY"`
}

type TracingConfig

type TracingConfig struct {
	Enabled     bool `default:"false"`
	Host        string
	Port        string
	ServiceName string `default:"gotrue" split_words:"true"`
	Tags        map[string]string
}

type WebhookConfig

type WebhookConfig struct {
	URL        string   `json:"url"`
	Retries    int      `json:"retries"`
	TimeoutSec int      `json:"timeout_sec"`
	Secret     string   `json:"secret"`
	Events     []string `json:"events"`
}

func (*WebhookConfig) HasEvent

func (w *WebhookConfig) HasEvent(event string) bool

Jump to

Keyboard shortcuts

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