Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultOptions = &Options{ RequiredLength: 6, RequireUppercase: true, RequireLowercase: true, RequireNonAlphanumeric: false, RequireDigit: true, RequiredUniqueChars: 0, }
DefaultOptions are the service's default password validation options.
Functions ¶
This section is empty.
Types ¶
type Hasher ¶
type Hasher struct { }
Hasher provides methods to hash and verify passwords, using a 64 bit salt and a 256 bit key, iterating 15000 times.
type Options ¶
type Options struct { // RequiredLength is the minimum length a password has to be. RequiredLength int // RequireUppercase is a flag which demands at least one // character to be uppercase. RequireUppercase bool // RequireLowercase is a flag which demands at least one // character to be lowercase. RequireLowercase bool // RequireNonAlphanumeric is a flag which demands at least one // character to be non alphanumeric. RequireNonAlphanumeric bool // RequireDigit is a flag which demands at least one // character to be a digit. RequireDigit bool // RequiredUniqueChars is an integer value, that determines // how many unique characters are required in a password. RequiredUniqueChars int }
Options contains a set of critrea that a password has to hit, to be considered valid.
type Service ¶
type Service interface { Validate(pwd string) error Hash(pwd string) string Verify(pwd, pwdHash string) bool }
Service is a wrapper around the password hasher and validator. This keeps all password logic in the same place, making it easier to use and decreasing the amount of dependencies methods require.
func NewService ¶
NewService is a factory method for the Service interface, creating an instance of an implementation for it.
Click to show internal directories.
Click to hide internal directories.