mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	Password Complexity Checks (#6230)
Add password complexity checks. The default settings require a lowercase, uppercase, number and a special character within passwords. Co-Authored-By: T-M-A <maxim.tkachenko@gmail.com> Co-Authored-By: Lanre Adelowo <adelowomailbox@gmail.com> Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-Authored-By: Lauris BH <lauris@nix.lv>
This commit is contained in:
		
				
					committed by
					
						 zeripath
						zeripath
					
				
			
			
				
	
			
			
			
						parent
						
							f9aba9ba0f
						
					
				
				
					commit
					db657192d0
				
			| @@ -146,6 +146,7 @@ var ( | ||||
| 	MinPasswordLength     int | ||||
| 	ImportLocalPaths      bool | ||||
| 	DisableGitHooks       bool | ||||
| 	PasswordComplexity    map[string]string | ||||
| 	PasswordHashAlgo      string | ||||
|  | ||||
| 	// UI settings | ||||
| @@ -774,6 +775,27 @@ func NewContext() { | ||||
|  | ||||
| 	InternalToken = loadInternalToken(sec) | ||||
|  | ||||
| 	var dictPC = map[string]string{ | ||||
| 		"lower": "[a-z]+", | ||||
| 		"upper": "[A-Z]+", | ||||
| 		"digit": "[0-9]+", | ||||
| 		"spec":  `][ !"#$%&'()*+,./:;<=>?@\\^_{|}~` + "`-", | ||||
| 	} | ||||
| 	PasswordComplexity = make(map[string]string) | ||||
| 	cfgdata := sec.Key("PASSWORD_COMPLEXITY").Strings(",") | ||||
| 	for _, y := range cfgdata { | ||||
| 		ts := strings.TrimSpace(y) | ||||
| 		for a := range dictPC { | ||||
| 			if strings.ToLower(ts) == a { | ||||
| 				PasswordComplexity[ts] = dictPC[ts] | ||||
| 				break | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if len(PasswordComplexity) == 0 { | ||||
| 		PasswordComplexity = dictPC | ||||
| 	} | ||||
|  | ||||
| 	sec = Cfg.Section("attachment") | ||||
| 	AttachmentPath = sec.Key("PATH").MustString(path.Join(AppDataPath, "attachments")) | ||||
| 	if !filepath.IsAbs(AttachmentPath) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user