Documentation
¶
Overview ¶
Package marshalers provides custom DynamoDB marshaling utilities with encryption support for sensitive data using DynamORM.
Index ¶
- func EncodeEncryptionKey(key []byte) string
- func GenerateEncryptionKey() ([]byte, error)
- type AESEncryptor
- type EncryptedString
- type Encryptor
- type JSONField
- type KMSEncryptor
- type MarshalUnmarshaler
- type Marshaler
- type Money
- type PreciseTime
- type StringSet
- func (ss *StringSet) Add(values ...string)
- func (ss StringSet) Contains(value string) bool
- func (ss StringSet) IsEmpty() bool
- func (ss StringSet) MarshalDynamORM() (interface{}, error)
- func (ss *StringSet) Remove(values ...string)
- func (ss StringSet) Size() int
- func (ss StringSet) String() string
- func (ss StringSet) ToSlice() []string
- func (ss *StringSet) UnmarshalDynamORM(data interface{}) error
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeEncryptionKey ¶
EncodeEncryptionKey encodes an encryption key as base64
func GenerateEncryptionKey ¶
GenerateEncryptionKey creates an encryption key for testing
Types ¶
type AESEncryptor ¶
type AESEncryptor struct {
// contains filtered or unexported fields
}
AESEncryptor implements AES encryption
func NewAESEncryptor ¶
func NewAESEncryptor() (*AESEncryptor, error)
NewAESEncryptor creates a new AES encryptor from centralized config
func NewAESEncryptorWithKey ¶
func NewAESEncryptorWithKey(key []byte) (*AESEncryptor, error)
NewAESEncryptorWithKey creates a new AES encryptor with provided key
type EncryptedString ¶
type EncryptedString struct {
Value string
// contains filtered or unexported fields
}
EncryptedString represents an encrypted string value
func NewEncryptedString ¶
func NewEncryptedString(value string, encryptor Encryptor) EncryptedString
NewEncryptedString creates a new EncryptedString
func (EncryptedString) MarshalDynamORM ¶
func (es EncryptedString) MarshalDynamORM() (interface{}, error)
MarshalDynamORM implements the Marshaler interface for EncryptedString
func (*EncryptedString) SetEncryptor ¶
func (es *EncryptedString) SetEncryptor(encryptor Encryptor)
SetEncryptor sets the encryptor for the EncryptedString
func (EncryptedString) String ¶
func (es EncryptedString) String() string
String returns the decrypted value (be careful with logging!)
func (*EncryptedString) UnmarshalDynamORM ¶
func (es *EncryptedString) UnmarshalDynamORM(data interface{}) error
UnmarshalDynamORM implements the Unmarshaler interface for EncryptedString
type Encryptor ¶
type Encryptor interface {
Encrypt(plaintext []byte) ([]byte, error)
Decrypt(ciphertext []byte) ([]byte, error)
}
Encryptor interface for encryption operations
type JSONField ¶
type JSONField struct {
Data any
}
JSONField represents a field that stores arbitrary JSON data
func (JSONField) MarshalDynamORM ¶
MarshalDynamORM implements the Marshaler interface for JSONField
func (*JSONField) UnmarshalDynamORM ¶
UnmarshalDynamORM implements the Unmarshaler interface for JSONField
func (JSONField) UnmarshalInto ¶
UnmarshalInto unmarshals the JSON data into a specific type
type KMSEncryptor ¶
type KMSEncryptor struct {
// contains filtered or unexported fields
}
KMSEncryptor implements encryption using AWS KMS
func NewKMSEncryptor ¶
func NewKMSEncryptor(keyID string) (*KMSEncryptor, error)
NewKMSEncryptor creates a new KMS encryptor
func (*KMSEncryptor) Decrypt ¶
func (e *KMSEncryptor) Decrypt(ciphertext []byte) ([]byte, error)
Decrypt decrypts ciphertext using KMS
func (*KMSEncryptor) DecryptFromBase64 ¶
func (e *KMSEncryptor) DecryptFromBase64(encoded string) ([]byte, error)
DecryptFromBase64 decrypts from base64-encoded ciphertext
func (*KMSEncryptor) Encrypt ¶
func (e *KMSEncryptor) Encrypt(plaintext []byte) ([]byte, error)
Encrypt encrypts plaintext using KMS
func (*KMSEncryptor) EncryptToBase64 ¶
func (e *KMSEncryptor) EncryptToBase64(plaintext []byte) (string, error)
EncryptToBase64 encrypts and returns base64-encoded ciphertext
type MarshalUnmarshaler ¶
type MarshalUnmarshaler interface {
Marshaler
Unmarshaler
}
MarshalUnmarshaler combines both interfaces
type Marshaler ¶
type Marshaler interface {
MarshalDynamORM() (interface{}, error)
}
Marshaler interface for custom DynamORM marshaling
type Money ¶
Money represents monetary values with currency information
func NewMoneyFromFloat ¶
NewMoneyFromFloat creates a new Money instance from a float64
func NewMoneyFromString ¶
NewMoneyFromString creates a new Money instance from a string
func (Money) MarshalDynamORM ¶
MarshalDynamORM implements the Marshaler interface for Money
func (*Money) UnmarshalDynamORM ¶
UnmarshalDynamORM implements the Unmarshaler interface for Money
type PreciseTime ¶
PreciseTime represents a time with configurable precision
func NewPreciseTime ¶
func NewPreciseTime(t time.Time, precision time.Duration) PreciseTime
NewPreciseTime creates a new PreciseTime with the specified precision
func NewPreciseTimeNow ¶
func NewPreciseTimeNow(precision time.Duration) PreciseTime
NewPreciseTimeNow creates a new PreciseTime with the current time and specified precision
func (PreciseTime) MarshalDynamORM ¶
func (pt PreciseTime) MarshalDynamORM() (interface{}, error)
MarshalDynamORM implements the Marshaler interface for PreciseTime
func (PreciseTime) String ¶
func (pt PreciseTime) String() string
String returns a string representation of PreciseTime
func (*PreciseTime) UnmarshalDynamORM ¶
func (pt *PreciseTime) UnmarshalDynamORM(data interface{}) error
UnmarshalDynamORM implements the Unmarshaler interface for PreciseTime
type StringSet ¶
type StringSet struct {
Values []string
}
StringSet represents a DynamoDB string set with additional functionality
func NewStringSet ¶
NewStringSet creates a new StringSet
func (StringSet) MarshalDynamORM ¶
MarshalDynamORM implements the Marshaler interface for StringSet
func (*StringSet) UnmarshalDynamORM ¶
UnmarshalDynamORM implements the Unmarshaler interface for StringSet
type Unmarshaler ¶
type Unmarshaler interface {
UnmarshalDynamORM(interface{}) error
}
Unmarshaler interface for custom DynamORM unmarshaling