vault

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLog

type AuditLog struct {
	ID        uint      `json:"id" gorm:"primaryKey"`
	UserID    string    `json:"user_id" gorm:"index;not null"`
	SecretKey string    `json:"secret_key" gorm:"not null"`
	Action    string    `json:"action" gorm:"not null"` // CREATE, READ, UPDATE, DELETE
	IPAddress string    `json:"ip_address"`
	UserAgent string    `json:"user_agent"`
	CreatedAt time.Time `json:"created_at"`
}

AuditLog represents an audit log entry for secret operations

func (AuditLog) TableName

func (AuditLog) TableName() string

TableName returns the table name for the AuditLog model

type Secret

type Secret struct {
	ID          uint           `json:"id" gorm:"primaryKey"`
	UserID      string         `json:"user_id" gorm:"index;not null"`
	Key         string         `json:"key" gorm:"not null"`
	Value       string         `json:"value,omitempty" gorm:"not null"` // Encrypted
	Description string         `json:"description"`
	Tags        StringSlice    `json:"tags" gorm:"type:text"`
	CreatedAt   time.Time      `json:"created_at"`
	UpdatedAt   time.Time      `json:"updated_at"`
	DeletedAt   gorm.DeletedAt `json:"-" gorm:"index"`
}

Secret represents a stored secret

func (Secret) TableName

func (Secret) TableName() string

TableName returns the table name for the Secret model

type SecretListItem

type SecretListItem struct {
	Key         string      `json:"key"`
	Description string      `json:"description"`
	Tags        StringSlice `json:"tags"`
	CreatedAt   time.Time   `json:"created_at"`
	UpdatedAt   time.Time   `json:"updated_at"`
}

SecretListItem represents a secret in list operations (without value)

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides vault operations

func NewService

func NewService() *Service

NewService creates a new vault service

func (*Service) DeleteSecret

func (s *Service) DeleteSecret(ctx context.Context, userID, key string) error

DeleteSecret deletes a secret

func (*Service) GetSecret

func (s *Service) GetSecret(ctx context.Context, userID, key string) (*Secret, error)

GetSecret retrieves a secret by key

func (*Service) ListSecrets

func (s *Service) ListSecrets(ctx context.Context, userID string) ([]*SecretListItem, error)

ListSecrets returns a list of all secrets (without values)

func (*Service) SetDB

func (s *Service) SetDB(db *gorm.DB)

SetDB sets the database connection

func (*Service) SetMasterPassword

func (s *Service) SetMasterPassword(password string)

SetMasterPassword sets the master password for encryption

func (*Service) StoreSecret

func (s *Service) StoreSecret(ctx context.Context, userID string, secret *Secret) error

StoreSecret stores a new secret

func (*Service) UpdateSecret

func (s *Service) UpdateSecret(ctx context.Context, userID string, secret *Secret) error

UpdateSecret updates an existing secret

type StringSlice

type StringSlice []string

StringSlice is a custom type for handling string slices in GORM

func (*StringSlice) Scan

func (s *StringSlice) Scan(value interface{}) error

Scan implements the Scanner interface for database deserialization

func (StringSlice) Value

func (s StringSlice) Value() (driver.Value, error)

Value implements the Valuer interface for database serialization

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL