7.7 KiB
client
import "github.com/effective-security/trustyca/api/client"
Package client creates the gRPC clients the services and tools of trustyca dial other listeners with.
A Factory holds the named service clients of the configuration (`clients`): each one has the TLS certificate it presents and the URLs of the listeners it dials, by listener name, so that one process can call with several identities, such as the `ca` client of the WFE and the `aia` client of the AIA (DESIGN.md section 2.2). A
factory, err := client.NewFactory(cfg.Clients)
if err != nil {
return err
}
Index
- Constants
- type Config
- type Factory
- type HTTPStatusClient
- func NewHTTPStatusClient(client retriable.HTTPClient) *HTTPStatusClient
- func (c *HTTPStatusClient) AuthURL(ctx context.Context, email string) (*pb.AuthProvidersResponse, error)
- func (c *HTTPStatusClient) Status(ctx context.Context) (*pb.ServerStatusResponse, error)
- func (c *HTTPStatusClient) Version(ctx context.Context) (*pb.ServerVersion, error)
- type Option
Constants
const (
// UserAgentWfe is the user agent of the clients of the service
UserAgentWfe = "trustyca"
// ClientNameAIA is the client the AIA service forwards OCSP requests to
// the backend with: the trustyca-aia identity
ClientNameAIA = "aia"
// ClientNameCA is the client the CA service of a process without the
// backend service forwards the calls of its tenants with: the identity
// of the WFE (trustyca-peer)
ClientNameCA = "ca"
)
type Config
Config specifies a named service client: the certificate it presents and the URLs of the listeners it dials. A process holds one client per identity it calls other listeners with (DESIGN.md section 2.2).
type Config struct {
// Name is the name the services select the client by, unique in the
// `clients` list
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// ClientTLS describes the TLS certificate the client presents and the
// roots it trusts
ClientTLS gserver.TLSInfo `json:"client_tls,omitempty" yaml:"client_tls,omitempty"`
// ServerURL specifies the URL of each listener the client dials, by
// listener name (wfe, backend)
ServerURL map[string]string `json:"server_url,omitempty" yaml:"server_url,omitempty"`
// DialTimeout is the timeout for failing to establish a connection.
DialTimeout time.Duration `json:"dial_timeout,omitempty" yaml:"dial_timeout,omitempty"`
// DialKeepAliveTime is the time after which client pings the server to see if
// transport is alive.
DialKeepAliveTime time.Duration `json:"dial_keep_alive_time,omitempty" yaml:"dial_keep_alive_time,omitempty"`
// DialKeepAliveTimeout is the time that the client waits for a response for the
// keep-alive probe. If the response is not received in this time, the connection is closed.
DialKeepAliveTimeout time.Duration `json:"dial_keep_alive_timeout,omitempty" yaml:"dial_keep_alive_timeout,omitempty"`
// EnableCNA enables Cloud Native Auth
EnableCNA bool `json:"enable_cna,omitempty" yaml:"enable_cna,omitempty"`
}
type Factory
Factory creates the gRPC clients of the services: every method dials the listener named server with the TLS identity and settings of the named client, and returns the closer of the connection
type Factory interface {
// StatusClient returns Status client
StatusClient(clientName, server string, ops ...Option) (pb.StatusServer, io.Closer, error)
// OrgsClient returns Orgs client
OrgsClient(clientName, server string, ops ...Option) (pb.OrgsServer, io.Closer, error)
// CAClient returns CA client
CAClient(clientName, server string, ops ...Option) (pb.CAServer, io.Closer, error)
// CISClient returns CIS client
CISClient(clientName, server string, ops ...Option) (pb.CISServer, io.Closer, error)
// BackendClient returns the client of the signing plane (privpb.Backend)
BackendClient(clientName, server string, ops ...Option) (privpb.BackendServer, io.Closer, error)
}
func NewFactory
func NewFactory(cfgs []Config, ops ...Option) (Factory, error)
NewFactory returns the Factory of the named clients; a client without a name, or two clients with the same name, is an error
type HTTPStatusClient
HTTPStatusClient provides Status over legacy HTTP
type HTTPStatusClient struct {
// contains filtered or unexported fields
}
func NewHTTPStatusClient
func NewHTTPStatusClient(client retriable.HTTPClient) *HTTPStatusClient
NewHTTPStatusClient returns legacy HTTP client
func (*HTTPStatusClient) AuthURL
func (c *HTTPStatusClient) AuthURL(ctx context.Context, email string) (*pb.AuthProvidersResponse, error)
AuthURL returns AuthURLResponse
func (*HTTPStatusClient) Status
func (c *HTTPStatusClient) Status(ctx context.Context) (*pb.ServerStatusResponse, error)
Status returns ServerStatusResponse
func (*HTTPStatusClient) Version
func (c *HTTPStatusClient) Version(ctx context.Context) (*pb.ServerVersion, error)
Version returns ServerVersion
type Option
Option configures how we set up the client
type Option struct {
// contains filtered or unexported fields
}
func WithAgent
func WithAgent(agent string) Option
WithAgent option to provide client Agent
func WithCallerIdentity
func WithCallerIdentity(callerIdentity credentials.CallerIdentity) Option
WithCallerIdentity option to provide CallerIdentity
func WithTLS
func WithTLS(tlsCfg *tls.Config) Option
WithTLS option to provide tls.Config
Generated by gomarkdoc