Documentation ¶
Index ¶
- Constants
- Variables
- func ClientPropagation(client *conf.Client, opt *Option, tokenMgr TokenManager, logger log.Logger) middleware.Middleware
- func FromTrustedContext(ctx context.Context) (bool, bool)
- func NewDiscovery(services *conf.Services) (registry.Discovery, error)
- func NewGrpcConn(clientName ClientName, serviceName string, services *conf.Services, ...) (grpcx.ClientConnInterface, func())
- func NewHttpClient(clientName ClientName, serviceName string, services *conf.Services, ...) (*http.Client, func())
- func NewTrustedContext(ctx context.Context, trust ...bool) context.Context
- func ServerPropagation(opt *Option, validator TrustedContextValidator, logger log.Logger) middleware.Middleware
- func UnaryClientInterceptor(ms []middleware.Middleware, timeout time.Duration, filters []selector.Filter) grpc.UnaryClientInterceptor
- type ClientName
- type ClientPropagator
- type ClientTrustedContextValidator
- type Header
- type HeaderCarrier
- type InMemoryTokenManager
- type Option
- type Propagator
- type SaasPropagator
- type TokenManager
- type Transport
- type TrustedContextValidator
- type UserPropagator
Constants ¶
const ( InternalKeyPrefix = "internal-" TenantKey = InternalKeyPrefix + "tenant" TenantInfoKey = InternalKeyPrefix + "tenant-info" TenantFilterKey = InternalKeyPrefix + "tenant-data-filter" TenantAutoSetKey = InternalKeyPrefix + "tenant-data-autoset" UserKey = InternalKeyPrefix + "user" ClientKey = InternalKeyPrefix + "client" )
Variables ¶
var DefaultProviderSet = wire.NewSet( NewDefaultOption, NewInMemoryTokenManager, wire.Bind(new(TokenManager), new(*InMemoryTokenManager)), NewClientTrustedContextValidator, NewDiscovery, )
Functions ¶
func ClientPropagation ¶
func ClientPropagation(client *conf.Client, opt *Option, tokenMgr TokenManager, logger log.Logger) middleware.Middleware
func NewGrpcConn ¶
func NewGrpcConn( clientName ClientName, serviceName string, services *conf.Services, dis registry.Discovery, opt *Option, tokenMgr TokenManager, logger log.Logger, opts ...grpc.ClientOption, ) (grpcx.ClientConnInterface, func())
NewGrpcConn create new grpc client from name
func NewHttpClient ¶
func NewHttpClient( clientName ClientName, serviceName string, services *conf.Services, dis registry.Discovery, opt *Option, tokenMgr TokenManager, logger log.Logger, opts ...http.ClientOption, ) (*http.Client, func())
NewHttpClient create new http client from name
func NewTrustedContext ¶
NewTrustedContext create a trusted (or not) context without propaganda to other services
func ServerPropagation ¶
func ServerPropagation(opt *Option, validator TrustedContextValidator, logger log.Logger) middleware.Middleware
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(ms []middleware.Middleware, timeout time.Duration, filters []selector.Filter) grpc.UnaryClientInterceptor
UnaryClientInterceptor
Types ¶
type ClientName ¶
type ClientName string
type ClientPropagator ¶
type ClientPropagator struct {
// contains filtered or unexported fields
}
func NewClientPropagator ¶
func NewClientPropagator(extractOnly bool, logger log.Logger) *ClientPropagator
func (*ClientPropagator) Fields ¶
func (u *ClientPropagator) Fields() []string
type ClientTrustedContextValidator ¶
type ClientTrustedContextValidator struct { }
type HeaderCarrier ¶
func (HeaderCarrier) Get ¶
func (h HeaderCarrier) Get(key string) string
func (HeaderCarrier) HasKey ¶
func (h HeaderCarrier) HasKey(key string) bool
func (HeaderCarrier) Set ¶
func (h HeaderCarrier) Set(key, value string)
type InMemoryTokenManager ¶
type InMemoryTokenManager struct {
// contains filtered or unexported fields
}
InMemoryTokenManager TODO should use centralize authorization server to get jwt
func NewInMemoryTokenManager ¶
func NewInMemoryTokenManager(tokenizer jwt.Tokenizer, logger log.Logger) *InMemoryTokenManager
func (*InMemoryTokenManager) GetOrGenerateToken ¶
type Option ¶
type Option struct { Propagators []Propagator BypassToken bool Insecure bool }
func NewDefaultOption ¶
func NewOption ¶
func NewOption(bypassToken bool, propagators ...Propagator) *Option
func (*Option) WithInsecure ¶
type Propagator ¶
type Propagator interface { Extract(ctx context.Context, carrier Header) (context.Context, error) Inject(ctx context.Context, carrier Header) error Fields() []string }
Propagator propagates cross-cutting concerns as key-value text pairs within a carrier that travels in-band across process boundaries to keep same state across services
type SaasPropagator ¶
type SaasPropagator struct {
// contains filtered or unexported fields
}
func NewSaasPropagator ¶
func NewSaasPropagator(logger log.Logger) *SaasPropagator
func (*SaasPropagator) Fields ¶
func (s *SaasPropagator) Fields() []string
type TokenManager ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is a gRPC transport.
func (*Transport) ReplyHeader ¶
ReplyHeader returns the reply header.
func (*Transport) RequestHeader ¶
RequestHeader returns the request header.
func (*Transport) SelectFilters ¶
SelectFilters returns the client select filters.
type TrustedContextValidator ¶
TrustedContextValidator validate whether the communication is behind authed gateway or server to server communication
func NewClientTrustedContextValidator ¶
func NewClientTrustedContextValidator() TrustedContextValidator
type UserPropagator ¶
type UserPropagator struct {
// contains filtered or unexported fields
}
func NewUserPropagator ¶
func NewUserPropagator(logger log.Logger) *UserPropagator
func (*UserPropagator) Fields ¶
func (u *UserPropagator) Fields() []string