joinserver

package
v3.28.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package joinserver provides a LoRaWAN-compliant Join Server implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteApplicationActivationSettings added in v3.10.0

func DeleteApplicationActivationSettings(ctx context.Context, r ApplicationActivationSettingRegistry, appID *ttnpb.ApplicationIdentifiers) error

DeleteApplicationActivationSettings deletes application activation settings from r.

func DeleteDevice

func DeleteDevice(ctx context.Context, r DeviceRegistry, appID *ttnpb.ApplicationIdentifiers, devID string) error

DeleteDevice deletes device identified by joinEUI, devEUI from r.

func DeleteKeys

func DeleteKeys(ctx context.Context, r KeyRegistry, joinEUI, devEUI types.EUI64, id []byte) error

DeleteKeys deletes session keys identified by devEUI, id pair from r.

Types

type ApplicationAccessAuthorizer added in v3.14.0

type ApplicationAccessAuthorizer interface {
	Authorizer
	RequireApplication(ctx context.Context, id *ttnpb.ApplicationIdentifiers, required ...ttnpb.Right) error
}

ApplicationAccessAuthorizer authorizes the request context for application access.

type ApplicationActivationSettingRegistry added in v3.10.0

ApplicationActivationSettingRegistry is a registry, containing application activation settings.

type Authorizer added in v3.14.0

type Authorizer interface {
	// RequireAuthorized returns an error if the given context is not authorized.
	RequireAuthorized(ctx context.Context) error
}

Authorizer checks whether the request context is authorized.

func ApplicationRightsAuthorizer added in v3.14.0

func ApplicationRightsAuthorizer(reqCtx context.Context) Authorizer

ApplicationRightsAuthorizer returns an Authorizer that authenticates the caller by application rights.

func ClusterAuthorizer added in v3.14.0

func ClusterAuthorizer(reqCtx context.Context) Authorizer

ClusterAuthorizer returns an Authorizer that authenticates clusters.

type Config

type Config struct {
	Devices                       DeviceRegistry                       `name:"-"`
	Keys                          KeyRegistry                          `name:"-"`
	ApplicationActivationSettings ApplicationActivationSettingRegistry `name:"-"`
	JoinEUIPrefixes               []types.EUI64Prefix                  `name:"join-eui-prefix" description:"JoinEUI prefixes handled by this Join Server"`
	DefaultJoinEUI                types.EUI64                          `name:"default-join-eui" description:"Default JoinEUI for this Join Server"`
	DeviceKEKLabel                string                               `name:"device-kek-label" description:"Label of KEK used to encrypt device keys at rest"`
	DevNonceLimit                 int                                  `name:"dev-nonce-limit" description:"Amount of DevNonces stored per device"`
	SessionKeyLimit               int                                  `name:"session-key-limit" description:"Amount of session keys stored per device"`
}

Config represents the JoinServer configuration.

type DeviceRegistry

type DeviceRegistry interface {
	GetByEUI(ctx context.Context, joinEUI types.EUI64, devEUI types.EUI64, paths []string) (*ttnpb.ContextualEndDevice, error)
	GetByID(ctx context.Context, appID *ttnpb.ApplicationIdentifiers, devID string, paths []string) (*ttnpb.EndDevice, error)
	SetByEUI(ctx context.Context, joinEUI types.EUI64, devEUI types.EUI64, paths []string, f func(context.Context, *ttnpb.EndDevice) (*ttnpb.EndDevice, []string, error)) (*ttnpb.ContextualEndDevice, error)
	SetByID(ctx context.Context, appID *ttnpb.ApplicationIdentifiers, devID string, paths []string, f func(*ttnpb.EndDevice) (*ttnpb.EndDevice, []string, error)) (*ttnpb.EndDevice, error)
	RangeByID(ctx context.Context, paths []string, f func(context.Context, *ttnpb.EndDeviceIdentifiers, *ttnpb.EndDevice) bool) error
	// BatchDelete deletes a batch of end devices.
	BatchDelete(
		ctx context.Context,
		appIDs *ttnpb.ApplicationIdentifiers,
		deviceIDs []string,
	) ([]*ttnpb.EndDeviceIdentifiers, error)
}

DeviceRegistry is a registry, containing devices.

type EndDeviceHomeNetwork added in v3.15.2

type EndDeviceHomeNetwork struct {
	NetID                *types.NetID
	TenantID             string
	NSID                 *types.EUI64
	NetworkServerAddress string
}

EndDeviceHomeNetwork contains information about the end device's home network.

type EntityAuthorizer added in v3.16.0

type EntityAuthorizer interface {
	// RequireEntityContext returns an error if the given entity context is not authorized.
	RequireEntityContext(ctx context.Context) error
}

EntityAuthorizer authorizes the request context with the entity context.

type ExternalAuthorizer added in v3.15.2

