service

package
v2.24.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DPSTag = "dps"

Variables

This section is empty.

Functions

func HTTPConfigToProto

func HTTPConfigToProto(cfg pkgHttpClient.Config) (*pb.HttpConfig, error)

func New

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

New creates server.

func NewMessageWithCode

func NewMessageWithCode(code codes.Code) *pool.Message

func NewStore

func NewStore(ctx context.Context, config mongodb.Config, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*mongodb.Store, func(), error)

func TLSConfigToProto

func TLSConfigToProto(cfg pkgCertManagerClient.Config) (*pb.TlsConfig, error)

Types

type APIsConfig

type APIsConfig struct {
	COAP COAPConfig `yaml:"coap" json:"coap"`
	HTTP HTTPConfig `yaml:"http" json:"http"`
}

func (*APIsConfig) Validate

func (c *APIsConfig) Validate() error

type AttestationMechanism

type AttestationMechanism struct {
	X509 X509 `yaml:"x509" json:"x509"`
}

func (*AttestationMechanism) ToProto

type AuthHandler

type AuthHandler interface {
	// tls.Config overrides
	VerifyPeerCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error
	VerifyConnection(tls.ConnectionState) error

	GetChainsCache() *cache.Cache[uint64, [][]*x509.Certificate]
}

type AuthorizationConfig

type AuthorizationConfig struct {
	OwnerClaim    string                      `yaml:"ownerClaim" json:"ownerClaim"`
	DeviceIDClaim string                      `yaml:"deviceIDClaim" json:"deviceIdClaim"`
	Provider      AuthorizationProviderConfig `yaml:"provider" json:"provider"`
}

func (*AuthorizationConfig) ToProto

type AuthorizationProviderConfig

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

func (*AuthorizationProviderConfig) ToProto

type COAPConfig

type COAPConfig struct {
	pkgCoapService.Config `yaml:",inline" json:",inline"`
}

func (*COAPConfig) Validate

func (c *COAPConfig) Validate() error

type CSR

type CSR struct {
	Encoding csr.CertificateEncoding `json:"encoding"`
	Data     string                  `json:"data"`
}

type ClientsConfig

type ClientsConfig struct {
	Storage                StorageConfig                        `yaml:"storage" json:"storage"`
	OpenTelemetryCollector pkgHttp.OpenTelemetryCollectorConfig `yaml:"openTelemetryCollector" json:"openTelemetryCollector"`
}

func (*ClientsConfig) Validate

func (c *ClientsConfig) Validate() error

type CoapConfig

type CoapConfig struct {
	Address string `yaml:"address" json:"address"`
}

func (*CoapConfig) Validate

func (c *CoapConfig) Validate() error

type CoapGatewayConfig

type CoapGatewayConfig struct {
	COAP         CoapConfig `yaml:"coap" json:"coap"`
	ProviderName string     `yaml:"providerName" json:"providerName"`
}

func (*CoapGatewayConfig) Validate

func (c *CoapGatewayConfig) Validate() error

type Config

type Config struct {
	Log              LogConfig        `yaml:"log" json:"log"`
	APIs             APIsConfig       `yaml:"apis" json:"apis"`
	Clients          ClientsConfig    `yaml:"clients" json:"clients"`
	EnrollmentGroups EnrollmentGroups `yaml:"enrollmentGroups" json:"enrollmentGroups"`
}

Config represents application configuration

func (Config) String

func (c Config) String() string

String returns string representation of Config

func (*Config) Validate

func (c *Config) Validate() error

type CredentialsRequest

type CredentialsRequest struct {
	CSR             CSR            `json:"csr"`
	SelectedGateway cloud.Endpoint `json:"selectedGateway"`
}

type DefaultAuthHandler

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

func MakeDefaultAuthHandler

func MakeDefaultAuthHandler(config Config, enrollmentGroupsCache *EnrollmentGroupsCache) DefaultAuthHandler

func (DefaultAuthHandler) GetChainsCache

func (d DefaultAuthHandler) GetChainsCache() *cache.Cache[uint64, [][]*x509.Certificate]

func (DefaultAuthHandler) VerifyConnection

func (d DefaultAuthHandler) VerifyConnection(tls.ConnectionState) error

func (DefaultAuthHandler) VerifyPeerCertificate

func (d DefaultAuthHandler) VerifyPeerCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error

type EnrollmentGroup

type EnrollmentGroup struct {
	*pb.EnrollmentGroup
	AttestationMechanismX509CertificateChain []*x509.Certificate
	// contains filtered or unexported fields
}

type EnrollmentGroupConfig

