service

package
v2.21.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: Apache-2.0 Imports: 86 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateResourceContentToObserver added in v2.3.6

func CreateResourceContentToObserver(client *session, resourceChanged *events.ResourceChanged, observe uint32, token coapMessage.Token) (*pool.Message, error)

func DefaultCodeToLevel added in v2.2.4

func DefaultCodeToLevel(code codes.Code, logger log.Logger) func(args ...interface{})

DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.

func MakeGetConfigForClient

func MakeGetConfigForClient(tlsCfg *tls.Config, identityPropertiesRequired bool) tls.Config

func New

func New(ctx context.Context, config Config, fileWatcher *fsnotify.Watcher, logger log.Logger) (*service.Service, error)

New creates server.

func PublishResourceLinks(ctx context.Context, raClient raService.ResourceAggregateClient, links schema.ResourceLinks, deviceID string, ttl int32, connectionID string, sequence uint64) ([]*commands.Resource, error)

func ValidUntil

func ValidUntil(expiry time.Time) (validUntil int64, ok bool)

ValidUntil returns time until expiration. No expiration is denoted by expiry = 0 for which 0 is returned. When expired, ok is false.

func WantToLog added in v2.2.4

func WantToLog(code codes.Code, logger log.Logger) bool

Types

type APIsConfig

type APIsConfig struct {
	COAP COAPConfigMarshalerUnmarshaler `yaml:"coap" json:"coap"`
}

func (*APIsConfig) Validate

func (c *APIsConfig) Validate() error

type AuthorizationConfig

type AuthorizationConfig struct {
	DeviceIDClaim string            `yaml:"deviceIDClaim" json:"deviceIdClaim"`
	OwnerClaim    string            `yaml:"ownerClaim" json:"ownerClaim"`
	Providers     []ProvidersConfig `yaml:"providers" json:"providers"`
	Authority     validator.Config  `yaml:",inline" json:",inline"`
}

func (*AuthorizationConfig) Validate

func (c *AuthorizationConfig) Validate() error

type COAPConfig

type COAPConfig struct {
	coapService.Config         `yaml:",inline" json:",inline"`
	ExternalAddress            string              `yaml:"externalAddress" json:"externalAddress"`
	Authorization              AuthorizationConfig `yaml:"authorization" json:"authorization"`
	OwnerCacheExpiration       time.Duration       `yaml:"ownerCacheExpiration" json:"ownerCacheExpiration"`
	SubscriptionBufferSize     int                 `yaml:"subscriptionBufferSize" json:"subscriptionBufferSize"`
	RequireBatchObserveEnabled bool                `yaml:"requireBatchObserveEnabled" json:"requireBatchObserveEnabled"`

	InjectedCOAPConfig InjectedCOAPConfig `yaml:"-" json:"-"`
}

func (*COAPConfig) Validate

func (c *COAPConfig) Validate() error

type COAPConfigMarshalerUnmarshaler added in v2.7.14

type COAPConfigMarshalerUnmarshaler struct {
	COAPConfig `yaml:",inline"`
}

func (COAPConfigMarshalerUnmarshaler) MarshalYAML added in v2.7.14

func (c COAPConfigMarshalerUnmarshaler) MarshalYAML() (interface{}, error)

func (*COAPConfigMarshalerUnmarshaler) UnmarshalYAML added in v2.7.14

func (c *COAPConfigMarshalerUnmarshaler) UnmarshalYAML(value *yaml.Node) error

func (*COAPConfigMarshalerUnmarshaler) Validate added in v2.7.14

func (c *COAPConfigMarshalerUnmarshaler) Validate() error

type ClientsConfig

type ClientsConfig struct {
	Eventbus               EventBusConfig          `yaml:"eventBus" json:"eventBus"`
	OpenTelemetryCollector otelClient.Config       `yaml:"openTelemetryCollector" json:"openTelemetryCollector"`
	IdentityStore          IdentityStoreConfig     `yaml:"identityStore" json:"identityStore"`
	ResourceDirectory      GrpcServerConfig        `yaml:"resourceDirectory" json:"resourceDirectory"`
	CertificateAuthority   GrpcServerConfig        `yaml:"certificateAuthority" json:"certificateAuthority"`
	ResourceAggregate      ResourceAggregateConfig `yaml:"resourceAggregate" json:"resourceAggregate"`
}

func (*ClientsConfig) Validate

func (c *ClientsConfig) Validate() error

type CoapRefreshTokenReq

type CoapRefreshTokenReq struct {
	DeviceID              string `json:"di"`
	UserID                string `json:"uid"`
	RefreshToken          string `json:"refreshtoken"`
	AuthorizationProvider string `json:"authprovider"`
}

type CoapRefreshTokenResp

type CoapRefreshTokenResp struct {
	AccessToken  string `json:"accesstoken"`
	RefreshToken string `json:"refreshtoken"`
	ExpiresIn    int64  `json:"expiresin"`
}

type CoapSignInReq

type CoapSignInReq struct {
	DeviceID    string `json:"di"`
	UserID      string `json:"uid"`
	AccessToken string `json:"accesstoken"`
	Login       bool   `json:"login"`
}

type CoapSignInResp

type CoapSignInResp struct {
	ExpiresIn int64 `json:"expiresin"`
}

type CoapSignUpRequest

type CoapSignUpRequest struct {
	DeviceID                string `json:"di"`
	AuthorizationCode       string `json:"accesstoken"`
	AuthorizationCodeLegacy string `json:"authcode"`
	AuthorizationProvider   string `json:"authprovider"`
}

