bufconnect

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Overview

Package bufconnect provides buf-specific Connect functionality.

Index

Constants

View Source
const (
	// AuthenticationHeader is the standard OAuth header used for authenticating
	// a user. Ignore the misnomer.
	AuthenticationHeader = "Authorization"
	// AuthenticationTokenPrefix is the standard OAuth token prefix.
	// We use it for familiarity.
	AuthenticationTokenPrefix = "Bearer "
	// CliVersionHeaderName is the name of the header carrying the buf CLI version.
	CliVersionHeaderName = "buf-version"
	// DefaultRemote is the default remote if none can be inferred from a module name.
	DefaultRemote = "buf.build"
)

Variables

This section is empty.

Functions

func NewAuthorizationInterceptorProvider

func NewAuthorizationInterceptorProvider(container app.EnvContainer) func(string) connect.UnaryInterceptorFunc

NewAuthorizationInterceptorProvider returns a new provider function which, when invoked, returns an interceptor which will look up an auth token by address and set it into the request header. This is used for registry providers where the token is looked up by the client address at the time of client construction (i.e. for clients where a user is already authenticated and the token is stored in .netrc)

Note that the interceptor returned from this provider is always applied LAST in the series of interceptors added to a client.

func NewAuthorizationInterceptorProviderWithToken

func NewAuthorizationInterceptorProviderWithToken(token string) func(string) connect.UnaryInterceptorFunc

NewAuthorizationInterceptorProviderWithToken returns a new provider function which, when invoked, returns an interceptor which sets the provided auth token into the request header. This is used for registry providers where the token is known at provider creation (i.e. when logging in and explicitly pasting a token into stdin

Note that the interceptor returned from this provider is always applied LAST in the series of interceptors added to a client.

func NewSetCLIVersionInterceptor

func NewSetCLIVersionInterceptor(version string) connect.UnaryInterceptorFunc

NewSetCLIVersionInterceptor returns a new Connect Interceptor that sets the Buf CLI version into all request headers

Types

type ErrAuth added in v1.10.0

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

ErrAuth wraps the error returned in the auth provider to add additional context.

func AsAuthError added in v1.10.0

func AsAuthError(err error) (*ErrAuth, bool)

AsAuthError uses errors.As to unwrap any error and look for an *ErrAuth.

func (*ErrAuth) Error added in v1.10.0

func (e *ErrAuth) Error() string

Error implements the error interface and returns the error message.

func (*ErrAuth) TokenEnvKey added in v1.10.0

func (e *ErrAuth) TokenEnvKey() string

TokenEnvKey returns the environment variable used, if any, for authentication.

func (*ErrAuth) Unwrap added in v1.10.0

func (e *ErrAuth) Unwrap() error

Unwrap returns the underlying error.

Jump to

Keyboard shortcuts

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