type EnrollmentGroupConfig struct {
	ID                   string               `yaml:"id" json:"id"`
	Owner                string               `yaml:"owner" json:"owner"`
	AttestationMechanism AttestationMechanism `yaml:"attestationMechanism" json:"attestationMechanism"`
	Hub                  HubConfig            `yaml:"hub" json:"hub"`
	Hubs                 []HubConfig          `yaml:"hubs" json:"hubs"`
	PreSharedKeyFile     urischeme.URIScheme  `yaml:"preSharedKeyFile" json:"preSharedKeyFile"`
	Name                 string               `yaml:"name" json:"name"`
}

func (*EnrollmentGroupConfig) String

func (e *EnrollmentGroupConfig) String() string

func (*EnrollmentGroupConfig) ToProto

func (e *EnrollmentGroupConfig) ToProto() (*pb.EnrollmentGroup, []*pb.Hub, error)

func (*EnrollmentGroupConfig) Validate

func (e *EnrollmentGroupConfig) Validate() error

type EnrollmentGroups

type EnrollmentGroups []EnrollmentGroupConfig

func (EnrollmentGroups) FindByID

type EnrollmentGroupsCache

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

func NewEnrollmentGroupsCache

func NewEnrollmentGroupsCache(ctx context.Context, expiration time.Duration, store *mongodb.Store, logger log.Logger) *EnrollmentGroupsCache

func (*EnrollmentGroupsCache) CheckExpirations

func (c *EnrollmentGroupsCache) CheckExpirations(t time.Time)

func (*EnrollmentGroupsCache) Close

func (c *EnrollmentGroupsCache) Close()

func (*EnrollmentGroupsCache) GetEnrollmentGroup

func (c *EnrollmentGroupsCache) GetEnrollmentGroup(ctx context.Context, chains [][]*x509.Certificate) (*EnrollmentGroup, bool, error)

func (*EnrollmentGroupsCache) GetEnrollmentGroupsByIssuerNames

func (c *EnrollmentGroupsCache) GetEnrollmentGroupsByIssuerNames(ctx context.Context, issuerNames []string, onEnrollmentGroup func(g *EnrollmentGroup) bool) error

type GrpcClientConfig

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

func (*GrpcClientConfig) ToProto

func (c *GrpcClientConfig) ToProto() (*pb.GrpcClientConfig, error)

func (*GrpcClientConfig) Validate

func (c *GrpcClientConfig) Validate() error

type HTTPConfig

type HTTPConfig struct {
	http.Config `yaml:",inline"`
	Enabled     bool `yaml:"enabled" json:"enabled"`
}

func (*HTTPConfig) Validate

func (c *HTTPConfig) Validate() error

type HubConfig

type HubConfig struct {
	ID                   string              `yaml:"id" json:"id"`
	HubID                string              `yaml:"hubID" json:"hubId"`
	CoapGateway          string              `yaml:"coapGateway" json:"coapGateway"`
	Gateways             []string            `yaml:"gateways" json:"gateways"`
	CertificateAuthority GrpcClientConfig    `yaml:"certificateAuthority" json:"certificateAuthority"`
	Authorization        AuthorizationConfig `yaml:"authorization" json:"authorization"`
	Name                 string              `yaml:"name" json:"name"`
}

func (*HubConfig) ToProto

func (c *HubConfig) ToProto(owner string) (*pb.Hub, error)

func (*HubConfig) Validate

func (c *HubConfig) Validate(owner string) error

type LinkedHub

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

func NewLinkedHub

func NewLinkedHub(ctx context.Context, expiration time.Duration, cfg *pb.Hub, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) (*LinkedHub, error)

func (*LinkedHub) Close

func (h *LinkedHub) Close()

func (*LinkedHub) GetToken

func (h *LinkedHub) GetToken(ctx context.Context, key string, urlValues map[string]string, requiredClaims map[string]interface{}) (*oauth2.Token, error)

func (*LinkedHub) GetTokenFromOAuth

func (h *LinkedHub) GetTokenFromOAuth(ctx context.Context, urlValues map[string]string, requiredClaims map[string]interface{}) (*oauth2.Token, error)

func (*LinkedHub) Invalidate

func (h *LinkedHub) Invalidate()

func (*LinkedHub) IsExpired

func (h *LinkedHub) IsExpired(now time.Time) bool

func (*LinkedHub) Refresh

func (h *LinkedHub) Refresh(now time.Time)

func (*LinkedHub) SignIdentityCertificate

