store

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2025 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Overview

Package store defines simple token and client-configuration stores used by the authorization helpers in the parent `auth` package.

It currently ships with an in-memory implementation that is sufficient for most CLI or unit-test scenarios but can be swapped for a persistent backend if required.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore added in v0.7.4

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

FileStore persists tokens to a JSON file, while delegating other lookups to an in-memory store. It is a lightweight way to survive process restarts in CLI or single-host services.

func (*FileStore) AddAuthorizationServerMetadata added in v0.7.4

func (f *FileStore) AddAuthorizationServerMetadata(metadata *meta.AuthorizationServerMetadata) error

func (*FileStore) AddClientConfig added in v0.7.4

func (f *FileStore) AddClientConfig(issuer string, client *oauth2.Config) error

func (*FileStore) AddIssuerPublicKeys added in v0.7.4

func (f *FileStore) AddIssuerPublicKeys(issuer string, keys map[string]crypto.PublicKey) error

func (*FileStore) AddToken added in v0.7.4

func (f *FileStore) AddToken(key TokenKey, token *oauth2.Token) error

func (*FileStore) LookupAuthorizationServerMetadata added in v0.7.4

func (f *FileStore) LookupAuthorizationServerMetadata(issuer string) (*meta.AuthorizationServerMetadata, bool)

func (*FileStore) LookupClientConfig added in v0.7.4

func (f *FileStore) LookupClientConfig(issuer string) (*oauth2.Config, bool)

func (*FileStore) LookupIssuerPublicKeys added in v0.7.4

func (f *FileStore) LookupIssuerPublicKeys(issuer string) (map[string]crypto.PublicKey, bool)

func (*FileStore) LookupToken added in v0.7.4

func (f *FileStore) LookupToken(key TokenKey) (*oauth2.Token, bool)

type MemoryStoreOption

type MemoryStoreOption func(*memoryStore)

func WithClientConfig

func WithClientConfig(client *oauth2.Config) MemoryStoreOption

type Store

type Store interface {
	LookupClientConfig(issuer string) (*oauth2.Config, bool)
	AddClientConfig(issuer string, client *oauth2.Config) error
	AddAuthorizationServerMetadata(metadata *meta.AuthorizationServerMetadata) error
	LookupAuthorizationServerMetadata(issuer string) (*meta.AuthorizationServerMetadata, bool)
	AddIssuerPublicKeys(issuer string, keys map[string]crypto.PublicKey) error
	LookupIssuerPublicKeys(issuer string) (map[string]crypto.PublicKey, bool)
	AddToken(key TokenKey, token *oauth2.Token) error
	LookupToken(key TokenKey) (*oauth2.Token, bool)
}

Store is a pluggable persistence layer for tokens & client IDs. The in‑memory default is fine for CLI tools; swap with Redis/SQL for fleets.

func NewFileStore added in v0.7.4

func NewFileStore(path string, options ...MemoryStoreOption) Store

NewFileStore creates a Store that persists tokens at the given path. Client configs and metadata are kept in-memory (they can be rediscovered).

func NewMemoryStore

func NewMemoryStore(options ...MemoryStoreOption) Store

type TokenKey

type TokenKey struct {
	Issuer string
	Scopes string
}

Jump to

Keyboard shortcuts

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