password

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Policy

type Policy struct {
	PasswordMinLength      int  `json:"password_min_length"`      // 密码最小长度
	PasswordRequireUpper   bool `json:"password_require_upper"`   // 需要大写字母
	PasswordRequireLower   bool `json:"password_require_lower"`   //需要小写字母
	PasswordRequireDigit   bool `json:"password_require_digit"`   //需要数字
	PasswordRequireSpecial bool `json:"password_require_special"` // 需要特殊字符
	PasswordExpireDays     int  `json:"password_expire_days"`     // 密码过期天数
	PasswordHistorySize    int  `json:"password_history_size"`    // 密码历史记录数量
	PasswordReuseLimit     int  `json:"password_reuse_limit"`     // 密码重复使用限制
	AllowWeakPassword      bool `json:"allow_weak_password"`      // 允许弱密码
	// 新增:防止连续键盘按键配置
	PreventSequentialChars bool `json:"prevent_sequential_chars"` // 防止连续字符(如: abc, 123)
	PreventKeyboardPattern bool `json:"prevent_keyboard_pattern"` // 防止键盘模式(如: qwert, asdfg)
	MaxSequentialLen       int  `json:"max_sequential_len"`       // 最大连续字符长度
	MaxRepeatedChars       int  `json:"max_repeated_chars"`       // 最大重复字符数,比如连续aaaa,ccccc,ddddd
}

Policy 密码策略

func (*Policy) GetPasswordStrength

func (p *Policy) GetPasswordStrength(password string) int

GetPasswordStrength 获取密码强度评分 (0-100)

func (*Policy) ValidatePassword

func (p *Policy) ValidatePassword(password string) error

ValidatePassword 验证密码是否符合策略

Jump to

Keyboard shortcuts

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