Machine to Machine OAuth Server

4 minutes read
Edit on GitHub

Machine to Machine OAuth Server (M2M OAuth Server) is used to generate API tokens to access the plgd services by other services. These tokens are acquired via client credentials flow with client assertion type JWT or secret in the case of service.

SOURCE Copy
Copied
        docker pull ghcr.io/plgd-dev/hub/m2m-oauth-server:latest
    

A configuration template is available on m2m-oauth-server/config.yaml.

PropertyTypeDescriptionDefault
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"

HTTP API of the OAuth Server service as defined here

PropertyTypeDescriptionDefault
apis.http.addressstringListen to specification <host>:<port> for http client connection."0.0.0.0:9100"
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
apis.http.tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
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

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

Signer configuration to access tokens of OAuth provider for services.

PropertyTypeDescriptionDefault
oauthSigner.privateKeyFilestringFile path to a private ECDSA key in PEM format required for access token signing.""
oauthSigner.domainstringDomain address <host>:<port> for OAuth APIs.""
oauthSigner.ownerClaimstringClaim name in the token which contains the owner of the token."sub"
oauthSigner.deviceIDClaimstringClaim name in the token which contains the deviceID of the token.""
oauthSigner.clients[].idstringclient id which is used by oauth clients."test"
oauthSigner.clients[].secretstringclient secret which is used by oauth clients. Can be empty when .jwtPrivateKey is set""
oauthSigner.clients[].accessTokenLifetimestringvalidity of generated access token lifetime. 0s means forever."0s"
oauthSigner.clients[].allowedGrantTypes[]stringgrant types which are allowed for the client. Only 'client_credentials' is supported.[ "client_credentials" ]
oauthSigner.clients[].allowedAudiences[]stringaudiences which are allowed for the client.[]
oauthSigner.clients[].allowedScopes[]stringscopes which are allowed for the client.[]
oauthSigner.clients[].insertTokenClaimsobjectclaims which are added to the token.{}
oauthSigner.clients[].jwtPrivateKey.enabledboolallow JWT private key for clientfalse
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].authoritystringaddress to OAuth authority""
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].maxIdleConnsintIt controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit.16
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].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
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].maxIdleConnsPerHostintIf non-zero, controls the maximum idle (keep-alive) connections to keep per-host. If zero, DefaultMaxIdleConnsPerHost is used.16
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].idleConnTimeoutstringThe maximum amount of time an idle (keep-alive) connection will remain idle before closing itself. Zero means no limit.30s
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].timeoutstringA time limit for requests made by this Client. A Timeout of zero means no timeout.10s
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].tls.caPool[]stringFile paths to the root certificates in PEM format. The file may contain multiple certificates.[]
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].tls.keyFilestringFile path to private key in PEM format.""
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].tls.certFilestringFile path to certificate in PEM format.""
oauthSigner.clients[].jwtPrivateKey.authorization.endpoints[].tls.useSystemCAPoolboolIf true, use system certification pool.false
Note

Note that the string type related to time (i.e. timeout, idleConnTimeout, expirationTime) is decimal numbers, each with optional fraction and a unit suffix, such as “300ms”, “1.5h” or “2h45m”. Valid time units are “ns”, “us”, “ms”, “s”, “m”, “h”.

Jul 4, 2024

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