Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTransaction ¶
func CreateTransaction() (*runner.Tx, error)
CreateTransaction creates a new transaction without exposing the db pool.
func InitDB ¶
func InitDB(ds string)
InitDB initializes the database pool and stores it in the model package scope.
func NukeKeysForSecret ¶
NukeKeysForSecret blows away all keys for a given secret due to the fact that they all need to be updated when a secret is updated.
Types ¶
type Credentials ¶
Credentials is a convenience struct for login use.
type Key ¶
type Key struct { ID uuid.UUID `db:"id" json:"id"` Secret Secret `db:"secret" json:"secret,omitempty"` Owner User `db:"owner" json:"owner"` Key string `db:"key" json:"key"` }
Key represents an asymmetrically encrypted symmetrically key. Once decrypted, this will decrypt the associated secret.
type Keys ¶
type Keys []Key
Keys is a convenience type representing a slice of Key.
func AllKeysForSecret ¶
AllKeysForSecret queries for associated keys. The referenced secret in the key is assigned to the secret passed in.
type Secret ¶
type Secret struct { ID uuid.UUID `db:"id" json:"id"` Author User `db:"author" json:"author"` Keys Keys `json:"keys"` CipherText string `db:"cipher_text" json:"cipher_text"` IV string `db:"iv" json:"iv"` }
Secret represents an symmetrically encrypted piece of data. It does not encompass an individual key.
func (Secret) Create ¶
Create assigns a UUID and stores the Secret struct representation into the database.
func (Secret) Delete ¶
Delete removes a saved Secret. Please note to any consumer of this function that this removes the Secret and associated Keys from the database. You still have to roll the password in this Secret as individuals may still hold a copy. Common sense, but just a friendly reminder :)
type Secrets ¶
type Secrets []Secret
Secrets is a convenience type representing a slice of Secret.
func AllSecrets ¶
AllSecrets returns all secrets authored by given user id (taken from JWT)
type Token ¶
type Token struct {
Token string
}
Token is a simple wrapper for compatibility with the generalized API handler.
type User ¶
type User struct { ID uuid.UUID `db:"id" json:"id,omitempty"` Fullname string `db:"fullname" json:"fullname"` Username string `db:"username" json:"username"` Password string `db:"password" json:"password,omitempty"` PublicKey string `db:"public_key" json:"public_key,omitempty"` }
User represents an individual that has access to Roccaforte
func UserByUsername ¶
UserByUsername retreives a user based on provided username.
func (User) Create ¶
Create assigns a UUID and stores the User struct representation into the database.
func (User) MarshalJSON ¶
MarshalJSON overrides default functionality and sets password to empty string to omit on serialization.