Documentation
¶
Overview ¶
Package supabase provides Secrets-specific database operations.
Package supabase provides Secrets-specific database operations.
Index ¶
- type AuditLog
- type Policy
- type Repository
- func (r *Repository) CreateAuditLog(ctx context.Context, log *AuditLog) error
- func (r *Repository) CreatePolicy(ctx context.Context, policy *Policy) error
- func (r *Repository) CreateSecret(ctx context.Context, secret *Secret) error
- func (r *Repository) DeletePolicy(ctx context.Context, id, userID string) error
- func (r *Repository) DeleteSecret(ctx context.Context, userID, name string) error
- func (r *Repository) GetAllowedServices(ctx context.Context, userID, secretName string) ([]string, error)
- func (r *Repository) GetAuditLogs(ctx context.Context, userID string, limit int) ([]AuditLog, error)
- func (r *Repository) GetAuditLogsForSecret(ctx context.Context, userID, secretName string, limit int) ([]AuditLog, error)
- func (r *Repository) GetPolicies(ctx context.Context, userID string) ([]Policy, error)
- func (r *Repository) GetPoliciesForSecret(ctx context.Context, userID, secretName string) ([]Policy, error)
- func (r *Repository) GetSecretByName(ctx context.Context, userID, name string) (*Secret, error)
- func (r *Repository) GetSecrets(ctx context.Context, userID string) ([]Secret, error)
- func (r *Repository) SetAllowedServices(ctx context.Context, userID, secretName string, services []string) error
- func (r *Repository) UpdateSecret(ctx context.Context, secret *Secret) error
- type RepositoryInterface
- type Secret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditLog ¶
type AuditLog struct {
ID string `json:"id"`
UserID string `json:"user_id"`
SecretName string `json:"secret_name"`
Action string `json:"action"` // create, read, update, delete, grant, revoke
ServiceID string `json:"service_id,omitempty"` // Service that accessed the secret
IPAddress string `json:"ip_address,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
Success bool `json:"success"`
ErrorMessage string `json:"error_message,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
AuditLog represents an audit log entry for secret operations.
type Policy ¶
type Policy struct {
ID string `json:"id"`
UserID string `json:"user_id"`
SecretName string `json:"secret_name"`
ServiceID string `json:"service_id"`
CreatedAt time.Time `json:"created_at"`
}
Policy represents an allowed service for a secret.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository provides Secrets-specific data access methods.
func NewRepository ¶
func NewRepository(base *database.Repository) *Repository
NewRepository creates a new Secrets repository.
func (*Repository) CreateAuditLog ¶
func (r *Repository) CreateAuditLog(ctx context.Context, log *AuditLog) error
CreateAuditLog creates a new audit log entry.
func (*Repository) CreatePolicy ¶
func (r *Repository) CreatePolicy(ctx context.Context, policy *Policy) error
CreatePolicy creates a new secret policy.
func (*Repository) CreateSecret ¶
func (r *Repository) CreateSecret(ctx context.Context, secret *Secret) error
CreateSecret creates a new secret.
func (*Repository) DeletePolicy ¶
func (r *Repository) DeletePolicy(ctx context.Context, id, userID string) error
DeletePolicy deletes a secret policy.
func (*Repository) DeleteSecret ¶
func (r *Repository) DeleteSecret(ctx context.Context, userID, name string) error
DeleteSecret deletes a secret by user ID and name.
func (*Repository) GetAllowedServices ¶
func (r *Repository) GetAllowedServices(ctx context.Context, userID, secretName string) ([]string, error)
GetAllowedServices returns the list of service IDs allowed to access a user's secret.
func (*Repository) GetAuditLogs ¶
func (r *Repository) GetAuditLogs(ctx context.Context, userID string, limit int) ([]AuditLog, error)
GetAuditLogs retrieves audit logs for a user with optional limit.
func (*Repository) GetAuditLogsForSecret ¶
func (r *Repository) GetAuditLogsForSecret(ctx context.Context, userID, secretName string, limit int) ([]AuditLog, error)
GetAuditLogsForSecret retrieves audit logs for a specific secret with optional limit.
func (*Repository) GetPolicies ¶
GetPolicies retrieves all policies for a user.
func (*Repository) GetPoliciesForSecret ¶
func (r *Repository) GetPoliciesForSecret(ctx context.Context, userID, secretName string) ([]Policy, error)
GetPoliciesForSecret retrieves policies for a specific secret.
func (*Repository) GetSecretByName ¶
GetSecretByName retrieves a secret by user ID and name.
func (*Repository) GetSecrets ¶
GetSecrets retrieves all secrets for a user.
func (*Repository) SetAllowedServices ¶
func (r *Repository) SetAllowedServices(ctx context.Context, userID, secretName string, services []string) error
SetAllowedServices replaces the allowed service list for a user's secret.
func (*Repository) UpdateSecret ¶
func (r *Repository) UpdateSecret(ctx context.Context, secret *Secret) error
UpdateSecret updates an existing secret.
type RepositoryInterface ¶
type RepositoryInterface interface {
// Secret Operations
GetSecrets(ctx context.Context, userID string) ([]Secret, error)
GetSecretByName(ctx context.Context, userID, name string) (*Secret, error)
CreateSecret(ctx context.Context, secret *Secret) error
UpdateSecret(ctx context.Context, secret *Secret) error
DeleteSecret(ctx context.Context, userID, name string) error
// Policy Operations
GetPolicies(ctx context.Context, userID string) ([]Policy, error)
CreatePolicy(ctx context.Context, policy *Policy) error
DeletePolicy(ctx context.Context, id, userID string) error
GetPoliciesForSecret(ctx context.Context, userID, secretName string) ([]Policy, error)
GetAllowedServices(ctx context.Context, userID, secretName string) ([]string, error)
SetAllowedServices(ctx context.Context, userID, secretName string, services []string) error
// Audit Log Operations
CreateAuditLog(ctx context.Context, log *AuditLog) error
GetAuditLogs(ctx context.Context, userID string, limit int) ([]AuditLog, error)
GetAuditLogsForSecret(ctx context.Context, userID, secretName string, limit int) ([]AuditLog, error)
}
RepositoryInterface defines Secrets-specific data access methods. This interface allows for easy mocking in tests.
type Secret ¶
type Secret struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Name string `json:"name"`
EncryptedValue []byte `json:"encrypted_value"`
Version int `json:"version"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Secret represents an encrypted secret.