verifier

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

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 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
)

func (Result) String

func (i Result) String() string

type Verifier

type Verifier interface {
	// 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.

type VerifyFunc

type VerifyFunc func(encoded, password string) (Result, error)

func (VerifyFunc) Verify

func (v VerifyFunc) Verify(encoded, password string) (Result, error)

Jump to

Keyboard shortcuts

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