database

package
v0.0.0-...-8b70b2c Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

** An implementation of the Databaser interface as an in-memory map for testing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Databaser

type Databaser interface {
	Add(user model.YubiUser) error
	Get(ykid string) (*model.YubiUser, error)
	GetAll() ([]*model.YubiUser, error)
	UpdateCounts(user model.YubiUser) error
	UpdateUser(user model.YubiUser) error
	SetSecretColumnKeyFunc(model.SecretColumnKeyT)
}

Databaser interface to the underlying database that manages known Yubi keys

type Db

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

Db implements Databaser interface

func NewDb

func NewDb(dsn string) (*Db, error)

NewDb creates a new interface to the database identified by `dsn`. Supports the following types to select the proper dialect:

  • sqlite -> "file:/home/user/data.db"
  • mysql -> "mysql://user@pass/dbname?charset=utf8&parseTime=True&loc=Local"

func (*Db) Add

func (db *Db) Add(req model.YubiUser) error

func (*Db) Get

func (db *Db) Get(ykid string) (*model.YubiUser, error)

func (*Db) GetAll

func (db *Db) GetAll() ([]*model.YubiUser, error)

func (*Db) SetSecretColumnKeyFunc

func (db *Db) SetSecretColumnKeyFunc(kf model.SecretColumnKeyT)

SetSecretColumnKeyFunc specifies the func to call to acquire the application's secret key for DB column encryption

func (*Db) UpdateCounts

func (db *Db) UpdateCounts(user model.YubiUser) error

UpdateCounts update counters for the YubiKey

func (*Db) UpdateUser

func (db *Db) UpdateUser(user model.YubiUser) error

UpdateUser update registration-editable fields

type MapDb

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

MapDb implements Databaser interface. This should be a real database that stores known user yubikey IDs and their secrets.

func NewMapDb

func NewMapDb() *MapDb

func (*MapDb) Add

func (db *MapDb) Add(user model.YubiUser) error

See README.md for info on how to determine the yubikey ID and secret AES key.

func (*MapDb) Get

func (db *MapDb) Get(ykid string) (*model.YubiUser, error)

Find key in database or return an error

func (*MapDb) GetAll

func (db *MapDb) GetAll() ([]*model.YubiUser, error)

func (*MapDb) SetSecretColumnKeyFunc

func (db *MapDb) SetSecretColumnKeyFunc(kf model.SecretColumnKeyT)

SetSecretColumnKeyFunc specifies the func to call to acquire the application's secret key for DB column encryption

func (*MapDb) UpdateCounts

func (db *MapDb) UpdateCounts(rec model.YubiUser) error

Intent is we are updating the usage count for the yubikey

func (*MapDb) UpdateUser

func (db *MapDb) UpdateUser(rec model.YubiUser) error

Intent is we are updating the usage count for the yubikey

type RegistrationError

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

func (*RegistrationError) Error

func (e *RegistrationError) Error() string

Jump to

Keyboard shortcuts

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