Documentation
¶
Index ¶
- func AllowInsecure(flagValue bool) (bool, error)
- func FirstNonEmpty(values ...string) string
- func FirstPresentEnv(names ...string) string
- func InsecureTransportOptInError(includeFlag bool) error
- func NewClientCredentials(cfg ClientTransportConfig, serverName string) (credentials.TransportCredentials, error)
- func NewServerCredentials(cfg ServerTransportConfig) (credentials.TransportCredentials, error)
- func ReadSecretFile(path string) (string, error)
- func ResolveServerName(address, override, defaultServerName string) string
- func ResolveToken(explicitValue, explicitFile string, envValueNames, envFileNames []string) (string, string, error)
- func StreamServerInterceptor(token string) grpc.StreamServerInterceptor
- func UnaryServerInterceptor(token string) grpc.UnaryServerInterceptor
- type ClientTransportConfig
- type ServerTransportConfig
- type TokenCredentials
- type TransportMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowInsecure ¶
AllowInsecure returns true when the caller has explicitly opted into the current plaintext gRPC transport via flag or environment variable.
func FirstNonEmpty ¶
FirstNonEmpty returns the first non-empty, trimmed value.
func FirstPresentEnv ¶
FirstPresentEnv returns the first non-empty environment variable value.
func InsecureTransportOptInError ¶
InsecureTransportOptInError explains how to explicitly keep using the legacy plaintext gRPC transport until mTLS support is configured.
func NewClientCredentials ¶
func NewClientCredentials(cfg ClientTransportConfig, serverName string) (credentials.TransportCredentials, error)
func NewServerCredentials ¶
func NewServerCredentials(cfg ServerTransportConfig) (credentials.TransportCredentials, error)
func ReadSecretFile ¶
ReadSecretFile reads a text secret from disk and trims trailing whitespace.
func ResolveServerName ¶
func ResolveToken ¶
func ResolveToken(explicitValue, explicitFile string, envValueNames, envFileNames []string) (string, string, error)
ResolveToken resolves a shared auth token from explicit values, then environment variables, then token files referenced by environment variables.
func StreamServerInterceptor ¶
func StreamServerInterceptor(token string) grpc.StreamServerInterceptor
StreamServerInterceptor validates the PSK token on streaming RPCs.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(token string) grpc.UnaryServerInterceptor
UnaryServerInterceptor validates the PSK token on unary RPCs.
Types ¶
type ClientTransportConfig ¶
type ClientTransportConfig struct {
Mode TransportMode
CACertPath string
CertPath string
KeyPath string
ServerName string
}
func ResolveClientTransport ¶
func ResolveClientTransport(modeValue string, allowInsecure bool, caCertPath, certPath, keyPath, serverName string) (ClientTransportConfig, error)
type ServerTransportConfig ¶
type ServerTransportConfig struct {
Mode TransportMode
CACertPath string
CertPath string
KeyPath string
}
func ResolveServerTransport ¶
func ResolveServerTransport(modeValue string, allowInsecure bool, caCertPath, certPath, keyPath string) (ServerTransportConfig, error)
type TokenCredentials ¶
TokenCredentials implements grpc.PerRPCCredentials for the client side.
func (TokenCredentials) GetRequestMetadata ¶
func (TokenCredentials) RequireTransportSecurity ¶
func (t TokenCredentials) RequireTransportSecurity() bool
type TransportMode ¶
type TransportMode string
const ( TransportModeMTLS TransportMode = "mtls" TransportModeInsecure TransportMode = "insecure" )