Documentation ¶
Overview ¶
Package bufconnect provides buf-specific Connect functionality.
Index ¶
- Constants
- func NewAuthorizationInterceptorProvider(container app.EnvContainer) func(string) connect.UnaryInterceptorFunc
- func NewAuthorizationInterceptorProviderWithToken(token string) func(string) connect.UnaryInterceptorFunc
- func NewSetCLIVersionInterceptor(version string) connect.UnaryInterceptorFunc
- type ErrAuth
Constants ¶
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
AsAuthError uses errors.As to unwrap any error and look for an *ErrAuth.
func (*ErrAuth) Error ¶ added in v1.10.0
Error implements the error interface and returns the error message.
func (*ErrAuth) TokenEnvKey ¶ added in v1.10.0
TokenEnvKey returns the environment variable used, if any, for authentication.