package transport

import "cloud.google.com/go/auth/internal/transport"

Package transport provided internal helpers for the two transport packages (grpctransport and httptransport).

Index

Functions

func BaseTransport

func BaseTransport() *http.Transport

BaseTransport returns a default http.Transport which can be used if http.DefaultTransport has been overwritten.

func CloneDetectOptions

func CloneDetectOptions(oldDo *credentials.DetectOptions) *credentials.DetectOptions

CloneDetectOptions clones a user set detect option into some new memory that we can internally manipulate before sending onto the detect package.

func DefaultHTTPClientWithTLS

func DefaultHTTPClientWithTLS(tlsConfig *tls.Config) *http.Client

DefaultHTTPClientWithTLS constructs an HTTPClient using the provided tlsConfig, to support mTLS.

func GetClientCertificateProvider

func GetClientCertificateProvider(opts *Options) (cert.Provider, error)

GetClientCertificateProvider returns a default client certificate source, if not provided by the user.

A nil default source can be returned if the source does not exist. Any exceptions encountered while initializing the default source will be reported as client error (ex. corrupt metadata file).

func GetHTTPTransportConfig

func GetHTTPTransportConfig(opts *Options) (cert.Provider, func(context.Context, string, string) (net.Conn, error), error)

GetHTTPTransportConfig returns a client certificate source and a function for dialing MTLS with S2A.

func GetMTLSS2AAddress

func GetMTLSS2AAddress(logger *slog.Logger) string

GetMTLSS2AAddress returns the S2A address to be reached via MTLS connection. Returns empty string if not set or invalid.

func GetS2AAddress

func GetS2AAddress(logger *slog.Logger) string

GetS2AAddress returns the S2A address to be reached via plaintext connection. Returns empty string if not set or invalid.

func StaticTelemetryAttributes

func StaticTelemetryAttributes(m map[string]string) []attribute.KeyValue

StaticTelemetryAttributes selectively converts known keys from a map of strings to Open Telemetry attributes.

func ValidateUniverseDomain

func ValidateUniverseDomain(clientUniverseDomain, credentialsUniverseDomain string) error

ValidateUniverseDomain verifies that the universe domain configured for the client matches the universe domain configured for the credentials.

Types

type GRPCTransportCredentials

type GRPCTransportCredentials struct {
	credentials.TransportCredentials
	Endpoint      string
	TransportType Type
}

GRPCTransportCredentials embeds interface TransportCredentials with additional data.

func GetGRPCTransportCredsAndEndpoint

func GetGRPCTransportCredsAndEndpoint(opts *Options) (*GRPCTransportCredentials, error)

GetGRPCTransportCredsAndEndpoint returns an instance of google.golang.org/grpc/credentials.TransportCredentials, and the corresponding endpoint and transport type to use for GRPC client.

type Options

type Options struct {
	Endpoint                string
	DefaultEndpointTemplate string
	DefaultMTLSEndpoint     string
	ClientCertProvider      cert.Provider
	Client                  *http.Client
	UniverseDomain          string
	EnableDirectPath        bool
	EnableDirectPathXds     bool
	Logger                  *slog.Logger
}

Options is a struct that is duplicated information from the individual transport packages in order to avoid cyclic deps. It correlates 1:1 with fields on httptransport.Options and grpctransport.Options.

type Type

type Type int

Type represents the type of transport used.

const (
	// TransportTypeUnknown represents an unknown transport type and is the default option.
	TransportTypeUnknown Type = iota
	// TransportTypeMTLSS2A represents the mTLS transport type using S2A.
	TransportTypeMTLSS2A
)

Source Files

cba.go s2a.go transport.go

Directories

PathSynopsis
internal/transport/cert
internal/transport/cert/cmdtest_signer.go is a net/rpc server that listens on stdin/stdout, exposing mock methods for testing enterprise certificate proxy flow.
internal/transport/headers
Version
v0.20.0 (latest)
Published
Apr 6, 2026
Platform
darwin/amd64
Imports
23 packages
Last checked
21 minutes ago

Tools for package owners.