basic

package
v1.15.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MPL-2.0 Imports: 18 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(address string, creds credentials.PerRPCCredentials, acceptedCAs []*x509.PEMEncodedCertificate, opts ...ConnectionOption) (conn *grpc.ClientConn, err error)

NewConnection initializes a grpc.ClientConn configured for basic authentication.

func NewTLSConfig

func NewTLSConfig(acceptedCAs []*x509.PEMEncodedCertificate, opts ...ConnectionOption) *tls.Config

NewTLSConfig builds client TLS configuration which verifies the server against the accepted CAs.

Types

type ConnectionOption

type ConnectionOption func(*ConnectionOptions)

ConnectionOption is a functional option for NewConnection.

func WithRequiredServerExtKeyUsage

func WithRequiredServerExtKeyUsage(oid asn1.ObjectIdentifier) ConnectionOption

WithRequiredServerExtKeyUsage requires the server certificate to have the specified custom extended key usage.

The check is performed in addition to the regular certificate verification.

type ConnectionOptions

type ConnectionOptions struct {
	RequiredServerExtKeyUsage asn1.ObjectIdentifier
}

ConnectionOptions configures the connection.

type Credentials

type Credentials interface {
	credentials.PerRPCCredentials

	UnaryInterceptor() grpc.UnaryServerInterceptor
	StreamInterceptor() grpc.StreamServerInterceptor
}

Credentials describes an authorization method.

func NewTokenCredentials

func NewTokenCredentials(token string) (creds Credentials)

NewTokenCredentials initializes ClientCredentials with the token.

func NewTokenCredentialsDynamic

func NewTokenCredentialsDynamic(f TokenGetterFunc) (creds Credentials)

NewTokenCredentialsDynamic initializes ClientCredentials with the dynamic token token.

type TokenCredentials

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

TokenCredentials implements credentials.PerRPCCredentials. It uses a basic token lookup to authenticate users.

func (*TokenCredentials) GetRequestMetadata

func (b *TokenCredentials) GetRequestMetadata(ctx context.Context, s ...string) (map[string]string, error)

GetRequestMetadata sets the value for the "token" key.

func (*TokenCredentials) RequireTransportSecurity

func (b *TokenCredentials) RequireTransportSecurity() bool

RequireTransportSecurity is set to true in order to encrypt the communication.

func (*TokenCredentials) StreamInterceptor added in v1.13.0

func (b *TokenCredentials) StreamInterceptor() grpc.StreamServerInterceptor

StreamInterceptor sets the StreamServerInterceptor for the server and enforces basic authentication.

For now, it rejects any API, as we don't have any streaming APIs in trustd component. This is to prevent accidentally allowing unauthenticated access to streaming APIs in the future without realizing it.

func (*TokenCredentials) UnaryInterceptor

func (b *TokenCredentials) UnaryInterceptor() grpc.UnaryServerInterceptor

UnaryInterceptor sets the UnaryServerInterceptor for the server and enforces basic authentication.

type TokenGetterFunc

type TokenGetterFunc func(context.Context) (string, error)

TokenGetterFunc is the function to dynamically retrieve the token.

Jump to

Keyboard shortcuts

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