jwt

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpired  = errors.New("expired")
	ErrInvalid  = errors.New("invalid")
	ErrNotFound = errors.New("not found")
)

predefined cache errors

Functions

func CacheKeyForHost

func CacheKeyForHost(host string, tlsConfig *tls.Config) string

CacheKeyForHost returns the cache key for the given host and tls config.

Types

type Cache

type Cache interface {
	DeleteJWT(key string) error
	LoadJWT(key string) (rawJWT string, err error)
	StoreJWT(key string, rawJWT string) error
}

A Cache loads and stores JWTs.

func GetCache

func GetCache() Cache

GetCache gets the Cache. Either a local one is used or if that's not possible an in-memory one is used.

type LocalCache

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

A LocalCache stores files in the user's cache directory.

func NewLocalCache

func NewLocalCache() (*LocalCache, error)

NewLocalCache creates a new LocalCache.

func (*LocalCache) DeleteJWT

func (cache *LocalCache) DeleteJWT(key string) error

DeleteJWT deletes a raw JWT from the local cache.

func (*LocalCache) LoadJWT

func (cache *LocalCache) LoadJWT(key string) (rawJWT string, err error)

LoadJWT loads a raw JWT from the local cache.

func (*LocalCache) StoreJWT

func (cache *LocalCache) StoreJWT(key string, rawJWT string) error

StoreJWT stores a raw JWT in the local cache.

type MemoryCache

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

A MemoryCache stores JWTs in an in-memory map.

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates a new in-memory JWT cache.

func (*MemoryCache) DeleteJWT

func (cache *MemoryCache) DeleteJWT(key string) error

DeleteJWT deletes a JWT from the in-memory map.

func (*MemoryCache) LoadJWT

func (cache *MemoryCache) LoadJWT(key string) (rawJWT string, err error)

LoadJWT loads a JWT from the in-memory map.

func (*MemoryCache) StoreJWT

func (cache *MemoryCache) StoreJWT(key string, rawJWT string) error

StoreJWT stores a JWT in the in-memory map.

Jump to

Keyboard shortcuts

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