Documentation
¶
Overview ¶
Package workloadidentity exchanges a workload's platform identity token (Kubernetes, AWS, GCP, Azure, GitHub Actions, SPIFFE) for a short-lived provider access token, so a provider can authenticate without a static API key.
A Source caches the access token and refreshes it ahead of expiry. The identity token file is re-read on every exchange because projected tokens rotate on disk. Neither the identity token nor the access token is ever logged or included in an error.
Index ¶
Constants ¶
const OpenAITokenEndpoint = "https://auth.openai.com/oauth/token" //nolint:gosec // G101: a public endpoint URL, not a credential.
OpenAITokenEndpoint is the default endpoint for the TokenExchange grant.
Variables ¶
This section is empty.
Functions ¶
func DefaultTokenEndpoint ¶
DefaultTokenEndpoint returns the exchange endpoint used when none is configured. The jwt-bearer endpoint lives under the provider's API base URL (Anthropic: <base_url>/oauth/token), so a custom base URL moves it too.
Types ¶
type Config ¶
type Config struct {
// Provider names the provider instance in logs.
Provider string
Grant Grant
// TokenEndpoint is the exchange URL; see DefaultTokenEndpoint.
TokenEndpoint string
config.WorkloadIdentityConfig
}
Config is a resolved workload identity configuration for one provider.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source hands out a cached provider access token, exchanging the identity token for a new one ahead of expiry. It is safe for concurrent use.
No exchange runs under the lock. While the cached token is still usable, callers get it immediately and one refresh runs in the background. Callers without a usable token wait for the shared exchange, and each stops waiting when its own context ends.
func New ¶
New validates cfg and returns a Source that exchanges through client. No exchange happens until the first Token call.