type ExternalAuthorizer interface {
	Authorizer
	// RequireAddress returns an error if the given address is not authorized in the context.
	RequireAddress(ctx context.Context, addr string) error
	// RequireNetID returns an error if the given NetID is not authorized in the context.
	RequireNetID(ctx context.Context, netID types.NetID) error
	// RequireASID returns an error if the given AS-ID is not authorized in the context.
	RequireASID(ctx context.Context, id string) error
}

ExternalAuthorizer authorizes the request context by the identity that the origin presents.

var InteropAuthorizer ExternalAuthorizer = new(interop.Authorizer)

InteropAuthorizer authorizes the caller by proof of identity used with LoRaWAN Backend Interfaces.

type JoinServer

type JoinServer struct {
	ttnpb.UnimplementedJsServer

	*component.Component
	// contains filtered or unexported fields
}

JoinServer implements the Join Server component.

The Join Server exposes the NsJs, AsJs, AppJs and DeviceRegistry services.

func New

func New(c *component.Component, conf *Config) (*JoinServer, error)

New returns new *JoinServer.

func (*JoinServer) Context

func (js *JoinServer) Context() context.Context

Context returns the context of the Join Server.

func (*JoinServer) GetAppSKey

func (js *JoinServer) GetAppSKey(ctx context.Context, req *ttnpb.SessionKeyRequest, authorizer Authorizer) (*ttnpb.AppSKeyResponse, error)

GetAppSKey returns the requested application session key.

func (*JoinServer) GetHomeNetwork added in v3.15.2

func (js *JoinServer) GetHomeNetwork(ctx context.Context, joinEUI, devEUI types.EUI64, authorizer Authorizer) (*EndDeviceHomeNetwork, error)

GetHomeNetwork returns the home network of an end device.

func (*JoinServer) GetNwkSKeys

func (js *JoinServer) GetNwkSKeys(ctx context.Context, req *ttnpb.SessionKeyRequest, authorizer Authorizer) (*ttnpb.NwkSKeysResponse, error)

GetNwkSKeys returns the requested network session keys.

func (*JoinServer) HandleJoin

func (js *JoinServer) HandleJoin(ctx context.Context, req *ttnpb.JoinRequest, authorizer Authorizer) (res *ttnpb.JoinResponse, err error)

HandleJoin handles the given join-request.

func (*JoinServer) RegisterHandlers

func (js *JoinServer) RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)

RegisterHandlers registers gRPC handlers.

func (*JoinServer) RegisterInterop

func (js *JoinServer) RegisterInterop(srv *interop.Server)

RegisterInterop registers the NS-JS and AS-JS interop services.

func (*JoinServer) RegisterServices

func (js *JoinServer) RegisterServices(s *grpc.Server)

RegisterServices registers services provided by js at s.

func (*JoinServer) Roles

func (js *JoinServer) Roles() []ttnpb.ClusterRole

Roles of the gRPC service.

type KeyRegistry

type KeyRegistry interface {
	GetByID(ctx context.Context, joinEUI, devEUI types.EUI64, id []byte, paths []string) (*ttnpb.SessionKeys, error)
	SetByID(ctx context.Context, joinEUI, devEUI types.EUI64, id []byte, paths []string, f func(*ttnpb.SessionKeys) (*ttnpb.SessionKeys, []string, error)) (*ttnpb.SessionKeys, error)
	Delete(ctx context.Context, joinEUI, devEUI types.EUI64) error
	BatchDelete(ctx context.Context, devIDs []*ttnpb.EndDeviceIdentifiers) error
}

KeyRegistry is a registry, containing session keys.

type RegistryCleaner added in v3.16.0

type RegistryCleaner struct {
	DevRegistry         DeviceRegistry
	AppAsRegistry       ApplicationActivationSettingRegistry
	LocalDeviceSet      map[string]struct{}
	LocalApplicationSet map[string]struct{}
}

RegistryCleaner is a service responsible for cleanup of the device registry.

func (*RegistryCleaner) CleanData added in v3.16.0

func (cleaner *RegistryCleaner) CleanData(ctx context.Context, isDeviceSet, isApplicationSet map[string]struct{}) error

CleanData cleans registry device and application data.

func (*RegistryCleaner) DeleteApplicationAndDeviceData added in v3.16.0

func (cleaner *RegistryCleaner) DeleteApplicationAndDeviceData(ctx context.Context, deviceList, applicationList []string) error

DeleteApplicationAndDeviceData deletes registry application data of all devices in the device id list.

func (*RegistryCleaner) RangeToLocalSet added in v3.16.0

func (cleaner *RegistryCleaner) RangeToLocalSet(ctx context.Context) error

RangeToLocalSet returns a set of devices that have data in the registry.

Directories

Path Synopsis
Package redis provides Redis implementations of interfaces used by joinserver.
Package redis provides Redis implementations of interfaces used by joinserver.

Jump to

Keyboard shortcuts

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