github.com/infraboard/keyauth@v0.8.1/common/password/config.go (about)

     1  package password
     2  
     3  const (
     4  	// LengthWeak weak length password
     5  	LengthWeak = 6
     6  
     7  	// LengthOK ok length password
     8  	LengthOK = 12
     9  
    10  	// LengthStrong strong length password
    11  	LengthStrong = 24
    12  
    13  	// LengthVeryStrong very strong length password
    14  	LengthVeryStrong = 36
    15  
    16  	// DefaultLetterSet is the letter set that is defaulted to - just the
    17  	// alphabet
    18  	DefaultLetterSet = "abcdefghijklmnopqrstuvwxyz"
    19  
    20  	// DefaultLetterAmbiguousSet are letters which are removed from the
    21  	// chosen character set if removing similar characters
    22  	DefaultLetterAmbiguousSet = "ijlo"
    23  
    24  	// DefaultNumberSet the default symbol set if character set hasn't been
    25  	// selected
    26  	DefaultNumberSet = "0123456789"
    27  
    28  	// DefaultNumberAmbiguousSet are the numbers which are removed from the
    29  	// chosen character set if removing similar characters
    30  	DefaultNumberAmbiguousSet = "01"
    31  
    32  	// DefaultSymbolSet the default symbol set if character set hasn't been
    33  	// selected
    34  	DefaultSymbolSet = "!$%^&*()_+{}:@[];'#<>?,./|\\-=?"
    35  
    36  	// DefaultSymbolAmbiguousSet are the symbols which are removed from the
    37  	// chosen character set if removing ambiguous characters
    38  	DefaultSymbolAmbiguousSet = "<>[](){}:;'/|\\,"
    39  )
    40  
    41  var (
    42  	// DefaultConfig is the default configuration, defaults to:
    43  	//    - length = 24
    44  	//    - Includes symbols, numbers, lowercase and uppercase letters.
    45  	//    - Excludes similar and ambiguous characters
    46  	DefaultConfig = Config{
    47  		Length:                     LengthStrong,
    48  		IncludeSymbols:             true,
    49  		IncludeNumbers:             true,
    50  		IncludeLowercaseLetters:    true,
    51  		IncludeUppercaseLetters:    true,
    52  		ExcludeSimilarCharacters:   true,
    53  		ExcludeAmbiguousCharacters: true,
    54  	}
    55  )
    56  
    57  // Config is the config struct to hold the settings about
    58  // what type of password to generate
    59  type Config struct {
    60  	// Length is the length of password to generate
    61  	Length int
    62  
    63  	// CharacterSet is the setting to manually set the
    64  	// character set
    65  	CharacterSet string
    66  
    67  	// IncludeSymbols is the setting to include symbols in
    68  	// the character set
    69  	// i.e. !"£*
    70  	IncludeSymbols bool
    71  
    72  	// IncludeNumbers is the setting to include number in
    73  	// the character set
    74  	// i.e. 1234
    75  	IncludeNumbers bool
    76  
    77  	// IncludeLowercaseLetters is the setting to include
    78  	// lowercase letters in the character set
    79  	// i.e. abcde
    80  	IncludeLowercaseLetters bool
    81  
    82  	// IncludeUppercaseLetters is the setting to include
    83  	// uppercase letters in the character set
    84  	// i.e. ABCD
    85  	IncludeUppercaseLetters bool
    86  
    87  	// ExcludeSimilarCharacters is the setting to exclude
    88  	// characters that look the same in the character set
    89  	// i.e. i1jIo0
    90  	ExcludeSimilarCharacters bool
    91  
    92  	// ExcludeAmbiguousCharacters is the setting to exclude
    93  	// characters that can be hard to remember or symbols
    94  	// that are rarely used
    95  	// i.e. <>{}[]()/|\`
    96  	ExcludeAmbiguousCharacters bool
    97  }