Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Configuration

Farshid Tavakolizadeh edited this page Jun 11, 2021 · 11 revisions

LinkSmart Thing Directory is configured using a JSON configuration file, path to which is provided via --conf flag. By default, the server looks for a configuration file at: conf/thing-directory.json

All configuration fields (except for arrays of objects) can be overridden using environment variables. Below are few examples:

  • TD_HTTP_BINDPORT=8081
  • TD_STORAGE_TYPE=leveldb
  • TD_VALIDATION_JSONSCHEMAS="conf/wot_td_schema.json,conf/wot_discovery_schema.json"
  • ❌ TD_AUTH_AUTHORIZATION_RULES --> setting array of objects is not possible with env var

For additional usage guides on passing configuration arguments using environment variables, see envconfig.

Configuration File

A sample configuration file is available at thing-directory.json.

where

  • description is a human-readable description for the TD

  • validation

    • jsonSchemas is an array of paths to JSON Schema files used for input validation; see validation
  • storage is the configuration of the storage backend

    • type is the type of the backend (i.e. currently only leveldb)
    • dsn is the Data Source Name for storage backend (for leveldb, the dsn may be relative or absolute directory path)
  • dnssd is the configuration of DNS-SD

    • publish is the configuration of the DNS-SD publisher. The service type is _wot._tcp, subtype is _directory.
      • enabled is a boolean flag to enable the DNS-SD service registration
      • instance is the instance portion of the Service Instance Name
      • domain is the domain portion of the Service Instance Name
      • interfaces is to limit the networking interfaces on which the service is announced. When empty, the service is announced to all interfaces.
  • serviceCatalog is the optional server information for a Service Catalog

    • discover is a flag to enable automatic discovery of the Service Catalog
    • endpoint is the URL of the Service Catalog HTTP API
    • ttl is the TTL for the service registration
  • http is the configuration of the HTTP server

    • publicEndpoint is the fully qualified domain name (FQDN)
    • bindAddr is the HTTP bind address which the server listens on
    • bindPort is the HTTP bind port
      • auth is the Authentication configuration
        • enabled is a boolean flag to enable the authentication
        • provider is the name of a supported auth provider (i.e. currently only keycloak)
        • providerURL is the URL of the auth provider endpoint
        • clientID is the ID of the client in the authentication provider
        • basicEnabled is a boolean flag to enable Basic Authentication. This allows the server to exchange credentials (provided as basic auth header) with the authentication provider for a token on behalf of the user. Note: This should be enabled only if the requests are served over TLS. More info.
        • authorization - optional, see authorization configuration

Validation

By default, the inputs are not validated. Validation can be done using one or more JSON Schema documents. To enable validation, the path to locally available JSON Schema files should be set in server configuration.

E.g. download WoT TD and Discovery validation files:

curl https://raw.githubusercontent.com/w3c/wot-thing-description/REC1.0/validation/td-json-schema-validation.json --create-dirs -o conf/wot_td_schema.json
curl https://raw.githubusercontent.com/w3c/wot-discovery/main/validation/td-discovery-extensions-json-schema.json --create-dirs -o conf/wot_discovery_schema.json

Pass the file paths to server either in configuration file:

  "validation": {
    "jsonSchemas": ["conf/wot_td_schema.json", "conf/wot_discovery_schema.json"]
  },

or as an environment variable:

TD_VALIDATION_JSONSCHEMAS="conf/wot_td_schema.json,conf/wot_discovery_schema.json"
Clone this wiki locally