credentialapi

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package credentialapi owns metadata management and private, workload-bound secret delivery. The resolution endpoint never authenticates human/API keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Providers

func Providers(kube client.Client) cb.Registry

Providers are process-owned; source metadata cannot choose endpoints or supply provider credentials. Reads use ambient workload identity. No provider error text or response body escapes this package. Providers returns the reader Registry the broker resolves through. Only the kubernetes provider is enabled (cb.ProviderSupported); cloud readers live in cloud_readers.go and are intentionally not registered.

Readers are process-owned; source metadata cannot choose endpoints or supply provider credentials. No provider error text escapes this package.

Types

type Handler

type Handler struct {
	Store        Store
	Kube         client.Client
	Authenticate func(context.Context, string) (sessionstate.Server, error)
	Providers    cb.Registry
	// Limits bounds resolution requests per source address (before TokenReview)
	// and per server, and briefly remembers provider failures. Nil uses a
	// process-wide default.
	Limits *Limits
}

func (Handler) Management

func (h Handler) Management(w http.ResponseWriter, r *http.Request)

func (Handler) Resolve

func (h Handler) Resolve(w http.ResponseWriter, r *http.Request)

type Limits

type Limits struct {
	Now func() time.Time
	// contains filtered or unexported fields
}

Limits holds rate limiters and a short, bounded negative cache of provider failures. It never stores secret values: only a key and an expiry.

func NewLimits

func NewLimits() *Limits

func (*Limits) AllowColdReview

func (l *Limits) AllowColdReview(addr string) bool

AllowColdReview charges the global TokenReview budget and the per-source budget. It applies only to tokens not already verified or rejected recently, so traffic with unknown tokens can never throttle a cached valid caller.

func (*Limits) AllowRenewal

func (l *Limits) AllowRenewal(key string) bool

AllowRenewal charges only the token's own renewal budget, never the cold-token or per-source budgets.

func (*Limits) AllowServer

func (l *Limits) AllowServer(uid string) bool

func (*Limits) CachedAuth

func (l *Limits) CachedAuth(key string) (sessionstate.Server, authState)

CachedAuth returns the cached verdict state for a token hash.

func (*Limits) ForgetAuth

func (l *Limits) ForgetAuth(key string)

ForgetAuth drops a token's valid verdict after a definite rejection.

func (*Limits) RecentFailure

func (l *Limits) RecentFailure(key string) bool

RecentFailure reports whether a provider read for key failed within failureTTL.

func (*Limits) RecordAuth

func (l *Limits) RecordAuth(key string, server sessionstate.Server, valid bool)

func (*Limits) RecordFailure

func (l *Limits) RecordFailure(key string)

type Store

type Store interface {
	ListCredentials(context.Context, passport.Principal, string, string) ([]json.RawMessage, error)
	PutCredential(context.Context, passport.Principal, *cb.Source, *cb.Binding) (json.RawMessage, error)
	DeleteCredential(context.Context, passport.Principal, string, string, string, int64) error
	// UseCredentials calls authorize before and again after fetch. fetch (provider
	// I/O) must run without holding shared locks; the value is returned only if
	// the second authorize, run after re-reading current state, still allows it.
	UseCredentials(ctx context.Context, server sessionstate.Server, request cb.ResolutionRequest, authorize func(sessionstate.Session, []cb.Binding, []cb.Source) error, fetch func(sessionstate.Session, []cb.Binding, []cb.Source) (cb.Delivery, error)) (cb.Delivery, error)
}

Jump to

Keyboard shortcuts

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