Documentation ¶
Index ¶
- Constants
- Variables
- func AddRoutes(deps Dependencies)
- type DataVaultItem
- type Dependencies
- type EncryptedData
- type Handler
- func (s *Handler) GetAuthenticationHandler(w http.ResponseWriter, r *http.Request)
- func (s *Handler) GetUserData(w http.ResponseWriter, r *http.Request)
- func (s *Handler) PostAuthenticationHandler(w http.ResponseWriter, r *http.Request)
- func (s *Handler) PostUserData(w http.ResponseWriter, r *http.Request)
- func (s *Handler) PostUserHandler(w http.ResponseWriter, r *http.Request)
- type Service
- func (s *Service) GetAuthData(lookupKey string) (EncryptedData, error)
- func (s *Service) GetItem(username string, key string) (EncryptedData, error)
- func (s *Service) ReserveUsername(username string) error
- func (s *Service) SetAuthData(lookupKey string, encryptedData EncryptedData) error
- func (s *Service) StoreItem(username string, key string, data EncryptedData) error
Constants ¶
const (
// UsernameExistsKey is used for the key to reserve a username
UsernameExistsKey = "exists"
)
Variables ¶
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 ¶
Dependencies contains objects needed to add hedgehog routes
type EncryptedData ¶
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 ¶
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 ¶
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.