Documentation ¶
Overview ¶
Package htpasswd contains utilities for manipulating .htpasswd files
Index ¶
- Variables
- func CreateUser(file, user, passwd string, algo Hasher) error
- func DeleteUser(file, user string) error
- func UpdateUser(file, user, passwd string, algo Hasher) error
- func VerifyUser(file, user, passwd string) error
- type Apr1
- type Bcrypt
- type Hasher
- type Passwds
- func (pp Passwds) Bytes() []byte
- func (pp Passwds) CreateUser(user, passwd string, algo Hasher) error
- func (pp Passwds) DeleteUser(user string) error
- func (pp Passwds) UpdateUser(user, passwd string, algo Hasher) error
- func (pp Passwds) VerifyUser(user, passwd string) error
- func (pp Passwds) WriteFile(file string) error
- type Sha
- type Sha256
- type Sha512
- type Ssha
- type UserError
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExists indicates the specified user already exists ErrExists = errors.New("user already exists") // ErrNotExists indicates the specified user does not exist ErrNotExists = errors.New("user does not exist") // ErrInvalidAlgorithm indicates the htpasswd entry doesn't contain a // valid algorithm signature ErrInvalidAlgorithm = errors.New("invalid algorithm") // ErrInvalidPassword indicates the offered password doesn't match ErrInvalidPassword = errors.New("invalid password") )
Functions ¶
func CreateUser ¶
CreateUser creates a record in the named file with the named password and hash algorithm
func DeleteUser ¶
DeleteUser deletes the named user from the named file
func UpdateUser ¶
UpdateUser will update the password for the named user in the named file
Types ¶
type Apr1 ¶
type Apr1 struct{}
Apr1 facilitates apr1 style hashing
func (*Apr1) Hash ¶
Hash returns the hashed variant of the password or an error
func (*Apr1) Match ¶
Match verifier the hashed password using the original
type Bcrypt ¶
type Bcrypt struct{}
Bcrypt facilitates bcrypt style hashing
func (*Bcrypt) Hash ¶
Hash returns the hashed variant of the password or an error
func (*Bcrypt) Match ¶
Match verifier the hashed password using the original
type Hasher ¶
type Hasher interface { Hash(password string) (string, error) Match(password, hashedPassword string) error Name() string Prefix() string }
Hasher interface implemented by hash algos
type Passwds ¶
Passwds name => hash
func Parse ¶
Parse parses a slice of bytes in htpasswd style
func ParseFile ¶
ParseFile parses a .htpasswd file and returns a Passwd type
func (Passwds) Bytes ¶
Bytes will return the Passwd as a byte slice
func (Passwds) CreateUser ¶
CreateUser will create a new user in the given Passwd object using the given name, password and hashing algorithm
func (Passwds) DeleteUser ¶
DeleteUser deletes the named user from the named file
func (Passwds) UpdateUser ¶
UpdateUser will update the password for the named user using the given name, password and hashing algorithm
func (Passwds) VerifyUser ¶
VerifyUser will check if the given user and password are matching with the given Passwd object
type Sha ¶
type Sha struct{}
Sha facilitates sha1 style hashing
func (*Sha) Hash ¶
Hash returns the hashed variant of the password or an error
func (*Sha) Match ¶
Match verifier the hashed password using the original
type Sha256 ¶
type Sha256 struct{}
Sha256 facilitates sha256 style hashing
func (*Sha256) Hash ¶
Hash returns the hashed variant of the password or an error
func (*Sha256) Match ¶
Match verifier the hashed password using the original
type Sha512 ¶
type Sha512 struct{}
Sha512 facilitates sha512 style hashing
func (*Sha512) Hash ¶
Hash returns the hashed variant of the password or an error
func (*Sha512) Match ¶
Match verifier the hashed password using the original