type CoapSignUpResponse

type CoapSignUpResponse struct {
	AccessToken  string `json:"accesstoken"`
	UserID       string `json:"uid"`
	RefreshToken string `json:"refreshtoken"`
	RedirectURI  string `json:"redirecturi"`
	ExpiresIn    int64  `json:"expiresin"`
}

type Config

type Config struct {
	Log              LogConfig              `yaml:"log" json:"log"`
	APIs             APIsConfig             `yaml:"apis" json:"apis"`
	Clients          ClientsConfig          `yaml:"clients" json:"clients"`
	DeviceTwin       DeviceTwinConfig       `yaml:"deviceTwin" json:"deviceTwin"`
	TaskQueue        queue.Config           `yaml:"taskQueue" json:"taskQueue"`
	ServiceHeartbeat ServiceHeartbeatConfig `yaml:"serviceHeartbeat" json:"serviceHeartbeat"`
}

Config represent application configuration

func (Config) String

func (c Config) String() string

String return string representation of Config

func (*Config) Validate

func (c *Config) Validate() error

type DeviceTwinConfig added in v2.10.0

type DeviceTwinConfig struct {
	MaxETagsCountInRequest uint32 `yaml:"maxETagsCountInRequest" json:"maxETagsCountInRequest"`
	UseETags               bool   `yaml:"useETags" json:"useETags"`
}

type EventBusConfig

type EventBusConfig struct {
	NATS natsClient.Config `yaml:"nats" json:"nats"`
}

func (*EventBusConfig) Validate

func (c *EventBusConfig) Validate() error

type ExchangeCache added in v2.6.2

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

Thread safe cache for Exchange operation.

Exchange takes authorization code and returns access token. Cache keeps track of the last (code, oauth2.token) pair and if the authorization code for next Exchange call is the same as the cached value then the call is skipped and the stored token is returned instead.

func NewExchangeCache

func NewExchangeCache() *ExchangeCache

func (*ExchangeCache) Clear added in v2.6.2

func (e *ExchangeCache) Clear()

Clear stored value.

func (*ExchangeCache) Execute added in v2.6.2

func (e *ExchangeCache) Execute(ctx context.Context, provider *oauth2.PlgdProvider, authorizationCode string) (*oauth2.Token, error)

Execute Exchange or returned cached value.

type GrpcServerConfig

type GrpcServerConfig struct {
	Connection client.Config `yaml:"grpc" json:"grpc"`
}

func (*GrpcServerConfig) Validate

func (c *GrpcServerConfig) Validate() error

type IdentityStoreConfig

type IdentityStoreConfig struct {
	Connection client.Config `yaml:"grpc" json:"grpc"`
}

func (*IdentityStoreConfig) Validate

func (c *IdentityStoreConfig) Validate() error

type InjectedCOAPConfig added in v2.7.14

type InjectedCOAPConfig struct {
	TLSConfig InjectedTLSConfig `yaml:"tls" json:"tls"`
}

func (*InjectedCOAPConfig) Validate added in v2.7.14

func (c *InjectedCOAPConfig) Validate() error

type InjectedTLSConfig added in v2.7.14

type InjectedTLSConfig struct {
	IdentityPropertiesRequired bool `yaml:"identityPropertiesRequired" json:"identityPropertiesRequired"`
}

type Interceptor

type Interceptor = func(ctx context.Context, code codes.Code, path string) (context.Context, error)

type LogConfig

type LogConfig = log.Config

type ProvidersConfig

type ProvidersConfig struct {
	Name          string `yaml:"name" json:"name"`
	oauth2.Config `yaml:",inline"`
}

func (*ProvidersConfig) Validate

func (c *ProvidersConfig) Validate(firstAuthority string, providerNames map[string]bool) error

type RefreshCache added in v2.6.2

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

Thread safe cache for Refresh operation.

Refresh takes a refreshToken and returns access token. Cache keeps track of the last (refreshToken, oauth2.token) pair and if the authorization code for next Refresh call is the same as the cache value then the call is skipped and the stored token is returned instead.

func NewRefreshCache

func NewRefreshCache() *RefreshCache

func (*RefreshCache) Clear added in v2.6.2

func (r *RefreshCache) Clear()

func (*RefreshCache) Execute added in v2.6.2

func (r *RefreshCache) Execute(ctx context.Context, providers map[string]*oauth2.PlgdProvider, queue *queue.Queue, refreshToken string, logger log.Logger) (*oauth2.Token, error)

type ResourceAggregateConfig

type ResourceAggregateConfig struct {
	Connection client.Config `yaml:"grpc" json:"grpc"`
}

func (*ResourceAggregateConfig) Validate

func (c *ResourceAggregateConfig) Validate() error

type Service

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

Service is a configuration of coap-gateway

func (*Service) ValidateToken

func (s *Service) ValidateToken(ctx context.Context, token string) (pkgJwt.Claims, error)

func (*Service) VerifyAndResolveDeviceID added in v2.16.3

func (s *Service) VerifyAndResolveDeviceID(tlsDeviceID, paramDeviceID string, claim pkgJwt.Claims) (string, error)

type ServiceHeartbeatConfig added in v2.12.0

type ServiceHeartbeatConfig struct {
	TimeToLive time.Duration `yaml:"timeToLive" json:"timeToLive"`
}

func (*ServiceHeartbeatConfig) Validate added in v2.12.0

func (c *ServiceHeartbeatConfig) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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