shared

package
v0.0.0-...-7447204 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultShareDuration = time.Hour * 24 * 30

DefaultShareDuration sets a maximum of 30 days for shared secrets with no defined time limit

Variables

View Source
var (
	ErrEmptyDuration = errors.New("duration cannot be zero")
	ErrEmptyTime     = errors.New("time cannot be zero")
	ErrExpired       = errors.New("input time is already expired")
)

Functions

func ValidateDuration

func ValidateDuration(dur time.Duration) error

ValidateDuration verifies if the input duration is valid, returning an error if otherwise

func ValidateTime

func ValidateTime(t time.Time) error

ValidateTime verifies if the input time is valid, returning an error if otherwise

Types

type Repository

type Repository interface {
	// Create shares the secret identified by `secretName`, owned by `owner`, with
	// user `target`. Returns its ID and an error
	Create(ctx context.Context, s *Share) (uint64, error)
	// Get fetches the secret's share metadata for a given owner's username and secret key
	Get(ctx context.Context, owner, secretName string) ([]*Share, error)
	// List fetches all shared secrets for a given owner's username
	List(ctx context.Context, owner string) ([]*Share, error)
	// ListTarget is similar to List, but returns secrets that are shared with a target user
	ListTarget(ctx context.Context, target string) ([]*Share, error)
	// Delete removes the user `target` from the secret share
	Delete(ctx context.Context, s *Share) error
}

Repository describes the actions exposed by the shared secrets store

func WithTrace

func WithTrace(r Repository) Repository

type Share

type Share struct {
	ID        uint64     `json:"id"`
	SecretKey string     `json:"secret_key"`
	Owner     string     `json:"owner"`
	Target    []string   `json:"shared_with"`
	Until     *time.Time `json:"until,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
}

Shared is metadata for a secret that a user (the owner) shares with a set of users optionally within a limited period of time

Jump to

Keyboard shortcuts

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