metadata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 6 Imported by: ? 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 metadata caches identity provider metadata documents (issuer and endpoint URLs, supported algorithms and scopes) in a cache Cache.

The cache is an optimisation only: a cache miss, a cache error or an invalid cached document falls back to the Loader, and cache writes are best effort. Every document, cached or loaded, must name exactly the requested issuer and use https endpoints before it is returned.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache serves validated metadata documents from a backing cache with a loader fallback. It is safe for concurrent use when the backing cache and loader are.

func NewCache

func NewCache(backing cache.Cache[string, Document], loader Loader, ttl time.Duration) *Cache

NewCache returns a Cache. backing may be nil to disable caching; ttl <= 0 disables cache writes.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, issuer string) (Document, error)

Get returns the validated document for issuer. It returns authentication.ErrProviderNotFound when nothing is cached and no loader is configured, authentication.ErrInvalidCredential for an invalid loaded document, and loader errors unchanged.

type Document

type Document struct {
	Issuer          string
	AuthURL         string
	TokenURL        string
	JWKSURL         string
	LoadedAt        time.Time
	ExpiresAt       time.Time
	SigningAlgs     []string
	SupportedScopes []string
}

Document is the subset of provider metadata this module uses.

type Loader

type Loader interface {
	Load(context.Context, string) (Document, error)
}

Loader fetches the metadata document for an issuer.

type LoaderFunc

type LoaderFunc func(context.Context, string) (Document, error)

LoaderFunc adapts a function to Loader.

func (LoaderFunc) Load

func (f LoaderFunc) Load(ctx context.Context, issuer string) (Document, error)

Load calls f.

Jump to

Keyboard shortcuts

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