Device Provisioning Service

9 minutes read
Edit on GitHub

The Device Provisioning Service provides API to provision device to the plgd/hub.

Before you use the image you need to setup K8s access to private registry.

SOURCE Copy
Copied
        docker pull ghcr.io/plgd-dev/hub/device-provisioning-service:latest
    

A configuration template is available on config.yaml.

PropertyTypeDescriptionDefault
log.dumpBodyboolSet to true if you would like to dump raw messages.false
log.levelstringLogging enabled from level."info"
log.encodingstringLogging format. The supported values are: "json", "console""json"
log.stacktrace.enabledboolLog stacktrace.false
log.stacktrace.levelstringStacktrace from level."warn"
log.encoderConfig.timeEncoderstringTime format for logs. The supported values are: "rfc3339nano", "rfc3339"."rfc3339nano"

CoAP API as specified in the workflow.

PropertyTypeDescriptionDefault
apis.coap.addressstringListening specification <host>:<port> for coap client connection."0.0.0.0:15684"
apis.coap.protocols[]stringProtocol for coap connection. The supported values are: "tcp", "udp" .["tcp"]
apis.coap.maxMessageSizeintMax message size which can be sent/received via coap. i.e. 256*1024 = 262144 bytes.262144
apis.coap.messagePoolSizeintDefines the maximum preallocated messages in the pool for parse/create coap messages.1000
apis.coap.inactivityMonitor.timeoutstringTime limit to close inactive connection.20s
apis.coap.blockwiseTransfer.enabledboolIf true, enable blockwise transfer of coap messages.true
apis.coap.blockwiseTransfer.blockSizeintSize of blockwise transfer block.1024
apis.coap.tls.keyFilestringFile path to private key in PEM format.""
apis.coap.tls.certFilestringFile path to certificate in PEM format.""

The plgd device provisioning service REST API is defined by swagger.

PropertyTypeDescriptionDefault
apis.http.enabledboolEnable HTTP API.false
apis.http.addressstringListening specification <host>:<port> for http client connection."0.0.0.0:9100"
apis.http.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
apis.http.tls.keyFilestringFile path to private key in PEM format.""
apis.http.tls.certFilestringFile path to certificate in PEM format.""
apis.http.tls.clientCertificateRequiredboolIf true, require client certificate.true
apis.http.authorization.authoritystringAuthority is the address of the token-issuing authentication server. Services will use this URI to find and retrieve the public key that can be used to validate the token’s signature.""
apis.http.authorization.ownerClaimstringClaim used to identify owner of the device."sub"
apis.http.authorization.audiencestringIdentifier of the API configured in your OAuth provider.""
apis.http.authorization.endpoints[].authoritystringAuthority is the address of the token-issuing authentication server. Services will use this URI to find and retrieve the public key that can be used to validate the token’s signature.""
apis.http.authorization.endpoints[].http.maxIdleConnsintIt controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit.16
apis.http.authorization.endpoints[].http.maxConnsPerHostintIt optionally limits the total number of connections per host, including connections in the dialing, active, and idle states. On limit violation, dials will block. Zero means no limit.32
apis.http.authorization.endpoints[].http.maxIdleConnsPerHostintIf non-zero, controls the maximum idle (keep-alive) connections to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.16
apis.http.authorization.endpoints[].http.idleConnTimeoutstringThe maximum amount of time an idle (keep-alive) connection will remain idle before closing itself. Zero means no limit.30s
apis.http.authorization.endpoints[].http.timeoutstringA time limit for requests made by this Client. A Timeout of zero means no timeout.10s
apis.http.authorization.endpoints[].http.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
apis.http.authorization.endpoints[].http.tls.keyFilestringFile path to private key in PEM format.""
apis.http.authorization.endpoints[].http.tls.certFilestringFile path to certificate in PEM format.""
apis.http.authorization.endpoints[].http.tls.useSystemCAPoolboolIf true, use system certification pool.false
apis.http.authorization.tokenTrustVerification.cacheExpirationstringDuration for which a valid token is kept in a runtime cache before re-verification is required.30s
apis.http.readTimeoutstringThe maximum duration for reading the entire request, including the body by the server. A zero or negative value means there will be no timeout.8s
apis.http.readHeaderTimeoutstringThe amount of time allowed to read request headers by the server. If readHeaderTimeout is zero, the value of readTimeout is used. If both are zero, there is no timeout.4s
apis.http.writeTimeoutstringThe maximum duration before the server times out writing of the response. A zero or negative value means there will be no timeout.16s
apis.http.idleTimeoutstringThe maximum amount of time the server waits for the next request when keep-alives are enabled. If idleTimeout is zero, the value of readTimeout is used. If both are zero, there is no timeout.30s

