Skip to content

Commit

Permalink
Add seeds and update certificate generation and document development …
Browse files Browse the repository at this point in the history
…setup (#47)
  • Loading branch information
mpfeil authored Sep 11, 2023
1 parent 72f655f commit 23d5476
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 16 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ See [config/default.json](config/default.json). You should at least configure th
}
}

### Development

To get up and running for development run the following steps:

- Run `./scripts/setup_certs.sh` for generating development certificates.
- Set the MQTT URL in row 23 in `./seeds/devices.json`
- Run `docker-compose up -d`

## Environment variables

Its possible to supply your configuration json through the `NODE_CONFIG` environment variable. It is also possible to configure through custom environment variables:
Expand All @@ -47,6 +55,5 @@ Stable versions should be tagged using `yarn version` and `git push --follow-tag

[openSenseMap API]: https://github.com/sensebox/openSenseMap-API
[node-config]: https://github.com/lorenwest/node-config
[mongoDB Connection String]: https://docs.mongodb.com/v3.2/reference/connection-string/
[osem-protos]: https://github.com/sensebox/osem-protos/blob/master/mqtt/mqtt.proto
[Github Container Registry]: https://github.com/sensebox/mqtt-osem-integration/pkgs/container/mqtt-osem-integration
4 changes: 2 additions & 2 deletions certstrap-notes
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ certstrap init --common-name "openSenseMapCA"
## Create certificate requests for the server and client

```bash
certstrap request-cert --key out/openSenseMapCA.key --common-name "mqtt-integration server" --domain mqtt-integration,localhost
certstrap request-cert --key out/openSenseMapCA.key --common-name "mqtt-integration client" --domain api,localhost
certstrap request-cert --common-name "mqtt-integration server"
certstrap request-cert --common-name "mqtt-integration client"
```

## Sign the certificate requests
Expand Down
11 changes: 8 additions & 3 deletions config/default.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
{
"openSenseMap-API-models": {
"db": {
"mongo_uri": "mongodb://localhost:27017/osem-mqtt"
}
},
"mqtt_client": {
"num_retries": 5,
"retry_after_minutes": 10
},
"grpc": {
"port": 3925,
"certificates": {
"ca_cert": "",
"server_cert": "",
"server_key": ""
"ca_cert": "./out/openSenseMapCA.crt",
"server_cert": "./out/mqtt-integration_server.crt",
"server_key": "./out/mqtt-integration_server.key"
}
},
"mqtts_test_client:": {
Expand Down
10 changes: 10 additions & 0 deletions scripts/setup_certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

echo "Initialize Certificate Authority called openSenseMapCA"
certstrap init --common-name "openSenseMapCA"

echo "Request a certificate called mqtt-integration_server"
certstrap request-cert --common-name "mqtt-integration server"

echo "Sign the requested certificated with the openSenseMapCA"
certstrap sign --CA "openSenseMapCA" mqtt-integration_server
69 changes: 59 additions & 10 deletions seeds/devices.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
[
{
"name": "Joe Smith",
"email": "[email protected]",
"age": 40,
"admin": false
},
{
"name": "Jen Ford",
"email": "[email protected]",
"age": 45,
"admin": true
"_id": "64ff1076088f2df36ed4d8ab",
"createdAt" : "2023-06-23T10:50:48.246Z",
"updatedAt" : "2023-09-11T11:35:12.838Z",
"name" : "MQTT Test Device",
"currentLocation" : {
"timestamp" : "2023-06-23T10:50:48.241Z",
"coordinates" : [
7.2123,
51.4823
],
"type" : "Point"
},
"exposure" : "outdoor",
"integrations" : {
"mqtt" : {
"enabled" : true,
"messageFormat" : "json",
"connectionOptions" : "",
"decodeOptions" : "",
"topic" : "test",
"url" : ""
},
"ttn" : {
"decodeOptions" : [ ],
"profile" : "sensebox/home",
"dev_id" : "43369",
"app_id" : "15649"
}
},
"access_token" : "c343eb5329cf80b1fc26b4943e52ab42d4ef699e17a0499ff2e1a69f3d7ab624",
"useAuth" : true,
"sensors" : [
{
"_id": "64ff1076088f2df36ed4d8ac",
"title": "Temperatur",
"unit": "°C",
"sensorType": "HDC1080",
"icon": "osem-thermometer"
},
{
"_id": "64ff1076088f2df36ed4d8ad",
"title": "rel. Luftfeuchte",
"unit": "%",
"sensorType": "HDC1080",
"icon": "osem-humidity"
}
],
"model" : "homeV2Wifi",
"grouptag" : [],
"locations" : [
{
"timestamp" : "2023-06-23T10:50:48.241Z",
"coordinates" : [
7.2123,
51.4823
],
"type" : "Point"
}
]
}
]

0 comments on commit 23d5476

Please sign in to comment.