Documentation
¶
Overview ¶
Package verifier provides types and interfaces for building verifiers, used by passwap.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoundsError ¶ added in v0.12.0
BoundsError is returned when a parameter is out of the configured bounds.
func (*BoundsError) Error ¶ added in v0.12.0
func (e *BoundsError) Error() string
type Result ¶
type Result int
Result of a password verification.
const ( // Fail is returned when the passwords don't match // or an error was encountered in the process. Fail Result = iota // OK is returned when the passwords match // and no further action is required. OK // NeedUpdate is returned when the passwords match // however the passed data is outdated and // needs to be updated in the database to the latest version. // The latest version is obtainable by calling Hasher.Hash(password) NeedUpdate // Skip is returned when a verifier is unable // to parse the encoded string. Skip )
type Verifier ¶
type Verifier interface {
// Validate checks if the encoded string can be handled by this Verifier.
// The verifier may check if the parameters used in the encoded string
// are within acceptable bounds.
// If the parameters are out of bounds, it returns [Fail] and
// an error of type [*verifier.BoundsError].
Validate(encoded string) (Result, error)
// Verify the hashed password against the encoded hash.
Verify(encoded, password string) (Result, error)
}
Verifier is capable of verifying passwords against an existing encoded hash string. Implementations are typically responsible for parsing such string and the format in use. Within the passwap project we aim to only use dollar sign `$` notation.
A Verifier should return the Skip result when it is unable to parse the encoded string. It may return an error if one was encountered during parsing, but should try to prevent this by early checking if the encoded string is indeed in the format expected.