cmd

package
v0.0.0-...-84b44bb Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package cmd contains all cli commands, their arguments and tests to them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddUser

type AddUser struct {
	Location string `long:"location" env:"LOCATION" description:"location of all db files" required:"true"`
	User     struct {
		ID         string `long:"id" env:"ID" required:"false"`
		Email      string `long:"email" env:"EMAIL" required:"true"`
		Password   string `long:"password" env:"PASSWORD" required:"true" `
		Privileges string `long:"privileges" env:"PRIVILEGES" required:"true" description:"JSON-specified list of privileges"`
	} `group:"user" namespace:"user" env-namespace:"USER"`

	BCryptCost int    `long:"bcrypt_cost" env:"BCRYPT_COST" description:"bcrypt cost for hashing user password" default:"10"`
	DBConnStr  string `long:"db_conn_str" env:"DB_CONN_STR" required:"true" description:"connection string to db"`

	CommonOpts
}

AddUser adds user to the database with the specified user data

func (*AddUser) Execute

func (a *AddUser) Execute(_ []string) error

Execute runs http web server

type AdminGroup

type AdminGroup struct {
	Email    string `long:"email" env:"EMAIL" description:"default admin email" required:"true"`
	Password string `long:"password" env:"PASSWORD" description:"default admin password" required:"true"`
}

AdminGroup defines options group for admin params

type CommonOptionsCommander

type CommonOptionsCommander interface {
	SetCommon(commonOpts CommonOpts)
	Execute(args []string) error
}

CommonOptionsCommander extends flags.Commander with SetCommon All commands should implement this interfaces

type CommonOpts

type CommonOpts struct {
	Version string
}

CommonOpts sets externally from main, shared across all commands

func (*CommonOpts) SetCommon

func (c *CommonOpts) SetCommon(opts CommonOpts)

SetCommon satisfies CommonOptionsCommander interface and sets common option fields The method called by main for each command

type DirectProvider

type DirectProvider struct {
	*provider.DirectHandler
}

DirectProvider overrides the LoginHandler to allow to pass the token string inside the response body fixme A HUGE KLUDGE

func (*DirectProvider) LoginHandler

func (p *DirectProvider) LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler just does the same as provider.DirectHandler.LoginHandler but adds the token string inside the response body

type SMTPGroup

type SMTPGroup struct {
	Host     string        `long:"host" env:"HOST" description:"SMTP host"`
	Port     int           `long:"port" env:"PORT" description:"SMTP port"`
	Username string        `long:"username" env:"USERNAME" description:"SMTP username"`
	Password string        `long:"password" env:"PASSWORD" description:"SMTP password"`
	TLS      bool          `long:"tls" env:"TLS" description:"enable TLS"`
	Timeout  time.Duration `long:"timeout" env:"TIMEOUT" default:"10s" description:"SMTP TCP connection timeout"`

	From string `long:"from" env:"FROM" required:"true" description:"from email address"`
}

SMTPGroup defines options for SMTP server connection, used in auth and notify modules

type Server

type Server struct {
	Location string `long:"location" env:"LOCATION" description:"location of all db files" required:"true"`

	ServiceURL string `long:"service_url" env:"SERVICE_URL" description:"http service url" required:"true"`
	Port       int    `long:"service_port" env:"SERVICE_PORT" description:"http server port" default:"8080"`

	Auth struct {
		TTL struct {
			JWT    time.Duration `long:"jwt" env:"JWT" default:"5m" description:"jwt TTL"`
			Cookie time.Duration `long:"cookie" env:"COOKIE" default:"200h" description:"auth cookie TTL"`
		} `group:"ttl" namespace:"ttl" env-namespace:"TTL"`
		Secret     string `long:"secret" env:"SECRET" description:"secret for authentication tokens" required:"true"`
		BCryptCost int    `long:"bcrypt_cost" env:"BCRYPT_COST" description:"bcrypt cost for hashing user password" default:"10"`
	} `group:"auth" namespace:"auth" env-namespace:"AUTH"`
	DBConnStr string `long:"db_conn_str" env:"DB_CONN_STR" required:"true" description:"connection string to db"`

	Admin AdminGroup `group:"admin" namespace:"admin" env-namespace:"ADMIN"`

	CommonOpts
}

Server runs REST API web server

func (*Server) Execute

func (s *Server) Execute(_ []string) error

Execute runs http web server

Jump to

Keyboard shortcuts

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