auth

package
v0.0.0-...-cf01233 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAuth = errors.New("invalid auth")

ErrInvalidAuth if auth is invalid.

Functions

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

func Transact

func Transact(db *sqlx.DB, txFn func(*sqlx.Tx) error) (err error)

Transact creates and executes a transaction.

Types

type Auth

type Auth = api.Auth

func NewPaperKey

func NewPaperKey(paperKey string, mk *[32]byte) (*Auth, error)

func NewPassword

func NewPassword(password string, mk *[32]byte) (*Auth, error)

type DB

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

DB for vault.

func NewDB

func NewDB(path string, opt ...Option) (*DB, error)

NewDB creates an DB for auth. This DB is unencrypted but the auth keys themselves are encrypted.

func (*DB) Close

func (d *DB) Close() error

func (*DB) Delete

func (d *DB) Delete(id string) error

Delete auth method.

func (*DB) FIDO2HMACSecret

func (d *DB) FIDO2HMACSecret(ctx context.Context, plugin fido2.FIDO2Server, pin string) (*Auth, *[32]byte, error)

FIDO2HMACSecret authenticates using FIDO2 hmac-secret.

func (*DB) List

func (d *DB) List() ([]*Auth, error)

List auth.

func (*DB) ListByType

func (d *DB) ListByType(typ Type) ([]*Auth, error)

ListByType lists auth by type.

func (*DB) PaperKey

func (d *DB) PaperKey(paperKey string) (*Auth, *[32]byte, error)

PaperKey authenticates using a paper key.

func (*DB) Password

func (d *DB) Password(password string) (*Auth, *[32]byte, error)

Password authenticates with a password.

func (*DB) RegisterFIDO2HMACSecret

func (d *DB) RegisterFIDO2HMACSecret(ctx context.Context, plugin fido2.FIDO2Server, hs *FIDO2HMACSecret, mk *[32]byte, pin string) (*Auth, error)

RegisterFIDO2HMACSecret registers FIDO2HMACSecret.

func (*DB) RegisterPaperKey

func (d *DB) RegisterPaperKey(paperKey string, mk *[32]byte) (*Auth, error)

RegisterPaperKey registers paper key auth.

func (*DB) RegisterPassword

func (d *DB) RegisterPassword(password string, mk *[32]byte) (*Auth, error)

RegisterPassword registers a password.

func (*DB) Set

func (d *DB) Set(auth *Auth) error

Set adds or updates auth method.

type FIDO2HMACSecret

type FIDO2HMACSecret struct {
	CredentialID []byte
	Salt         []byte
	AAGUID       string
	NoPin        bool
}

FIDO2HMACSecret from a device.

func GenerateFIDO2HMACSecret

func GenerateFIDO2HMACSecret(ctx context.Context, plugin fido2.FIDO2Server, pin string, device string, appName string) (*FIDO2HMACSecret, error)

GenerateFIDO2HMACSecret creates FIDO2 hmac-secret on a device.

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Option

type Option func(*Options)

Option for DB.

func WithClientKey

func WithClientKey(key *keys.EdX25519Key) Option

WithClientKey ...

type Options

type Options struct {
	ClientKey *keys.EdX25519Key
}

Options for auth.

type Type

type Type = api.Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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