Documentation ¶
Index ¶
- Constants
- Variables
- func And(es ...string) string
- func ToQueryString(target interface{}) string
- type ArgsMap
- type CanonicalForm
- type CanonicalForms
- type Canonicaller
- type EncryptedField
- type GetOptionFunc
- type IDs
- type Mapper
- func (m *Mapper) CheckSignature(i Canonicaller, sig []byte) (bool, error)
- func (m *Mapper) ConfigureKeys(signatureKeys, encryptionKeys *[]keyloader.KeyConfig) error
- func (m *Mapper) Decrypt(src []byte, dest interface{}, extra []interface{}) error
- func (m *Mapper) Delete(db gorp.SqlExecutor, i interface{}) error
- func (m *Mapper) Encrypt(src interface{}, dst *[]byte, extra []interface{}) error
- func (m *Mapper) Get(ctx context.Context, db gorp.SqlExecutor, q Query, i interface{}, ...) (bool, error)
- func (m *Mapper) GetAll(ctx context.Context, db gorp.SqlExecutor, q Query, i interface{}, ...) error
- func (m *Mapper) GetInt(db gorp.SqlExecutor, q Query) (int64, error)
- func (m *Mapper) GetTableMapping(i interface{}) (TableMapping, bool)
- func (m *Mapper) Insert(db gorp.SqlExecutor, i interface{}) error
- func (m *Mapper) InsertAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller) error
- func (m *Mapper) ListCanonicalFormsByEntity(db gorp.SqlExecutor, entity string) ([]sdk.CanonicalFormUsage, error)
- func (m *Mapper) ListEncryptedEntities() []string
- func (m *Mapper) ListSignedEntities() []string
- func (m *Mapper) ListTupleByCanonicalForm(db gorp.SqlExecutor, entity, signer string) ([]string, error)
- func (m *Mapper) ListTuplesByEntity(db gorp.SqlExecutor, entity string) ([]string, error)
- func (m *Mapper) LoadAndLockTupleByPrimaryKey(ctx context.Context, db gorp.SqlExecutor, entity string, pk interface{}, ...) (interface{}, error)
- func (m *Mapper) LoadTupleByPrimaryKey(ctx context.Context, db gorp.SqlExecutor, entity string, pk interface{}, ...) (interface{}, error)
- func (m *Mapper) NewTableMapping(target interface{}, name string, autoIncrement bool, keys ...string) TableMapping
- func (m *Mapper) Register(ms ...TableMapping)
- func (m *Mapper) RollEncryptedTupleByPrimaryKey(ctx context.Context, db gorp.SqlExecutor, entity string, pk interface{}) error
- func (m *Mapper) RollSignedTupleByPrimaryKey(ctx context.Context, db SqlExecutorWithTx, entity string, pk interface{}) error
- func (m *Mapper) Update(db gorp.SqlExecutor, i interface{}) error
- func (m *Mapper) UpdateAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller) error
- func (m *Mapper) UpdateColumns(db gorp.SqlExecutor, i interface{}, columnFilter gorp.ColumnFilter) error
- func (m *Mapper) UpdateColumnsAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller, ...) error
- type Query
- type Signed
- type SignedEntity
- type SqlExecutorWithTx
- type TableMapping
- type TestEncryptedData
Constants ¶
const ( // ViolateForeignKeyPGCode is the pg code when violating foreign key ViolateForeignKeyPGCode = "23503" // ViolateUniqueKeyPGCode is the pg code when duplicating unique key ViolateUniqueKeyPGCode = "23505" // StringDataRightTruncation is raisedalue is too long for varchar. StringDataRightTruncation = "22001" )
const (
KeyEcnryptionIdentifier = "db-crypt"
)
const (
KeySignIdentifier = "db-sign"
)
Constant for gorp mapping.
Variables ¶
var GetOptions = struct { WithDecryption GetOptionFunc }{ WithDecryption: getEncryptedData, }
Functions ¶
func ToQueryString ¶
func ToQueryString(target interface{}) string
ToQueryString returns a comma separated list of given ids.
Types ¶
type CanonicalForm ¶
type CanonicalForm string
func (*CanonicalForm) Bytes ¶
func (f *CanonicalForm) Bytes() []byte
func (*CanonicalForm) String ¶
func (f *CanonicalForm) String() string
type CanonicalForms ¶
type CanonicalForms []CanonicalForm
func (CanonicalForms) Latest ¶
func (fs CanonicalForms) Latest() (*CanonicalForm, CanonicalForms)
type Canonicaller ¶
type Canonicaller interface {
Canonical() CanonicalForms
}
Canonicaller returns a byte array that represent its data.
type EncryptedField ¶
type GetOptionFunc ¶
type IDs ¶
type IDs pq.Int64Array
type Mapper ¶
type Mapper struct { Mapping map[string]TableMapping CanonicalFormTemplates struct { M map[string]*template.Template L sync.RWMutex } // contains filtered or unexported fields }
Mapping is the global var for all registered mapping
func (*Mapper) CheckSignature ¶
func (m *Mapper) CheckSignature(i Canonicaller, sig []byte) (bool, error)
CheckSignature return true if a given signature is valid for given object.
func (*Mapper) ConfigureKeys ¶
func (*Mapper) Delete ¶
func (m *Mapper) Delete(db gorp.SqlExecutor, i interface{}) error
Delete value in given db.
func (*Mapper) Get ¶
func (m *Mapper) Get(ctx context.Context, db gorp.SqlExecutor, q Query, i interface{}, opts ...GetOptionFunc) (bool, error)
Get a value from database.
func (*Mapper) GetAll ¶
func (m *Mapper) GetAll(ctx context.Context, db gorp.SqlExecutor, q Query, i interface{}, opts ...GetOptionFunc) error
GetAll values from database.
func (*Mapper) GetTableMapping ¶
func (m *Mapper) GetTableMapping(i interface{}) (TableMapping, bool)
func (*Mapper) Insert ¶
func (m *Mapper) Insert(db gorp.SqlExecutor, i interface{}) error
Insert value in given db.
func (*Mapper) InsertAndSign ¶
func (m *Mapper) InsertAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller) error
InsertAndSign a data in database, given data should implement canonicaller interface.
func (*Mapper) ListCanonicalFormsByEntity ¶
func (m *Mapper) ListCanonicalFormsByEntity(db gorp.SqlExecutor, entity string) ([]sdk.CanonicalFormUsage, error)
func (*Mapper) ListEncryptedEntities ¶
func (*Mapper) ListSignedEntities ¶
func (*Mapper) ListTupleByCanonicalForm ¶
func (*Mapper) ListTuplesByEntity ¶
func (*Mapper) LoadAndLockTupleByPrimaryKey ¶
func (m *Mapper) LoadAndLockTupleByPrimaryKey(ctx context.Context, db gorp.SqlExecutor, entity string, pk interface{}, opts ...GetOptionFunc) (interface{}, error)
func (*Mapper) LoadTupleByPrimaryKey ¶
func (m *Mapper) LoadTupleByPrimaryKey(ctx context.Context, db gorp.SqlExecutor, entity string, pk interface{}, opts ...GetOptionFunc) (interface{}, error)
func (*Mapper) NewTableMapping ¶
func (m *Mapper) NewTableMapping(target interface{}, name string, autoIncrement bool, keys ...string) TableMapping
NewTableMapping initialize a TableMapping.
func (*Mapper) Register ¶
func (m *Mapper) Register(ms ...TableMapping)
Register intialiaze gorp mapping
func (*Mapper) RollEncryptedTupleByPrimaryKey ¶
func (*Mapper) RollSignedTupleByPrimaryKey ¶
func (*Mapper) Update ¶
func (m *Mapper) Update(db gorp.SqlExecutor, i interface{}) error
Update value in given db.
func (*Mapper) UpdateAndSign ¶
func (m *Mapper) UpdateAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller) error
UpdateAndSign a data in database, given data should implement canonicaller interface.
func (*Mapper) UpdateColumns ¶
func (m *Mapper) UpdateColumns(db gorp.SqlExecutor, i interface{}, columnFilter gorp.ColumnFilter) error
func (*Mapper) UpdateColumnsAndSign ¶
func (m *Mapper) UpdateColumnsAndSign(ctx context.Context, db gorp.SqlExecutor, i Canonicaller, colFilter gorp.ColumnFilter) error
UpdateColumnsAndSign a data in database, given data should implement canonicaller interface.
type Query ¶
type Query struct { Query string Arguments []interface{} }
Query to get gorp entities in database.
type SignedEntity ¶
type SignedEntity struct {
Signature []byte `json:"-" db:"sig"`
}
SignedEntity struct for signed entity stored in database.
func (SignedEntity) GetSignature ¶
func (s SignedEntity) GetSignature() []byte
type SqlExecutorWithTx ¶
type SqlExecutorWithTx interface { gorp.SqlExecutor Commit() error Rollback() error }
type TableMapping ¶
type TableMapping struct { Target interface{} Name string AutoIncrement bool SignedEntity bool Keys []string EncryptedEntity bool EncryptedFields []EncryptedField }
TableMapping represents a table mapping with gorp
type TestEncryptedData ¶
type TestEncryptedData struct { SignedEntity ID int64 `db:"id"` Data string `db:"data"` SensitiveData string `db:"sensitive_data" gorpmapping:"encrypted,Data"` AnotherSensitiveData string `db:"another_sensitive_data" gorpmapping:"encrypted,ID,Data"` }
func (TestEncryptedData) Canonical ¶
func (e TestEncryptedData) Canonical() CanonicalForms