config

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultAdminUsername = "admin"
	DefaultAdminPassword = "password"
	DefaultConfigFile    = "app.yaml"
)

Variables

View Source
var AppConfig *appConfig
View Source
var (
	Viper *viper.Viper
)

globals

Functions

func AppConfigFromYaml

func AppConfigFromYaml(yamlString string) (*appConfig, error)

func GetAppName

func GetAppName() string

func GetHost

func GetHost() string

func GetInsecure added in v0.2.0

func GetInsecure() bool

func GetPort

func GetPort() int

func NewAppConfig

func NewAppConfig() *appConfig

func SaveConfig

func SaveConfig() error

for the time being, viper does not support saving the config back to disk.

This is about to arrive in: https://github.com/spf13/viper/pull/287

func UserNewContext

func UserNewContext(ctx context.Context, u *User) context.Context

Types

type Settings

type Settings struct {
	Initialized bool
	Debug       bool
	LogLevel    string `validate:"eq=debug|eq=info|eq=warning|eq=error|eq=fatal|eq=panic"`
}

type User

type User struct {
	Id string `validate:"uuid4"`
	// Username is globally unique from the user's perspective.  It must
	// either be in email address format, or the special case 'admin'
	Username     string `validate:"required,email|eq=admin"`
	Name         string `validate:"required,printascii"` // TODO: plan on escaping and handling all printable ASCII
	PasswordHash string `validate:"required"`            // Hashed and Salted by the bcrypt library
	Role         string `validate:"eq=user|eq=admin"`
	Phone        string `validate:"phone,min=7"`
}

func NewUser

func NewUser() *User

func UserFromContext

func UserFromContext(ctx context.Context) (*User, bool)

FromContext returns the User value stored in ctx, if any.

func (*User) GenerateJwt

func (u *User) GenerateJwt(secondsToExpiration int64) (string, error)

func (*User) GetRole

func (u *User) GetRole() (gorbac.Role, error)

func (*User) HashPassword

func (u *User) HashPassword(password string) error

func (*User) ValidatePassword

func (u *User) ValidatePassword(password string) error

Jump to

Keyboard shortcuts

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