backend

package
v0.0.0-...-88f351d Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: MIT, CC-BY-4.0, MIT, + 1 more Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoomPage          = "room.html"
	ResetPasswordPage = "reset-password.html"
	VerifyEmailPage   = "verify-email.html"
)
View Source
const (
	MaxKeepAliveMisses      = 3
	MaxAuthFailures         = 5
	MaxConsecutiveThrottled = 10
)

Variables

View Source
var (
	KeepAlive     = 20 * time.Second
	FastKeepAlive = 2 * time.Second

	ErrUnresponsive = fmt.Errorf("connection unresponsive")
	ErrReplaced     = fmt.Errorf("connection replaced")
	ErrFlooding     = fmt.Errorf("connection flooding")
)
View Source
var (
	Config = ServerConfig{
		CommonEmailParams: &proto.DefaultCommonEmailParams,
	}
)
View Source
var PageScenarios = map[string]map[string]templates.TemplateTest{
	RoomPage: map[string]templates.TemplateTest{
		"default": templates.TemplateTest{
			Data: map[string]interface{}{"RoomName": "test"},
		},
	},
	ResetPasswordPage: map[string]templates.TemplateTest{
		"default": templates.TemplateTest{
			Data: map[string]interface{}{
				"Data": map[string]interface{}{
					"email":        "test@test.invalid",
					"confirmation": "confirmationcode",
				},
			},
		},
	},
	VerifyEmailPage: map[string]templates.TemplateTest{
		"default": templates.TemplateTest{
			Data: map[string]interface{}{
				"Data": map[string]interface{}{
					"email":        "test@test.invalid",
					"confirmation": "confirmationcode",
				},
			},
		},
	},
}

Functions

func IntegrationTest

func IntegrationTest(t *testing.T, factory proto.BackendFactory)

func LoadPageTemplates

func LoadPageTemplates(path string) (*templates.Templater, error)

func NewIdentity

func NewIdentity(id proto.UserID, name string) proto.Identity

func RegisterBackend

func RegisterBackend(name string, factory proto.BackendFactory)

func ValidatePageTemplates

func ValidatePageTemplates(templater *templates.Templater) []error

Types

type CSV

type CSV []string

func (*CSV) Set

func (k *CSV) Set(flags string) error

func (*CSV) String

func (k *CSV) String() string

type ClusterConfig

type ClusterConfig struct {
	ServerID string `yaml:"server-id"`
	Era      string `yaml:"-"`
	Version  string `yaml:"-"`
	EtcdHost string `yaml:"etcd-host,omitempty"`
	EtcdHome string `yaml:"etcd,omitempty"`
}

func (*ClusterConfig) DescribeSelf

func (c *ClusterConfig) DescribeSelf() *cluster.PeerDesc

func (*ClusterConfig) EtcdCluster

func (c *ClusterConfig) EtcdCluster(ctx scope.Context) (cluster.Cluster, error)

type ConsoleConfig

type ConsoleConfig struct {
	HostKey  string `yaml:"host-key-file"`
	AuthKeys CSV    `yaml:"auth-key-files,flow"`
}

type DatabaseConfig

type DatabaseConfig struct {
	DSN          string `yaml:"dsn"`
	MaxConnCount int    `yaml:"max-connection-count,omitempty"`
}

type EmailConfig

type EmailConfig struct {
	Server     string `yaml:"server"`
	AuthMethod string `yaml:"auth_method"` // must be "", "CRAM-MD5", or "PLAIN"
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
	Identity   string `yaml:"identity"`
	UseTLS     bool   `yaml:"use_tls"`
	Templates  string `yaml:"templates"`
}

func (*EmailConfig) Get

type GeoIPConfig

type GeoIPConfig struct {
	UserID     string `yaml:"user-id"`
	LicenseKey string `yaml:"license-key"`
}

func (*GeoIPConfig) Api

func (c *GeoIPConfig) Api() *geoip2.Api

type KMSConfig

type KMSConfig struct {
	AES256 struct {
		KeyFile string `yaml:"key-file"`
	} `yaml:"aes256,omitempty"`

	Amazon struct {
		Region string `yaml:"region"`
		KeyID  string `yaml:"key-id"`
	} `yaml:"amazon,omitempty"`
}

func (*KMSConfig) Get

func (kc *KMSConfig) Get() (security.KMS, error)

type Server

type Server struct {
	ID  string
	Era string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(heim *proto.Heim, id, era string) (*Server, error)

func (*Server) AllowRoomCreation

func (s *Server) AllowRoomCreation(allow bool)

func (*Server) NewAccountMinAgentAge

func (s *Server) NewAccountMinAgentAge(age time.Duration)

func (*Server) RoomEntryMinAgentAge

func (s *Server) RoomEntryMinAgentAge(age time.Duration)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) SetInsecureCookies

func (s *Server) SetInsecureCookies(allow bool)

type ServerConfig

type ServerConfig struct {
	*proto.CommonEmailParams `yaml:"site"`

	AllowRoomCreation     bool          `yaml:"allow_room_creation"`
	NewAccountMinAgentAge time.Duration `yaml:"new_account_min_agent_age"`
	RoomEntryMinAgentAge  time.Duration `yaml:"room_entry_min_agent_age"`
	SetInsecureCookies    bool          `yaml:"set_insecure_cookies"`

	StaticPath string `yaml:"static_path"`

	Cluster ClusterConfig  `yaml:"cluster,omitempty"`
	Console ConsoleConfig  `yaml:"console,omitempty"`
	DB      DatabaseConfig `yaml:"database"`
	KMS     KMSConfig      `yaml:"kms"`
	Email   EmailConfig    `yaml:"email"`
	GeoIP   GeoIPConfig    `yaml:"geoip"`
}

func (*ServerConfig) GetBackend

func (cfg *ServerConfig) GetBackend(heim *proto.Heim) (proto.Backend, error)

func (*ServerConfig) Heim

func (cfg *ServerConfig) Heim(ctx scope.Context) (*proto.Heim, error)

func (*ServerConfig) LoadFromEtcd

func (cfg *ServerConfig) LoadFromEtcd(c cluster.Cluster) error

func (*ServerConfig) LoadFromFile

func (cfg *ServerConfig) LoadFromFile(path string) error

func (*ServerConfig) String

func (cfg *ServerConfig) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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