The plgd open telemetry exporter configuration.

PropertyTypeDescriptionDefault
clients.openTelemetryCollector.grpc.enabledboolEnable OTLP gRPC exporterfalse
clients.openTelemetryCollector.grpc.addressstringThe gRPC collector to which the exporter is going to send data""
clients.openTelemetryCollector.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
clients.openTelemetryCollector.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
clients.openTelemetryCollector.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.true
clients.openTelemetryCollector.grpc.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
clients.openTelemetryCollector.grpc.tls.keyFilestringFile path to private key in PEM format.""
clients.openTelemetryCollector.grpc.tls.certFilestringFile path to certificate in PEM format.""
clients.openTelemetryCollector.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false

The plgd device provisioning service uses MongoDB database.

PropertyTypeDescriptionDefault
clients.storage.cacheExpirationstringExpiration time of cached records from database."10m"
clients.storage.mongoDB.uristringURI to mongo database."mongodb://localhost:27017"
clients.storage.mongoDB.databasestringName of database"deviceProvisioning"
clients.storage.mongoDB.maxPoolSizeintLimits number of connections.16
clients.storage.mongoDB.maxConnIdleTimestringClose connection when idle time reach the value.4m0s
clients.storage.mongoDB.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
clients.storage.mongoDB.tls.keyFilestringFile path to private key in PEM format.""
clients.storage.mongoDB.tls.certFilestringFile path to certificate in PEM format.""
clients.storage.mongoDB.tls.useSystemCAPoolboolIf true, use system certification pool.false
clients.storage.mongoDB.bulkWrite.timeoutstringA time limit for write bulk to mongodb. A Timeout of zero means no timeout.1m0s
clients.storage.mongoDB.bulkWrite.throttleTimestringThe amount of time to wait until a record is written to mongodb. Any records collected during the throttle time will also be written. A throttle time of zero writes immediately. If recordLimit is reached, all records are written immediately.500ms
clients.storage.mongoDB.bulkWrite.documentLimituint16The maximum number of documents to cache before an immediate write.1000

Enrollment group entry configuration.

PropertyTypeDescriptionDefault
enrollmentGroups.[].idstringUnique enrollment group id in GUID format""
enrollmentGroups.[].ownerstringOwner of a newly provisioned device""
enrollmentGroups.[].preSharedKeyFilestringFile path to the pre-shared key that will be stored on the device for the owner. It must be empty or have 16 characters in the preSharedKeyFile.""
enrollmentGroups.[].attestationMechanism.x509.certificateChainstringFile path to certificate chain in PEM format.""
enrollmentGroups.[].attestationMechanism.x509.expiredCertificateEnabledboolAccept device connections with an expired certificate.false
enrollmentGroups.[].HubobjectDefines configuration of the plgd hub where the device connects after it's successfully provisioned.{}
enrollmentGroups.[].Hubs[]objectDefines configuration of the multiple plgd hubs where the device connects after it's successfully provisioned.[]

Defines configuration of the plgd hub where the device connects after it’s successfully provisioned.

PropertyTypeDescriptionDefault
enrollmentGroups.[].hub.caPoolstringFile path to the root certificate in PEM format. Multiple certificates in a single file are supported.""
enrollmentGroups.[].hub.hubIDstringUniqhe id of the plgd hub instance.""
enrollmentGroups.[].hub.coapGatewaystringplgd hub CoAP gateway endpoint where the devices should connect to after successful provisioning.Format <IP:PORT>.""
enrollmentGroups.[].hub.gateways[]stringplgd hub gateway multiple endpoints where the devices should connect to after successful provisioning. If coapGateway is also set, it is prepended before .gateways. Format <SCHEME>://<IP:PORT>, for example coaps+tcp://plgd.cloud:1234[]
enrollmentGroups.[].hub.certificateAuthority.grpc.addressstringplgd hub Certificate Authority endpoint used to sign device identity CSRs. Format <IP:PORT>.""
enrollmentGroups.[].hub.certificateAuthority.grpc.keepAlive.timestringAfter a duration of this time if the client doesn't see any activity it pings the server to see if the transport is still alive.10s
enrollmentGroups.[].hub.certificateAuthority.grpc.keepAlive.timeoutstringAfter having pinged for keepalive check, the client waits for a duration of Timeout and if no activity is seen even after that the connection is closed.20s
enrollmentGroups.[].hub.certificateAuthority.grpc.keepAlive.permitWithoutStreamboolIf true, client sends keepalive pings even with no active RPCs. If false, when there are no active RPCs, Time and Timeout will be ignored and no keepalive pings will be sent.true
enrollmentGroups.[].hub.certificateAuthority.grpc.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
enrollmentGroups.[].hub.certificateAuthority.grpc.tls.keyFilestringFile path to private key in PEM format.""
enrollmentGroups.[].hub.certificateAuthority.grpc.tls.certFilestringFile path to certificate in PEM format.""
enrollmentGroups.[].hub.certificateAuthority.grpc.tls.useSystemCAPoolboolIf true, use system certification pool.false

