secrets

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package secrets provides a synchronizable set of keys backed by a key-value store.

Index

Constants

View Source
const (
	UniqueIdentifierCharacterSet = "abcdefghijklmnopqrstuvwxyz" +
		"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	VisuallyUnambiguousLowerCaseCharacterSet = `abcdefhijkmnoprstwxy34`
	VisuallyUnambiguousCharacterSet          = VisuallyUnambiguousLowerCaseCharacterSet + `ABCDEFHIJKMNOPRSTWXY`
)

Variables

This section is empty.

Functions

func NewRotation

func NewRotation(callback Callback, withOptions ...Option) (err error)

Types

type Callback

type Callback func(present, past *Secret) error

type Option

type Option func(*options) error

func WithDefaultEntropySizeOf32

func WithDefaultEntropySizeOf32() Option

func WithDefaultExpiryOfOneWeek

func WithDefaultExpiryOfOneWeek() Option

func WithDefaultIDSizeOfSix

func WithDefaultIDSizeOfSix() Option

func WithDefaultLogger

func WithDefaultLogger() Option

func WithDefaultRotationWindow

func WithDefaultRotationWindow() Option

func WithEntropySize

func WithEntropySize(length int) Option

func WithExpiry

func WithExpiry(d time.Duration) Option

func WithIDSize

func WithIDSize(length int) Option

func WithLogger

func WithLogger(logger *slog.Logger) Option

func WithRotationWindow

func WithRotationWindow(d time.Duration) Option

type Rotation

type Rotation struct {
	Snapshot
	// contains filtered or unexported fields
}

func (*Rotation) Loop

func (r *Rotation) Loop(ctx context.Context)

func (*Rotation) Next

func (r *Rotation) Next(expires int64) (s *Secret, err error)

func (*Rotation) Rotate

func (r *Rotation) Rotate(now time.Time) error

type Secret

type Secret struct {
	ID      []byte
	Entropy []byte
	Expires int64
}

type Snapshot

type Snapshot struct {
	Future  *Secret
	Present *Secret
	Past    *Secret
}

func NewSnapshot

func NewSnapshot(b []byte) (s *Snapshot, err error)

func (*Snapshot) Serialize

func (s *Snapshot) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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