providerauth

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package providerauth owns renewable credentials for provider inference. It does not read or reuse Starmap catalog-acquisition credentials.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSourceRequired reports a missing credential source.
	ErrSourceRequired = errors.New("provider credential source is required")
	// ErrTokenEmpty reports a credential source that returned no token value.
	ErrTokenEmpty = errors.New("provider credential token is empty")
	// ErrTokenExpiryRequired reports a renewable token without an expiry.
	ErrTokenExpiryRequired = errors.New("provider credential token expiry is required")
	// ErrTokenStale reports a credential source that returned a token too close
	// to expiry for a new inference request.
	ErrTokenStale = errors.New("provider credential token is stale")
	// ErrCredentialRedirect reports an attempt to reuse renewable provider
	// credentials on an HTTP redirect.
	ErrCredentialRedirect = errors.New("provider credential redirect is not allowed")
)

Functions

func NewBearerTransport

func NewBearerTransport(base http.RoundTripper, source Source) http.RoundTripper

NewBearerTransport returns a transport that obtains a bearer token for each request. The source can cache a fresh token between requests.

Types

type Mode

type Mode string

Mode selects the operator-owned inference credential source.

const (
	// ModeStatic uses the configured provider secret.
	ModeStatic Mode = "static"
	// ModeDefault uses the cloud platform's default credential chain.
	ModeDefault Mode = "default"
)

func (Mode) Validate

func (m Mode) Validate() error

Validate checks a configured mode. An empty mode is valid for providers that use a directly configured secret.

type RefreshOptions

type RefreshOptions struct {
	RefreshBefore time.Duration
	Now           func() time.Time
}

RefreshOptions configures a refreshable credential source.

type Source

type Source interface {
	Token(context.Context) (Token, error)
}

Source supplies provider inference bearer tokens.

func NewAzureDefaultSource

func NewAzureDefaultSource() (Source, error)

NewAzureDefaultSource uses Azure DefaultAzureCredential for Azure OpenAI inference.

func NewGoogleDefaultSource

func NewGoogleDefaultSource() (Source, error)

NewGoogleDefaultSource uses Google Application Default Credentials for Vertex AI inference.

func NewRefreshingSource

func NewRefreshingSource(upstream Source, options RefreshOptions) (Source, error)

NewRefreshingSource caches a token and replaces it before expiry. One caller performs each refresh. Other callers can stop waiting through their own contexts.

type SourceFunc

type SourceFunc func(context.Context) (Token, error)

SourceFunc adapts a function to Source.

func (SourceFunc) Token

func (f SourceFunc) Token(ctx context.Context) (Token, error)

Token supplies one provider inference bearer token.

type Token

type Token struct {
	Value          string
	ExpiresAt      time.Time
	QuotaProjectID string
}

Token is one provider inference bearer token.

Jump to

Keyboard shortcuts

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