hedgehog

package
v0.0.0-...-cda998f Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UsernameExistsKey is used for the key to reserve a username
	UsernameExistsKey = "exists"
)

Variables

View Source
var (
	// ErrorUsernameExists is thrown when trying to reserve a username that is already in use
	ErrorUsernameExists = errors.New("username exists")
	// ErrorKeyExists is thrown when attempting to save a key that already exists
	ErrorKeyExists = errors.New("key exists")
	// ErrorNotFound is thrown when attempting to retrieve a key that does not exist
	ErrorNotFound = errors.New("not found")
)

Functions

func AddRoutes

func AddRoutes(deps Dependencies)

AddRoutes configures the router to serve routes for Hedgehog storage

Types

type DataVaultItem

type DataVaultItem struct {
	Namespace string `gorm:"PRIMARY_KEY"`
	Key       string `gorm:"PRIMARY_KEY"`
	EncryptedData
}

DataVaultItem is the gorm model that stores encrypted data

type Dependencies

type Dependencies struct {
	Router chi.Router
	Db     *gorm.DB
}

Dependencies contains objects needed to add hedgehog routes

type EncryptedData

type EncryptedData struct {
	Iv         string `json:"iv"`
	CipherText string `json:"cipherText"`
}

EncryptedData contains fields needed to store encrypted data

type Handler

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

Handler contains the http handler methods for hedgehog

func (*Handler) GetAuthenticationHandler

func (s *Handler) GetAuthenticationHandler(w http.ResponseWriter, r *http.Request)

GetAuthenticationHandler serves GET /authentication/{lookupKey}

func (*Handler) GetUserData

func (s *Handler) GetUserData(w http.ResponseWriter, r *http.Request)

GetUserData serves the GET /users/{username}/store/{key} route

func (*Handler) PostAuthenticationHandler

func (s *Handler) PostAuthenticationHandler(w http.ResponseWriter, r *http.Request)

PostAuthenticationHandler serves the POST /authentication route

func (*Handler) PostUserData

func (s *Handler) PostUserData(w http.ResponseWriter, r *http.Request)

PostUserData serves the POST /users/{username}/store/{key} route

func (*Handler) PostUserHandler

func (s *Handler) PostUserHandler(w http.ResponseWriter, r *http.Request)

PostUserHandler services the POST /users route

type Service

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

Service provides methods to store and retrieve encrypted data

func NewService

func NewService(db *gorm.DB) *Service

NewService constructs a new Service instance

func (*Service) GetAuthData

func (s *Service) GetAuthData(lookupKey string) (EncryptedData, error)

GetAuthData retrieves stored auth data

func (*Service) GetItem

func (s *Service) GetItem(username string, key string) (EncryptedData, error)

GetItem retrieves an encrypted data item

func (*Service) ReserveUsername

func (s *Service) ReserveUsername(username string) error

ReserveUsername sets a data item to identity that a username is in use

func (*Service) SetAuthData

func (s *Service) SetAuthData(lookupKey string, encryptedData EncryptedData) error

SetAuthData inserts iv, cipherText, and lookupKey into the data item table.

func (*Service) StoreItem

func (s *Service) StoreItem(username string, key string, data EncryptedData) error

StoreItem stores an encrypted data item

Jump to

Keyboard shortcuts

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