cache

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SubNamespace is the plugin sub-namespace within GoModularAuth cache keys.
	SubNamespace = "twofactor"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache wraps the core cache adapter for the twofactor plugin.

func New

func New(core corecache.Cache) *Cache

New creates a Cache wrapper. If core is nil, the wrapper operates in degraded mode.

func (*Cache) Available

func (c *Cache) Available() bool

Available reports whether a backing cache is configured.

func (*Cache) DeleteChallenge

func (c *Cache) DeleteChallenge(ctx context.Context, challengeID string) error

DeleteChallenge removes an MFA challenge from cache upon consumption.

func (*Cache) GetChallenge

func (c *Cache) GetChallenge(ctx context.Context, challengeID string) (*ChallengeCacheEntry, error)

GetChallenge retrieves an MFA challenge from cache.

func (*Cache) IsStepUsed

func (c *Cache) IsStepUsed(ctx context.Context, factorID string, timeStep int64) (bool, error)

IsStepUsed checks whether a specific time-step for a factor was already seen in the cache.

func (*Cache) MarkStepUsed

func (c *Cache) MarkStepUsed(ctx context.Context, factorID string, timeStep int64, ttl time.Duration) error

MarkStepUsed sets an ephemeral replay marker in the cache for a specific factor time-step.

func (*Cache) SetChallenge

func (c *Cache) SetChallenge(ctx context.Context, entry *ChallengeCacheEntry, ttl time.Duration) error

SetChallenge caches a short-lived MFA challenge.

type ChallengeCacheEntry

type ChallengeCacheEntry struct {
	ID        string    `json:"id"`
	UserID    string    `json:"user_id"`
	ExpiresAt time.Time `json:"expires_at"`
	CreatedAt time.Time `json:"created_at"`
}

ChallengeCacheEntry is the serialized representation of an ephemeral MFA challenge stored in cache.

Jump to

Keyboard shortcuts

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