capabilitymemory

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package capabilitymemory provides process-local replay and revocation adapters. State is not shared across processes and therefore cannot provide cluster-wide one-time or instant revocation semantics.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock supplies wall time for expiry decisions.

type ConsumptionStore

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

ConsumptionStore owns process-local atomic replay state.

func NewConsumptionStore

func NewConsumptionStore(clock Clock) (*ConsumptionStore, error)

NewConsumptionStore constructs an empty process-local store.

Example
now := time.Date(2026, 9, 9, 12, 0, 0, 0, time.UTC)
store, _ := capabilitymemory.NewConsumptionStore(fixedClock{now: now})
result, err := store.Consume(context.Background(), capability.Consumption{
	CapabilityID: "cap-42", MaxUses: 1, ExpiresAt: now.Add(time.Minute),
})
fmt.Println(result.Use, result.Remaining, err == nil)
Output:
1 0 true

func (*ConsumptionStore) Cleanup

func (store *ConsumptionStore) Cleanup(ctx context.Context, cutoff time.Time) (int, error)

Cleanup removes state expiring at or before cutoff and returns the number removed.

func (*ConsumptionStore) Consume

Consume atomically records one use or returns ErrReplayExhausted without incrementing.

type Revocations

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

Revocations is a concurrency-safe process-local revocation set.

func NewRevocations

func NewRevocations() *Revocations

NewRevocations constructs an empty process-local revocation set.

func (*Revocations) Check

func (store *Revocations) Check(ctx context.Context, query capability.RevocationQuery) (bool, error)

Check reports whether any exact revocation boundary matches query.

func (*Revocations) RevokeCapability

func (store *Revocations) RevokeCapability(ctx context.Context, issuer, capabilityID string) error

RevokeCapability revokes one capability ID within an issuer namespace.

func (*Revocations) RevokeIssuedBefore

func (store *Revocations) RevokeIssuedBefore(ctx context.Context, issuer string, cutoff time.Time) error

RevokeIssuedBefore revokes capabilities issued strictly before cutoff. A later cutoff replaces an earlier one; the boundary never moves backward.

func (*Revocations) RevokeKey

func (store *Revocations) RevokeKey(ctx context.Context, issuer, keyID string) error

RevokeKey revokes every capability signed by one key ID for an issuer.

func (*Revocations) RevokeResource

func (store *Revocations) RevokeResource(ctx context.Context, issuer, tenant, resource string) error

RevokeResource revokes an exact issuer, tenant, and resource boundary.

func (*Revocations) RevokeSubject

func (store *Revocations) RevokeSubject(ctx context.Context, issuer, subject string) error

RevokeSubject revokes every subject-bound capability for an issuer.

Jump to

Keyboard shortcuts

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