config

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cnf = &Config{
	Hostname: "id.resonate.coop",
	CSRF: CSRFConfig{
		Key:     "",
		Origins: "upload.resonate.is",
	},
	Mailgun: MailgunConfig{
		Sender: "members@resonate.is",
		Key:    "",
		Domain: "mailgun.resonate.is",
	},
	Database: DatabaseConfig{
		PSN:          "postgres://resonate_dev_user:password@127.0.0.1:5432/resonate_dev?sslmode=disable",
		MaxIdleConns: 5,
		MaxOpenConns: 5,
	},
	Oauth: OauthConfig{
		AccessTokenLifetime:  3600,
		RefreshTokenLifetime: 1209600,
		AuthCodeLifetime:     3600,
	},
	Session: SessionConfig{
		Secret:   "test_secret",
		Path:     "/",
		MaxAge:   86400 * 7,
		HTTPOnly: true,
	},
	Clients: []ClientConfig{
		{
			ConnectUrl:  "https://upload.resonate.is/api/user/connect/resonate",
			Name:        "Upload Tool",
			Description: "for creators",
		},
	},
	IsDevelopment:       true,
	Port:                ":8080",
	ApplicationURL:      "https://upload.resonate.is",
	Origins:             []string{"upload.resonate.is", "beta.stream.resonate.is"},
	EmailTokenSecretKey: "super secret key",
	UserAPIHostname:     "0.0.0.0",
	UserAPIPort:         ":11000",
}

Cnf ... Let's start with some sensible defaults

Functions

This section is empty.

Types

type Backend

type Backend interface {
	LoadConfig() (*Config, error)
	RefreshConfig(newCnf *Config)
	InitConfigBackend()
}

Backend defines a configuration backend, implement this interface to support additional backends

type CSRFConfig added in v1.0.5

type CSRFConfig struct {
	Key     string
	Origins string
}

type ClientConfig added in v1.0.5

type ClientConfig struct {
	ConnectUrl  string `json:"connectUrl"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

type Config

type Config struct {
	Hostname            string
	CSRF                CSRFConfig
	Mailgun             MailgunConfig
	Database            DatabaseConfig
	Oauth               OauthConfig
	Session             SessionConfig
	IsDevelopment       bool
	Clients             []ClientConfig
	Port                string
	ApplicationURL      string
	Origins             []string
	EmailTokenSecretKey string
	UserAPIHostname     string
	UserAPIPort         string
}

Config stores all configuration options

func NewConfig

func NewConfig(mustLoadOnce bool, keepReloading bool, backendType string) *Config

NewConfig loads configuration from etcd and returns *Config struct It also starts a goroutine in the background to keep config up-to-date

type DatabaseConfig

type DatabaseConfig struct {
	PSN          string
	MaxIdleConns int
	MaxOpenConns int
}

DatabaseConfig stores database connection options

type MailgunConfig added in v1.0.5

type MailgunConfig struct {
	Sender string
	Key    string
	Domain string
}

type OauthConfig

type OauthConfig struct {
	AccessTokenLifetime  int
	RefreshTokenLifetime int
	AuthCodeLifetime     int
}

OauthConfig stores oauth service configuration options

type SessionConfig

type SessionConfig struct {
	Secret string
	Domain string
	Path   string
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
	// MaxAge>0 means Max-Age attribute present and given in seconds.
	MaxAge int
	Secure bool
	// When you tag a cookie with the HttpOnly flag, it tells the browser that
	// this particular cookie should only be accessed by the server.
	// Any attempt to access the cookie from client script is strictly forbidden.
	HTTPOnly bool
	SameSite bool
}

SessionConfig stores session configuration for the web app

Jump to

Keyboard shortcuts

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