Documentation
¶
Index ¶
- func NewConnection(address string, creds credentials.PerRPCCredentials, ...) (conn *grpc.ClientConn, err error)
- type Credentials
- type TokenCredentials
- func (b *TokenCredentials) GetRequestMetadata(ctx context.Context, s ...string) (map[string]string, error)
- func (b *TokenCredentials) RequireTransportSecurity() bool
- func (b *TokenCredentials) StreamInterceptor() grpc.StreamServerInterceptor
- func (b *TokenCredentials) UnaryInterceptor() grpc.UnaryServerInterceptor
- type TokenGetterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewConnection ¶
func NewConnection(address string, creds credentials.PerRPCCredentials, acceptedCAs []*x509.PEMEncodedCertificate) (conn *grpc.ClientConn, err error)
NewConnection initializes a grpc.ClientConn configured for basic authentication.
Types ¶
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.