security

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowInsecure

func AllowInsecure(flagValue bool) (bool, error)

AllowInsecure returns true when the caller has explicitly opted into the current plaintext gRPC transport via flag or environment variable.

func FirstNonEmpty

func FirstNonEmpty(values ...string) string

FirstNonEmpty returns the first non-empty, trimmed value.

func FirstPresentEnv

func FirstPresentEnv(names ...string) string

FirstPresentEnv returns the first non-empty environment variable value.

func InsecureTransportOptInError

func InsecureTransportOptInError(includeFlag bool) error

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 ReadSecretFile

func ReadSecretFile(path string) (string, error)

ReadSecretFile reads a text secret from disk and trims trailing whitespace.

func ResolveServerName

func ResolveServerName(address, override, defaultServerName string) string

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

type TokenCredentials struct {
	Token      string
	RequireTLS bool
}

TokenCredentials implements grpc.PerRPCCredentials for the client side.

func (TokenCredentials) GetRequestMetadata

func (t TokenCredentials) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

func (TokenCredentials) RequireTransportSecurity

func (t TokenCredentials) RequireTransportSecurity() bool

type TransportMode

type TransportMode string
const (
	TransportModeMTLS     TransportMode = "mtls"
	TransportModeInsecure TransportMode = "insecure"
)

Jump to

Keyboard shortcuts

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