password

package
v0.0.0-...-7d41a23 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package password contains all code related to the password domain.

Index

Constants

This section is empty.

Variables

View Source
var (
	LowerCaseLetters = NewDomain("abcdefghijklmnopqrstuvwxyz")
	UpperCaseLetters = NewDomain("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
	Numbers          = NewDomain("0123456789")
	ASCIISpecials    = NewDomain(`!"#$%&'()*+,-./:;<=>?@[\]^_{|}~`)

	Letters           = LowerCaseLetters.MergeWith(UpperCaseLetters)
	LettersAndNumbers = Letters.MergeWith(Numbers)

	// LettersAndNumbers will be more common than specials
	Standard = LettersAndNumbers.MergeWith(LettersAndNumbers).MergeWith(ASCIISpecials)
)

Most common domains

Functions

This section is empty.

Types

type Backend

type Backend interface {
	GetPrincipalEmail(userID string) (string, error)
	SetUserPassword(userID string, hashedPassword string) error
}

Backend interface.

type Domain

type Domain interface {
	Len() uint
	AsSlice() []rune
	Rune(uint) rune
	MergeWith(Domain) Domain
}

Domain object contains information about characters used to construct a random secret string.

func NewDomain

func NewDomain(chars string) Domain

NewDomain create a new domain object.

type Driver

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

Driver is the entry point of the domain that expose methods.

func NewDriver

func NewDriver(backend Backend, spusher SecretPusher) Driver

NewDriver create a new domain driver with given driven implementations.

func (Driver) AssignPassword

func (d Driver) AssignPassword(userID string, alg string, password string) error

AssignPassword to the user with id, the secret is pushed to the user securely.

func (Driver) AssignRandomPassword

func (d Driver) AssignRandomPassword(userID string, alg string, domain Domain, length uint) error

AssignRandomPassword to the user with id, the secret is pushed to the user securely.

func (Driver) GetHash

func (d Driver) GetHash(alg string, password string) (string, error)

GetHash hash the password with the given algorithm.

func (Driver) GetHashAlgorithms

func (d Driver) GetHashAlgorithms() []string

GetHashAlgorithms returns list of supported hash algorithms.

func (Driver) GetRandomPassword

func (d Driver) GetRandomPassword(domain Domain, length uint) (string, error)

GetRandomPassword generate a random password with given length and domain.

type SecretPusher

type SecretPusher interface {
	PushSecret(email string, secretType string, secret string) error
	CanPushSecret() error
}

SecretPusher role is to let the user know of a secret in a secure manner.

Jump to

Keyboard shortcuts

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