user

package
v0.0.0-...-6d05f87 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// salt length in byte for key derivation
	SALT_LEN = 16
	// derived key length
	KEY_LEN = 16
	// iteration times for PBKDF2
	ITER_TIME = 128

	// auth code type for signup
	CODE_TYPE_SIGNUP = "signup"
	// auth code type for login
	CODE_TYPE_LOGIN = "login"
	// cache the request time of code to prevent request code frequently
	CODE_REQ_TIME = "time"
	// field for cache extension field
	EXTENSION = "ext"

	// waiting for CODE_REQ_DURATION seconds is required to request a new code
	CODE_REQ_DURATION = 60
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyInfo

type APIKeyInfo struct {
	Exchange  string `json:"exchange"`
	APIKey    string `json:"api_key"`
	APISecret string `json:"api_secret"`
}

func (*APIKeyInfo) Persist

func (k *APIKeyInfo) Persist(username string) error

func (*APIKeyInfo) Valid

func (k *APIKeyInfo) Valid() bool

type Login

type Login struct {
	Signup
}

func (*Login) Valid

func (l *Login) Valid() (bool, error)

type ReqCode

type ReqCode struct {
	Username string `json:"username"`
	CodeType string `json:"code_type"`
}

func (*ReqCode) Valid

func (r *ReqCode) Valid() bool

type SendCode

type SendCode struct {
	Username string `json:"username"`
	CodeType string `json:"code_type"`
	Code     string `json:"code"`
}

func (*SendCode) CleanupCode

func (s *SendCode) CleanupCode()

clean up common key

func (*SendCode) Valid

func (s *SendCode) Valid() bool

type Signup

type Signup struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

func (*Signup) Persist

func (s *Signup) Persist() error

func (*Signup) Valid

func (s *Signup) Valid() (bool, error)

type User

type User struct {
	APIKeyInfo
	Username string
	// contains filtered or unexported fields
}

func (*User) AddStrategy

func (u *User) AddStrategy(s strategy.Strategy)

func (*User) GetStrategy

func (u *User) GetStrategy(id string) strategy.Strategy

func (*User) GetStrategyInfo

func (u *User) GetStrategyInfo() []strategy.Strategy

func (*User) RecoverFromLocalDB

func (u *User) RecoverFromLocalDB() error

func (*User) RemoveStrategy

func (u *User) RemoveStrategy(id string)

func (*User) Valid

func (u *User) Valid() bool

type UserStore

type UserStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func GetUserStore

func GetUserStore() *UserStore

func (*UserStore) AddToCache

func (us *UserStore) AddToCache(u *User) error

func (*UserStore) ExistInCache

func (us *UserStore) ExistInCache(name string) (*User, bool)

func (*UserStore) Find

func (us *UserStore) Find(name string) (*User, error)

func (*UserStore) Status

func (us *UserStore) Status() (int, int)

Jump to

Keyboard shortcuts

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