Help us shape the future of Go! Take the 2026 Go Developer Survey

credprovider

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package credprovider implements outbound credential brokering for Agent Mesh egress destinations (static secrets, RFC 8693 OIDC federation with optional Google Service Account impersonation, AWS STS AssumeRoleWithWebIdentity with inline IAM session policy compilation, and platform metadata identity) as well as TaskAuthorizationRule scope/permission/resource narrowing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallerBiscuitFromContext

func CallerBiscuitFromContext(ctx context.Context) []byte

CallerBiscuitFromContext returns the caller Biscuit attached to ctx, or nil.

func CompileAWSSessionPolicy

func CompileAWSSessionPolicy(templateJSON, destName string, rules []*api.TaskAuthorizationRule) (string, error)

CompileAWSSessionPolicy compiles an inline AWS IAM session policy JSON from the destination's session_policy template intersected with the TAR chain. It enforces the "TAR narrows, never selects" invariant: if templateJSON defines allowed Actions or Resources, the TAR chain can only narrow them to a subset, never add Actions or Resources outside the template.

func IntersectTaskPermissionsAndResources

func IntersectTaskPermissionsAndResources(destName string, rules []*api.TaskAuthorizationRule) (perms []string, resources []string, err error)

IntersectTaskPermissionsAndResources computes the intersection of allowed_permissions and allowed_resources across all TaskAuthorizationRules in rules that match egress://<destName>. If two TARs in the chain specify disjoint permissions or disjoint resources, an error is returned.

func NarrowOIDCScopes

func NarrowOIDCScopes(policyScopes []string, destName string, rules []*api.TaskAuthorizationRule) ([]string, error)

NarrowOIDCScopes computes the intersection of policyScopes with any OAuth scope constraints carried in the TaskAuthorizationRule chain for destName. It enforces the "TAR narrows, never selects" invariant:

  • A TAR can shrink policyScopes to a subset.
  • A TAR can never add a scope that is not in policyScopes.
  • If a TAR specifies scope constraints that have an empty intersection with policyScopes, NarrowOIDCScopes returns an error so the exchange fails closed.

func WithCallerBiscuit

func WithCallerBiscuit(ctx context.Context, biscuitBytes []byte) context.Context

WithCallerBiscuit attaches a verified caller Biscuit (such as a narrowed Task Biscuit or an exchanged Delegated Session Biscuit) to ctx so outbound credential brokers key their caches and STS mint requests by the caller's exact token.

Types

type AWSAssumeRoleExchanger

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

AWSAssumeRoleExchanger exchanges a Control-Plane-issued ES256 JWT at AWS STS AssumeRoleWithWebIdentity, compiling the intersected TAR chain into an inline IAM session policy intersected with the destination's session_policy template.

func NewAWSAssumeRoleExchanger

func NewAWSAssumeRoleExchanger(destName string, cfg *api.AWSAssumeRole, mintJWT BorderJWTMintFunc, httpClient *http.Client) *AWSAssumeRoleExchanger

NewAWSAssumeRoleExchanger constructs an AWSAssumeRoleExchanger for destName.

func (*AWSAssumeRoleExchanger) Exchange

func (e *AWSAssumeRoleExchanger) Exchange(ctx context.Context, principal string, rules []*api.TaskAuthorizationRule) (string, time.Time, error)

Exchange compiles the intersected session policy and calls AWS STS AssumeRoleWithWebIdentity.

type BorderJWTMintFunc

type BorderJWTMintFunc func(ctx context.Context, destination, audience string) (jwt string, expiry time.Time, err error)

BorderJWTMintFunc mints an outbound ES256 border JWT from the Control Plane (or a test double) for a destination and audience.

type Exchanger

type Exchanger interface {
	Exchange(ctx context.Context, principal string, rules []*api.TaskAuthorizationRule) (bearerToken string, expiry time.Time, err error)
}

Exchanger translates a verified Agent Mesh principal and its intersected TaskAuthorizationRule chain into a downscoped upstream credential.

type OIDCFederationExchanger

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

OIDCFederationExchanger exchanges a Control-Plane-issued ES256 JWT at a cloud or third-party RFC 8693 STS endpoint (e.g. Google Workload/Workforce Identity Federation or generic OAuth 2.0 token exchange), with optional Google Service Account impersonation and scope narrowing from the TAR chain.

func NewOIDCFederationExchanger

func NewOIDCFederationExchanger(destName string, cfg *api.OIDCFederation, mintJWT BorderJWTMintFunc, httpClient *http.Client) *OIDCFederationExchanger

NewOIDCFederationExchanger constructs an OIDCFederationExchanger for destName.

func (*OIDCFederationExchanger) Exchange

func (e *OIDCFederationExchanger) Exchange(ctx context.Context, principal string, rules []*api.TaskAuthorizationRule) (string, time.Time, error)

Exchange mints a border JWT and exchanges it at the configured STS endpoint, narrowing scopes by the TAR chain while never selecting a broker, audience, service account, or scope outside the destination policy.

type PlatformIdentityExchanger

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

PlatformIdentityExchanger fetches an access token from the node's own cloud metadata server (e.g. GKE Workload Identity / GCE instance metadata).

func NewPlatformIdentityExchanger

func NewPlatformIdentityExchanger(destName string, cfg *api.PlatformIdentity, httpClient *http.Client) *PlatformIdentityExchanger

NewPlatformIdentityExchanger constructs a PlatformIdentityExchanger.

func (*PlatformIdentityExchanger) Exchange

Exchange queries the platform metadata server with scopes narrowed by the TAR chain.

type StaticSecretExchanger

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

StaticSecretExchanger reads a static secret file from the node's secrets directory. A TaskAuthorizationRule cannot alter or replace a static secret.

func NewStaticSecretExchanger

func NewStaticSecretExchanger(secretsDir, secretName string) *StaticSecretExchanger

NewStaticSecretExchanger constructs a StaticSecretExchanger for secretName in secretsDir.

func (*StaticSecretExchanger) Exchange

Exchange reads the secret from disk per request so platform secret rotations apply immediately.

Jump to

Keyboard shortcuts

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