Documentation
¶
Index ¶
- Variables
- func ContainsToken(records []string, token string) bool
- func FileHash(filePath string) (string, error)
- func FileHashFromStream(file multipart.File) (string, error)
- func FilePath(hash string) (dir, file string)
- func GenerateRandomString(length int) string
- func GetEnv(key string, defaultValue string) string
- func GetEnvBool(key string, defaultValue bool) bool
- func GetEnvInt(key string, defaultValue int) int
- func GetJsonFieldFromCtx(c *app.RequestContext, path string) (string, bool)
- func IsValidEntityName(name string) bool
- func IsValidZipFile(fileHeader *multipart.FileHeader) (bool, error)
- func LookupTXTRecords(domain string) ([]string, error)
- func NormalizeDomain(domain string) string
- func RunWithMode(h *server.Hertz, mode string) error
- func SendEmail(ctx context.Context, emailConfig *EmailConfig, target, subject, content string, ...) error
- func SendTemplate(ctx context.Context, emailConfig *EmailConfig, ...) error
- func VerifyDomainOwnership(domain, token string) (bool, error)
- type CaptchaConfig
- type Claims
- type EmailConfig
- type KVStore
- type PasswordType
- type TokenType
- func (TokenType) CreateApiToken(userID uint, duration time.Duration, ...) (string, error)
- func (TokenType) CreateJsonWebToken(userID uint, duration time.Duration, stateful bool, ...) (string, error)
- func (TokenType) ParseApiToken(tokenString string, isValidFunc func(string) (*models.ApiToken, error)) (*models.ApiToken, error)
- func (TokenType) ParseJsonWebToken(tokenString string, revokeChecker func(uint) bool) (*Claims, error)
- type Utils
Constants ¶
This section is empty.
Variables ¶
View Source
var Captcha = captchaType{}
View Source
var Ctx = ctxType{}
View Source
var Email = emailType{}
View Source
var Password = PasswordType{}
View Source
var Random = randomType{}
View Source
var Token = TokenType{}
Functions ¶
func ContainsToken ¶
ContainsToken 检查TXT记录中是否包含指定令牌
func GenerateRandomString ¶
GenerateRandomString 生成随机字符串
func GetEnvBool ¶
func GetJsonFieldFromCtx ¶
func GetJsonFieldFromCtx(c *app.RequestContext, path string) (string, bool)
GetJsonFieldFromCtx 高效获取JSON字段
func IsValidEntityName ¶
IsValidEntityName 检查字符串是否符合Git仓库命名规范,该函数只应被检查owner和project,site的方法所调用,不能被其他地方调用
func IsValidZipFile ¶
func IsValidZipFile(fileHeader *multipart.FileHeader) (bool, error)
IsValidZipFile 检查 multipart.FileHeader 是否为合法的 ZIP 文件
func LookupTXTRecords ¶
LookupTXTRecords 查询域名的TXT记录
func SendEmail ¶
func SendEmail(ctx context.Context, emailConfig *EmailConfig, target, subject, content string, isHTML bool) error
SendEmail 使用gomail库发送邮件
func SendTemplate ¶
func SendTemplate(ctx context.Context, emailConfig *EmailConfig, target, subject, htmlTemplate string, data map[string]interface{}) error
SendTemplate 发送HTML模板,从配置文件中读取邮箱配置,支持上下文控制
func VerifyDomainOwnership ¶
VerifyDomainOwnership 验证域名所有权
Types ¶
type CaptchaConfig ¶
type EmailConfig ¶
type KVStore ¶
type KVStore struct {
// contains filtered or unexported fields
}
KVStore 是一个简单的内存键值存储系统
type PasswordType ¶
type PasswordType struct { }
func (*PasswordType) CheckPasswordComplexity ¶
func (u *PasswordType) CheckPasswordComplexity(password string, level int) bool
CheckPasswordComplexity 根据指定级别检查密码复杂度 password: 待检查的密码 level: 复杂度级别(1-4) 返回值: 是否满足复杂度要求
func (*PasswordType) HashPassword ¶
func (u *PasswordType) HashPassword(password string, salt string) (string, error)
HashPassword 密码哈希函数
func (*PasswordType) VerifyPassword ¶
func (u *PasswordType) VerifyPassword(password, hashedPassword string, salt string) bool
VerifyPassword 验证密码
type TokenType ¶
type TokenType struct{}
func (TokenType) CreateApiToken ¶
func (TokenType) CreateApiToken(userID uint, duration time.Duration, persistentHandler func(*models.ApiToken) error) (string, error)
CreateApiToken 生成API令牌
func (TokenType) CreateJsonWebToken ¶
func (TokenType) CreateJsonWebToken(userID uint, duration time.Duration, stateful bool, persistentHandler func(uint) (*models.JsonWebToken, error)) (string, error)
CreateJsonWebToken 生成用户会话令牌(默认24小时有效)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.