password

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxLength bounds the Argon2 work an unauthenticated request can ask for.
	MinLength = 10
	MaxLength = 128
	// HIBPAPITimeout is the timeout for Have I Been Pwned API calls
	HIBPAPITimeout = 3 * time.Second
	// HIBPURL is the Have I Been Pwned API endpoint
	HIBPURL = "https://api.pwnedpasswords.com/range/"
)

Variables

View Source
var (
	ErrTooShort  = errors.New("too short")
	ErrTooLong   = errors.New("too long")
	ErrTooCommon = errors.New("too common")
	ErrBreached  = errors.New("found in a breach corpus")
)

Sentinels rather than messages: the wording a client sees belongs to the boundary.

Functions

This section is empty.

Types

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator decides whether a password is acceptable. The whole rule lives here.

func NewValidator

func NewValidator() *Validator

NewValidator creates a new password validator

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, password string) error

Validate checks length, then the common list, then the breach corpus.

A failed breach lookup accepts the password: a reset must not hinge on a third party.

Jump to

Keyboard shortcuts

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