password

package
v0.0.0-...-45ab5d3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package password provides utilities to validate a password or list of passwords against a set of criteria

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooShort is the error when a password doesn't meet the minimum password length requirement
	ErrTooShort = errors.New("Too Short")
	// ErrTooLong is the error when a password doesn't meet the maxumum password length requirement
	ErrTooLong = errors.New("Too Long")
	// ErrInvalidCharacters is the error when the password contains non-ASCII characters
	ErrInvalidCharacters = errors.New("Invalid Characters")
	// ErrCommon is the error when the password matches a string in the common password list
	ErrCommon = errors.New("Common Password")
)

Functions

This section is empty.

Types

type CommonList

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

CommonList holds a list of strings containing common passwords

func NewCommonList

func NewCommonList(r io.Reader) (CommonList, error)

NewCommonList list returns a CommonList with a list of sorted strings from the contents of the supplied filename

func (*CommonList) Matches

func (c *CommonList) Matches(input string) bool

Matches determines if the supplied string it a match to the list of common passwords

type Password

type Password string

Password is a type alias for a string of password that needs to be validated

type Validator

type Validator struct {
	AcceptASCIIOnly bool
	MaxCharacters   int
	MinCharacters   int
	// contains filtered or unexported fields
}

Validator is a password validator with configurable settings

func NewValidator

func NewValidator(acceptASCIIOnly bool, minChar, maxChar int) *Validator

NewValidator returns a password validator based on the configuration values supplied

func (*Validator) AddCommonPasswords

func (v *Validator) AddCommonPasswords(r io.Reader) error

AddCommonPasswords constructs a CommonList from the supplied reader

func (*Validator) ValidatePassword

func (v *Validator) ValidatePassword(pass string) error

ValidatePassword checks the Password based on the NIST password criteria

Jump to

Keyboard shortcuts

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