store

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltStore

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

func NewBoltStore

func NewBoltStore(dbPath string, encryptionSecret string) *BoltStore

NewBoltStore creates a new BoltStore. If encryptionSecret is non-empty, policies are encrypted at rest using AES-256-GCM.

func (*BoltStore) Close

func (s *BoltStore) Close() error

func (*BoltStore) Create

func (s *BoltStore) Create(tokenHash string, policyJSON string, expiresAt string) error

func (*BoltStore) Delete

func (s *BoltStore) Delete(tokenHash string) error

func (*BoltStore) Get

func (s *BoltStore) Get(tokenHash string) (*TokenRecord, error)

func (*BoltStore) Init

func (s *BoltStore) Init() error

func (*BoltStore) List

func (s *BoltStore) List() ([]TokenRecord, error)

func (*BoltStore) Lookup

func (s *BoltStore) Lookup(tokenHash string) (*policy.Policy, error)

func (*BoltStore) Reload

func (s *BoltStore) Reload() error

func (*BoltStore) SetEmitter

func (s *BoltStore) SetEmitter(e events.Emitter)

SetEmitter configures the event emitter for token lifecycle events.

func (*BoltStore) StartFileWatch

func (s *BoltStore) StartFileWatch(interval time.Duration)

StartFileWatch starts a goroutine that polls the DB file for changes and reloads.

func (*BoltStore) Update

func (s *BoltStore) Update(tokenHash string, policyJSON string, expiresAt string) error

type TokenRecord

type TokenRecord struct {
	ID        int64
	TokenHash string
	Policy    *policy.Policy
	PolicyRaw string
	CreatedAt string
	ExpiresAt string // RFC3339 timestamp or empty for no expiration
}

TokenRecord represents a stored token with its policy.

type TokenStore

type TokenStore interface {
	// Init initializes the store (create tables, load cache, etc.)
	Init() error

	// Create stores a new token hash → policy mapping with optional expiration.
	Create(tokenHash string, policyJSON string, expiresAt string) error

	// Get retrieves a single token record by hash. Returns nil if not found.
	Get(tokenHash string) (*TokenRecord, error)

	// Update replaces the policy and/or expiration for an existing token.
	Update(tokenHash string, policyJSON string, expiresAt string) error

	// Delete removes a token by its hash.
	Delete(tokenHash string) error

	// Lookup retrieves a policy by token hash. Returns nil if not found or expired.
	Lookup(tokenHash string) (*policy.Policy, error)

	// List returns all token records.
	List() ([]TokenRecord, error)

	// Reload refreshes the in-memory cache from the database.
	Reload() error

	// Close cleans up resources.
	Close() error
}

TokenStore is the interface for token persistence and lookup.

Jump to

Keyboard shortcuts

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