func (h *LinkedHub) SignIdentityCertificate(ctx context.Context, in *pbCA.SignCertificateRequest, opts ...grpc.CallOption) (*pbCA.SignCertificateResponse, error)

type LinkedHubCache

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

func NewLinkedHubCache

func NewLinkedHubCache(ctx context.Context, expiration time.Duration, store *mongodb.Store, fileWatcher *fsnotify.Watcher, logger log.Logger, tracerProvider trace.TracerProvider) *LinkedHubCache

func (*LinkedHubCache) Close

func (c *LinkedHubCache) Close()

func (*LinkedHubCache) GetHubs

func (c *LinkedHubCache) GetHubs(ctx context.Context, eg *EnrollmentGroup) ([]*LinkedHub, error)

type LogConfig

type LogConfig = log.Config

LogConfig represents application configuration

type Option

type Option func(o Options) Options

func WithAuthHandler

func WithAuthHandler(authHandler AuthHandler) Option

Override default authorization handler

func WithRequestHandler

func WithRequestHandler(requestHandler RequestHandler) Option

Override default request handler

type Options

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

type ProvisionCloudConfigurationRequest

type ProvisionCloudConfigurationRequest struct {
	DeviceID        string         `json:"di"`
	SelectedGateway cloud.Endpoint `json:"selectedGateway"`
}

type RequestHandle

type RequestHandle struct{}

func (RequestHandle) DefaultHandler

func (RequestHandle) DefaultHandler(_ context.Context, req *mux.Message, _ *Session, _ []*LinkedHub, _ *EnrollmentGroup) (*pool.Message, error)

func (RequestHandle) ProcessACLs

func (RequestHandle) ProcessACLs(_ context.Context, req *mux.Message, session *Session, linkedHubs []*LinkedHub, _ *EnrollmentGroup) (*pool.Message, error)

func (RequestHandle) ProcessCloudConfiguration

func (RequestHandle) ProcessCloudConfiguration(ctx context.Context, req *mux.Message, session *Session, linkedHubs []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)

func (RequestHandle) ProcessCredentials

func (RequestHandle) ProcessCredentials(ctx context.Context, req *mux.Message, session *Session, linkedHubs []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)

func (RequestHandle) ProcessOwnership

func (RequestHandle) ProcessOwnership(_ context.Context, req *mux.Message, session *Session, _ []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)

func (RequestHandle) ProcessPlgdTime

func (RequestHandle) ProcessPlgdTime(_ context.Context, req *mux.Message, session *Session, _ []*LinkedHub, _ *EnrollmentGroup) (*pool.Message, error)

type RequestHandler

type RequestHandler interface {
	DefaultHandler(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
	ProcessOwnership(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
	ProcessCredentials(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
	ProcessACLs(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
	ProcessCloudConfiguration(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
	ProcessPlgdTime(ctx context.Context, req *mux.Message, session *Session, linkedHub []*LinkedHub, group *EnrollmentGroup) (*pool.Message, error)
}

type Service

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

type Session

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

Session represents a setup of connection

func (*Session) Close

func (s *Session) Close() error

Close closes coap connection

func (*Session) Context

func (s *Session) Context() context.Context

func (*Session) Debugf

func (s *Session) Debugf(fmt string, args ...interface{})

func (*Session) DeviceID

func (s *Session) DeviceID() string

func (*Session) Errorf

func (s *Session) Errorf(fmt string, args ...interface{})

func (*Session) OnClose

func (s *Session) OnClose()

OnClose action when coap connection was closed.

func (*Session) RemoteAddr

func (s *Session) RemoteAddr() net.Addr

func (*Session) SetDeviceID

func (s *Session) SetDeviceID(deviceID string)

func (*Session) String

func (s *Session) String() string

func (*Session) WriteMessage

func (s *Session) WriteMessage(m *pool.Message) error

type StorageConfig

type StorageConfig struct {
	// expiration time of cached DB records
	CacheExpiration time.Duration  `yaml:"cacheExpiration" json:"cacheExpiration"`
	MongoDB         mongodb.Config `yaml:"mongoDB" json:"mongoDb"` //nolint:tagliatelle
}

func (*StorageConfig) Validate

func (c *StorageConfig) Validate() error

type X509

type X509 struct {
	CertificateChain          urischeme.URIScheme `yaml:"certificateChain" json:"certificateChain"`
	LeadCertificateName       string              `yaml:"leadCertificateName" json:"leadCertificateName"`
	ExpiredCertificateEnabled bool                `yaml:"expiredCertificateEnabled" json:"expiredCertificateEnabled"`
}

func (*X509) ToProto

func (c *X509) ToProto() *pb.X509Configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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