Documentation
¶
Overview ¶
Package vsafedb handles storing instances in the vsafe app to persistent storage.
Index ¶
- Variables
- func AddEntry(store AddEntryRunner, t db.Transaction, key *vsafe.Key, entry *vsafe.Entry) (newId int64, err error)
- func ChangePassword(store SafeUpdateUserRunner, t db.Transaction, id int64, ...) (*vsafe.User, error)
- func Entries(store EntriesByOwnerRunner, keyId int64, query string, catId int64) ([]*vsafe.Entry, error)
- func EntryById(store EntryByIdRunner, t db.Transaction, id int64, key *vsafe.Key, ...) (err error)
- func RemoveCategory(store SafeRemoveCategoryRunner, t db.Transaction, id, owner int64) (oldName string, err error)
- func Reverse(entries []*vsafe.Entry)
- func SortByTitle(entries []*vsafe.Entry)
- func UpdateCategory(store SafeUpdateCategoryRunner, t db.Transaction, id, owner int64, ...) (oldName string, err error)
- func UpdateEntry(store UpdateEntryRunner, t db.Transaction, key *vsafe.Key, entry *vsafe.Entry) (err error)
- func UpdateEntryWithEtag(store SafeUpdateEntryRunner, t db.Transaction, id int64, tag uint64, ...) error
- type AddCategoryRunner
- type AddEntryRunner
- type AddUserRunner
- type CategoriesByOwnerRunner
- type CategoryByIdRunner
- type EntriesByOwnerRunner
- type EntryByIdRunner
- type RemoveCategoryRunner
- type RemoveEntryRunner
- type RemoveUserRunner
- type SafeRemoveCategoryRunner
- type SafeUpdateCategoryRunner
- type SafeUpdateEntryRunner
- type SafeUpdateUserRunner
- type UpdateCategoryRunner
- type UpdateEntryRunner
- type UpdateUserRunner
- type UserByIdRunner
- type UserByNameRunner
- type UsersRunner
Constants ¶
This section is empty.
Variables ¶
var ( // Indicates that the id does not exist in the database. ErrNoSuchId = errors.New("vsafedb: No such Id.") // Indicates concurrent modification ErrConcurrentModification = errors.New("vsafedb: Concurrent Modification") )
Functions ¶
func AddEntry ¶
func AddEntry( store AddEntryRunner, t db.Transaction, key *vsafe.Key, entry *vsafe.Entry) (newId int64, err error)
AddEntry adds a new entry to persistent storage so that sensitive fields are encrypted in persistent storage.
func ChangePassword ¶
func ChangePassword( store SafeUpdateUserRunner, t db.Transaction, id int64, oldPass, newPass string) (*vsafe.User, error)
ChangePassword changes the password of a user in persistent storage. t, the transaction, must be non nil.
func Entries ¶
func Entries( store EntriesByOwnerRunner, keyId int64, query string, catId int64) ([]*vsafe.Entry, error)
Entries returns a new slice containing entries encrypted with keyId and matching query and orders them by Id. It does not decrypt the sensitive fields within the fetched entries. query is searched for within url, title, and description of each entry ignoring case to determine whether or not there is a match. Whitespace within query and entry fields are normalized to a single space before matching happens. The empty string matches all entries.
If catId is non-zero, returned entries must belong to corresponding category in addition to matching query.
func EntryById ¶
func EntryById( store EntryByIdRunner, t db.Transaction, id int64, key *vsafe.Key, entry *vsafe.Entry) (err error)
EntryById retrieves an entry by its id from persistent storage while handling decryption of sensitive fields. If the Id of the provided key does not match the Owner field of fetched entry, that is the current user does not own the entry being fetched, EntryById returns ErrNoSuchId.
func RemoveCategory ¶
func RemoveCategory( store SafeRemoveCategoryRunner, t db.Transaction, id, owner int64) (oldName string, err error)
RemoveCategory removes a category by id and owner. t must be non-nil.
func SortByTitle ¶
SortByTitle sorts entries by title in place ignoring case.
func UpdateCategory ¶
func UpdateCategory( store SafeUpdateCategoryRunner, t db.Transaction, id, owner int64, newName string) (oldName string, err error)
UpdateCategory updates a category name by id and owner. t must be non-nil.
func UpdateEntry ¶
func UpdateEntry( store UpdateEntryRunner, t db.Transaction, key *vsafe.Key, entry *vsafe.Entry) (err error)
UpdateEntry updates an entry in persistent storage so that sensitive fields remain encrypted in persistent storage. Beware: UpdateEntry does not protect against concurrent modification nor does it protect against users clobbering an entry they do not own.
func UpdateEntryWithEtag ¶
func UpdateEntryWithEtag( store SafeUpdateEntryRunner, t db.Transaction, id int64, tag uint64, key *vsafe.Key, update vsafe.EntryUpdater) error
UpdateEntryWithEtag updates an entry in persistent storage in a way that detects concurrent modification. It also prevents users from modifying entries they do not own by returning ErrNoSuchId. t, the transaction, must be non nil.
Types ¶
type AddCategoryRunner ¶
type AddCategoryRunner interface {
// AddCategory adds a new category to persistent storage
AddCategory(t db.Transaction, category *vsafe.Category) error
}
type AddEntryRunner ¶
type AddEntryRunner interface {
// AddEntry adds a new entry to persistent storage.
AddEntry(t db.Transaction, entry *vsafe.Entry) error
}
type AddUserRunner ¶
type AddUserRunner interface {
// AddUser adds a new user to persistent storage.
AddUser(t db.Transaction, user *vsafe.User) error
}
type CategoriesByOwnerRunner ¶
type CategoryByIdRunner ¶
type EntriesByOwnerRunner ¶
type EntryByIdRunner ¶
type RemoveCategoryRunner ¶
type RemoveCategoryRunner interface {
// RemoveCategory removes a category with given id from
// persistent storage.
RemoveCategory(t db.Transaction, id int64) error
}
type RemoveEntryRunner ¶
type RemoveEntryRunner interface {
// RemoveEntry removes an entry with given id and owner from persistent
// storage.
RemoveEntry(t db.Transaction, id, owner int64) error
}
type RemoveUserRunner ¶
type RemoveUserRunner interface {
// RemoveUser removes a user by name from persistent storage.
RemoveUser(t db.Transaction, name string) error
}
type SafeRemoveCategoryRunner ¶
type SafeRemoveCategoryRunner interface {
CategoryByIdRunner
RemoveCategoryRunner
}
type SafeUpdateCategoryRunner ¶
type SafeUpdateCategoryRunner interface {
CategoryByIdRunner
UpdateCategoryRunner
}
type SafeUpdateEntryRunner ¶
type SafeUpdateEntryRunner interface {
UpdateEntryRunner
EntryByIdRunner
}
type SafeUpdateUserRunner ¶
type SafeUpdateUserRunner interface {
UpdateUserRunner
UserByIdRunner
}
type UpdateCategoryRunner ¶
type UpdateCategoryRunner interface {
// UpdateCategory updates a category.
UpdateCategory(t db.Transaction, category *vsafe.Category) error
}
type UpdateEntryRunner ¶
type UpdateEntryRunner interface {
// UpdateEntry updates an entry in persistent storage.
UpdateEntry(t db.Transaction, entry *vsafe.Entry) error
}
type UpdateUserRunner ¶
type UpdateUserRunner interface {
// UpdateUser modifies a user in persistent storage.
UpdateUser(t db.Transaction, user *vsafe.User) error
}
type UserByIdRunner ¶
type UserByNameRunner ¶
type UsersRunner ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package fixture provides test suites to test implementations of the datastore interfaces in the vsafedb package.
|
Package fixture provides test suites to test implementations of the datastore interfaces in the vsafedb package. |
|
Package for_sqlite provides a sqlite implementation of interfaces in vsafedb package.
|
Package for_sqlite provides a sqlite implementation of interfaces in vsafedb package. |
|
Package sqlite_setup sets up a sqlite database for vsafe app
|
Package sqlite_setup sets up a sqlite database for vsafe app |