tokencache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tokencache caches extension token verification for one Engine process. Invalidation is local: other replicas observe a revocation only after their entry expires, so TTL bounds cross-replica revocation lag.

Index

Constants

View Source
const MaxTTL = 30 * time.Second

MaxTTL caps how long a revoked token can remain valid on another replica.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a bounded TTL cache of verification results keyed by site and token hash.

func New

func New(cfg Config) *Cache

New returns a cache, clamping TTL to MaxTTL and NegativeTTL to 5s.

func (*Cache) InvalidateSite

func (c *Cache) InvalidateSite(site string)

InvalidateSite drops every cached result for site.

func (*Cache) Wrap

func (c *Cache) Wrap(next Verifier) Verifier

Wrap returns a Verifier that consults the cache before next.

type Config

type Config struct {
	TTL         time.Duration
	NegativeTTL time.Duration
	MaxEntries  int
	Now         func() time.Time
}

Config sets entry lifetimes and capacity. Zero NegativeTTL disables caching of unknown tokens.

type Verifier

type Verifier interface {
	VerifyAccessToken(ctx context.Context, site, tokenHash string) (extension.Credential, error)
}

Verifier resolves the active extension owning a token verifier.

Jump to

Keyboard shortcuts

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