OAuth2.0 Client is used to obtain JWT with ownerClaim an deviceIDClaim via the client credentials flow. The JWT will be is used directly during the SignUp operation.

PropertyTypeDescriptionDefault
enrollmentGroups.[].hub.authorization.ownerClaimstringClaim used to identify owner of the device. If configured, your OAuth2.0 server has to set the owner id to the token as configured. OwnerClaim with sub is not supported. Custom owner claim needs to be configured also on the plgd hub instance. If used with the plgd mock OAuth Server, value https://plgd.dev/owner has to be set. **Required.**""
enrollmentGroups.[].hub.authorization.deviceIDClaimstringClaim used to make JWT tokens device specific. If configured, your OAuth2.0 server has to set the device id to the token as configured. If used with the plgd mock OAuth Server, value https://plgd.dev/deviceId has to be set.""
enrollmentGroups.[].hub.authorization.provider.namestringProvider name which is registered also on the instance of the plgd hub where the device connects after it's successfully provisioned. The grant type for this provider must to be set to ClientCredentials.""
enrollmentGroups.[].hub.authorization.provider.authoritystringAuthority is the address of the token-issuing authentication server. Services will use this URI to find token endpoint.""
enrollmentGroups.[].hub.authorization.provider.clientIDstringOAuth Client ID.""
enrollmentGroups.[].hub.authorization.provider.clientSecretFilestringFile path to client secret required to request an access token.""
enrollmentGroups.[].hub.authorization.provider.audiencestringAudience of OAuth provider.""
enrollmentGroups.[].hub.authorization.provider.http.maxIdleConnsintMaximum number of idle (keep-alive) connections across all hosts. Zero means no limit.16
enrollmentGroups.[].hub.authorization.provider.http.maxConnsPerHostintLimit the total number of connections per host, including connections in the dialing, active, and idle states. On limit violation, dials will be blocked. Zero means no limit.32
enrollmentGroups.[].hub.authorization.provider.http.maxIdleConnsPerHostintIf non-zero, controls the maximum idle (keep-alive) connections to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.16
enrollmentGroups.[].hub.authorization.provider.http.idleConnTimeoutstringThe maximum time an idle (keep-alive) connection will remain idle before closing itself. Zero means no limit.30s
enrollmentGroups.[].hub.authorization.provider.http.timeoutstringA time limit for requests made by this Client. A Timeout of zero means no timeout.10s
enrollmentGroups.[].hub.authorization.provider.http.tls.caPoolstringFile path to the root certificate in PEM format which might contain multiple certificates in a single file.""
enrollmentGroups.[].hub.authorization.provider.http.tls.keyFilestringFile path to private key in PEM format.""
enrollmentGroups.[].hub.authorization.provider.http.tls.certFilestringFile path to certificate in PEM format.""
enrollmentGroups.[].hub.authorization.provider.http.tls.useSystemCAPoolboolIf true, use system certification pool.false
Tip

You might have one client, but multiple APIs registered in the OAuth2.0 Server. What you might want to prevent is to be able to contact all the APIs of your system with one token. This audience allows you to request the token for a specific API. If you configure it to myplgdc2c.api in the Auth0, you have to set it here if you want to also validate it.

May 18, 2023

Get started

plgd makes it simpler to build a successful IoT initiative – to create a proof of concept, evaluate, optimize, and scale.

Get Started Illustration Get Started Illustration