values

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT = DynamicValues{
	SessionTTL:      time.Hour,
	LoginTTL:        time.Minute * 15,
	LoginFailures:   5,
	IpLoginFailures: 10,
	IpWhitelist:     []string{},
	IpBlacklist:     []string{},
	PwdStrategy:     1,
	PwdTTL:          time.Hour * 24 * 365,
}

Functions

This section is empty.

Types

type Controller

type Controller struct {
	Service *Service
}

func (*Controller) Get

func (*Controller) Remove

func (x *Controller) Remove(_ context.Context, c *app.RequestContext)

func (*Controller) Set

type DynamicValues

type DynamicValues struct {
	// session period (seconds)
	// User inactivity for 1 hour, session will end
	SessionTTL time.Duration
	// login lockout time
	// Locked for 15 minutes
	LoginTTL time.Duration
	// Maximum number of login failures for a user
	// If you fail to log in 5 times consecutively within a limited time (lockout time),
	// your account will be locked
	LoginFailures int64
	// Maximum number of login failures for the user's host IP
	// If the same host IP fails to log in 10 times continuously, the IP will be locked (period is the login_ttl)
	IpLoginFailures int64
	// IP whitelist
	// Whitelisting IPs does not restrict login failure lockouts
	IpWhitelist []string
	// IP blacklist
	// will ban all access
	IpBlacklist []string
	// password strength
	// 0: unlimited
	// 1: uppercase and lowercase letters
	// 2: uppercase and lowercase letters, numbers
	// 3: uppercase and lowercase letters, numbers, special characters
	PwdStrategy int
	// password validity period
	// After the password expires, it is mandatory to change the password, 0: permanently valid
	PwdTTL time.Duration
	// Public Cloud
	// Supported: Tencent Cloud `tencent`
	// Plan: AWS `aws`
	Cloud string
	// Tencent Cloud API Secret Id
	// It is recommended to use CAM to assign the required permissions
	TencentSecretId string
	// Tencent Cloud API Secret Key
	TencentSecretKey string `secret:"*"`
	// Tencent Cloud COS bucket name
	TencentCosBucket string
	// Tencent Cloud COS bucket region, for example: ap-guangzhou
	TencentCosRegion string
	// Tencent Cloud COS bucket pre-signature validity period, unit: second
	TencentCosExpired int64
	// Tencent Cloud COS bucket upload size limit, unit: KB
	TencentCosLimit int64
	// Enterprise Collaboration
	// Lark App ID
	LarkAppId string
	// Lark application key
	LarkAppSecret string `secret:"*"`
	// Lark event subscription security verification data key
	LarkEncryptKey string `secret:"*"`
	// Lark Event Subscription Verification Token
	LarkVerificationToken string `secret:"*"`
	// Third-party registration-free authorization code redirection address
	RedirectUrl string
	// Public email service SMTP address
	EmailHost string
	// Public email SMTP port number (SSL)
	EmailPort int
	// Public email username
	EmailUsername string
	// Public email password
	EmailPassword string `secret:"*"`
	// Openapi url
	OpenapiUrl string
	// Openapi application authentication key
	// API gateway application authentication https://cloud.tencent.com/document/product/628/55088
	OpenapiKey string
	// Openapi Application Authentication Secret
	OpenapiSecret string `secret:"*"`
	// RestControls
	RestControls map[string]*RestControl
}

type GetDto

type GetDto struct {
	Keys []string `query:"keys"`
}

type Option

type Option func(x *Service)

func SetCipher

func SetCipher(v *cipher.Cipher) Option

func SetDynamicValues

func SetDynamicValues(v *DynamicValues) Option

func SetKeyValue

func SetKeyValue(v nats.KeyValue) Option

func SetNamespace

func SetNamespace(v string) Option

type RemoveDto

type RemoveDto struct {
	Key string `query:"key,requred"`
}

type RestControl

type RestControl struct {
	Event bool
	Keys  []string
}

type Service

type Service struct {
	Namespace string
	KeyValue  nats.KeyValue
	Cipher    *cipher.Cipher
	Values    *DynamicValues
}

func New

func New(options ...Option) *Service

func (*Service) Fetch

func (x *Service) Fetch(v interface{}) (err error)

func (*Service) Get

func (x *Service) Get(keys ...string) (data map[string]interface{}, err error)

func (*Service) Remove

func (x *Service) Remove(keys ...string) (err error)

func (*Service) Reset

func (x *Service) Reset() (err error)

func (*Service) Set

func (x *Service) Set(update map[string]interface{}) (err error)

func (*Service) Sync

func (x *Service) Sync(ok chan interface{}) (err error)

func (*Service) Update

func (x *Service) Update(data interface{}) (err error)

type SetDto

type SetDto struct {
	Update map[string]interface{} `json:"update,required"`
}

Jump to

Keyboard shortcuts

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