authentication

package
v0.0.0-...-9518a5e Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package authentication provides functions and structures to facilitate salting and authenticating passwords, as well as validating TOTP tokens.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidTOTPToken indicates that a provided two factor code is invalid.
	ErrInvalidTOTPToken = errors.New("invalid two factor code")
	// ErrPasswordDoesNotMatch indicates that a provided passwords does not match.
	ErrPasswordDoesNotMatch = errors.New("password does not match")
)
View Source
var (
	// Providers is what we offer to dependency injection.
	Providers = wire.NewSet(
		ProvideArgon2Authenticator,
	)
)

Functions

This section is empty.

Types

type Argon2Authenticator

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

Argon2Authenticator is our argon2-based authenticator.

func (*Argon2Authenticator) HashPassword

func (a *Argon2Authenticator) HashPassword(ctx context.Context, password string) (string, error)

HashPassword takes a password and hashes it using argon2.

func (*Argon2Authenticator) ValidateLogin

func (a *Argon2Authenticator) ValidateLogin(ctx context.Context, hash, password, totpSecret, totpCode string) (bool, error)

ValidateLogin validates a login attempt by:

  • checking that the provided authentication matches the provided hashed passwords.
  • checking that the temporary one-time authentication provided jives with the provided two factor secret.

type Authenticator

type Authenticator interface {
	Hasher

	ValidateLogin(ctx context.Context, hash, password, totpSecret, totpCode string) (bool, error)
}

Authenticator authenticates users.

func ProvideArgon2Authenticator

func ProvideArgon2Authenticator(logger logging.Logger) Authenticator

ProvideArgon2Authenticator returns an argon2 powered Argon2Authenticator.

type Hasher

type Hasher interface {
	HashPassword(ctx context.Context, password string) (string, error)
}

Hasher hashes passwords.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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