kv

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 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,
}
View Source
var Provides = wire.NewSet(
	wire.Struct(new(Controller), "*"),
	wire.Struct(new(Service), "*"),
)
View Source
var SECRET = map[string]bool{
	"tencent_secret_key":        true,
	"feishu_app_secret":         true,
	"feishu_encrypt_key":        true,
	"feishu_verification_token": true,
	"email_password":            true,
	"openapi_secret":            true,
}

Functions

This section is empty.

Types

type Controller

type Controller struct {
	KVService *Service
}

func (*Controller) Get

func (*Controller) Remove

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

func (*Controller) Set

type DSLOption

type DSLOption struct {
	Event bool
	Keys  []string
}

type DynamicValues

type DynamicValues struct {
	// session period (seconds)
	// User inactivity for 1 hour, session will end
	SessionTTL time.Duration `json:"session_ttl"`
	// login lockout time
	// Locked for 15 minutes
	LoginTTL time.Duration `json:"login_ttl"`
	// 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 `json:"login_failures"`
	// 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 `json:"ip_login_failures"`
	// IP whitelist
	// Whitelisting IPs does not restrict login failure lockouts
	IpWhitelist []string `json:"ip_whitelist"`
	// IP blacklist
	// will ban all access
	IpBlacklist []string `json:"ip_blacklist"`
	// 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 `json:"pwd_strategy"`
	// password validity period
	// After the password expires, it is mandatory to change the password, 0: permanently valid
	PwdTTL time.Duration `json:"pwd_ttl"`
	// Public Cloud
	// Supported: Tencent Cloud `tencent`
	// Plan: AWS `aws`, Alibaba Cloud `aliyun`
	Cloud string `json:"cloud"`
	// Tencent Cloud API Secret Id
	// It is recommended to use CAM to assign the required permissions
	TencentSecretId string `json:"tencent_secret_id"`
	// Tencent Cloud API Secret Key
	TencentSecretKey string `json:"tencent_secret_key,omitempty"`
	// Tencent Cloud COS bucket name
	TencentCosBucket string `json:"tencent_cos_bucket,omitempty"`
	// Tencent Cloud COS bucket region, for example: ap-guangzhou
	TencentCosRegion string `json:"tencent_cos_region"`
	// Tencent Cloud COS bucket pre-signature validity period, unit: second
	TencentCosExpired int `json:"tencent_cos_expired"`
	// Tencent Cloud COS bucket upload size limit, unit: KB
	TencentCosLimit int64 `json:"tencent_cos_limit"`
	// Enterprise Collaboration
	// Feishu App ID
	FeishuAppId string `json:"feishu_app_id"`
	// Feishu application key
	FeishuAppSecret string `json:"feishu_app_secret,omitempty"`
	// Feishu event subscription security verification data key
	FeishuEncryptKey string `json:"feishu_encrypt_key,omitempty"`
	// Feishu Event Subscription Verification Token
	FeishuVerificationToken string `json:"feishu_verification_token,omitempty"`
	// Third-party registration-free authorization code redirection address
	RedirectUrl string `json:"redirect_url"`
	// Public email service SMTP address
	EmailHost string `json:"email_host"`
	// Public email SMTP port number (SSL)
	EmailPort string `json:"email_port"`
	// Public email username
	EmailUsername string `json:"email_username"`
	// Public email password
	EmailPassword string `json:"email_password,omitempty"`
	// Openapi url
	OpenapiUrl string `json:"openapi_url"`
	// Openapi application authentication key
	// API gateway application authentication https://cloud.tencent.com/document/product/628/55088
	OpenapiKey string `json:"openapi_key"`
	// Openapi Application Authentication Secret
	OpenapiSecret string `json:"openapi_secret,omitempty"`
	// DSL Control Variables
	DSL map[string]*DSLOption `json:"dsl,omitempty"`
}

type GetDto

type GetDto struct {
	Keys map[string]int64 `query:"keys" vd:"len($)==0 || range($,regexp('^[a-z_]+$',#k));msg:'Keys must be lowercase letters with underscores'"`
}

type KV

type KV struct {
	Namespace     string
	KeyValue      nats.KeyValue
	DynamicValues *DynamicValues
}

func New

func New(options ...Option) *KV

type Option

type Option func(x *KV)

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 `path:"key,required" vd:"regexp('^[a-z_]+$');msg:'Keys must be lowercase letters with underscores'"`
}

type Service

type Service struct {
	*KV
}

func (*Service) Get

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

func (*Service) Load

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

func (*Service) Remove

func (x *Service) Remove(key string) (err error)

func (*Service) Set

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

func (*Service) Sync

func (x *Service) Sync(option *SyncOption) (err error)

func (*Service) Update

func (x *Service) Update(values map[string]interface{}) (err error)

type SetDto

type SetDto struct {
	Data map[string]interface{} `json:"data,required" vd:"len($)>0 && range($,regexp('^[a-z_]+$',#k));msg:'Keys must be lowercase letters with underscores'"`
}

type SyncOption

type SyncOption struct {
	Updated chan *DynamicValues
	Err     chan error
}

Jump to

Keyboard shortcuts

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