You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/cfg/sms.go

52 lines
1.4 KiB
Go

2 months ago
package cfg
import (
"time"
)
// Config 短信验证码配置
type SMSConfig struct {
// 区域配置 +86/.../global
Regions map[string]RegionConfig `json:"regions"`
Default RegionConfig `json:"default"` // 默认区域配置
// 全局配置
Global GlobalConfig `json:"global"`
}
// RegionConfig 区域配置
type RegionConfig struct {
Provider string `json:"provider"` // aliyun, tencent
TemplateID string `json:"template_id"` // 模板ID
Key string `json:"key"`
Secret string `json:"secret"`
SignName string `json:"sign_name"`
Endpoint string `json:"endpoint"`
}
// GlobalConfig 全局配置
type GlobalConfig struct {
CodeLength int `json:"code_length" usage:"验证码长度默认6位"`
CodeExpiry time.Duration `json:"code_expiry" usage:"验证码有效期默认5分钟"`
SendInterval time.Duration `json:"send_interval" usage:"发送间隔默认60秒"`
MaxAttempts int `json:"max_attempts" usage:"最大重试次数默认3次"`
MaxDailyCount int `json:"max_daily_count" usage:"每日最大发送次数默认100次,0禁用-1不限制"`
}
// DefaultConfig 默认配置
func defaultSMS() *SMSConfig {
return &SMSConfig{
Global: GlobalConfig{
CodeLength: 6,
CodeExpiry: 5 * time.Minute,
SendInterval: 60 * time.Second,
MaxAttempts: 3,
MaxDailyCount: 100,
},
Default: RegionConfig{
Provider: "aliyun",
},
}
}