From 0432b2aa03debd4611e10c34b02a0593f4da33d3 Mon Sep 17 00:00:00 2001 From: Mirko Teodorovic Date: Sat, 27 Feb 2021 01:01:48 +0100 Subject: [PATCH] NOISSUE - Fix default values for port and x509 provision (#1367) * remove owner id Signed-off-by: Mirko Teodorovic * fix default port and certs settings Signed-off-by: Mirko Teodorovic * small typo fix Signed-off-by: Mirko Teodorovic * refactor env vars Signed-off-by: Mirko Teodorovic * revert users Signed-off-by: Mirko Teodorovic --- .env | 5 +- cmd/provision/main.go | 4 +- docker/addons/provision/docker-compose.yml | 2 - provision/README.md | 55 ++++++++++------------ provision/config.go | 2 +- provision/configs/config.toml | 4 +- 6 files changed, 30 insertions(+), 42 deletions(-) diff --git a/.env b/.env index 822a44f7..8162f629 100644 --- a/.env +++ b/.env @@ -111,14 +111,13 @@ MF_PROVISION_HTTP_PORT=8190 MF_PROVISION_ENV_CLIENTS_TLS=false MF_PROVISION_SERVER_CERT= MF_PROVISION_SERVER_KEY= -MF_PROVISION_MQTT_URL=tcp://localhost -MF_PROVISION_USERS_LOCATION=http://localhost:8180 +MF_PROVISION_USERS_LOCATION=http://users:8180 MF_PROVISION_THINGS_LOCATION=http://things:8182 MF_PROVISION_USER= MF_PROVISION_PASS= MF_PROVISION_API_KEY= MF_PROVISION_CERTS_SVC_URL=http://certs:8204 -MF_PROVISION_X509_PROVISIONING=true +MF_PROVISION_X509_PROVISIONING=false MF_PROVISION_BS_SVC_URL=http://bootstrap:8202/things MF_PROVISION_BS_SVC_WHITELIST_URL=http://bootstrap:8202/things/state MF_PROVISION_BS_CONFIG_PROVISIONING=true diff --git a/cmd/provision/main.go b/cmd/provision/main.go index 0e3c5057..c98cc588 100644 --- a/cmd/provision/main.go +++ b/cmd/provision/main.go @@ -27,8 +27,7 @@ const ( defServerKey = "" defThingsLocation = "http://localhost" defUsersLocation = "http://localhost" - defMQTTURL = "localhost:1883" - defHTTPPort = "8091" + defHTTPPort = "8190" defMfUser = "test@example.com" defMfPass = "test" defMfAPIKey = "" @@ -48,7 +47,6 @@ const ( envTLS = "MF_PROVISION_ENV_CLIENTS_TLS" envServerCert = "MF_PROVISION_SERVER_CERT" envServerKey = "MF_PROVISION_SERVER_KEY" - envMQTTURL = "MF_PROVISION_MQTT_URL" envUsersLocation = "MF_PROVISION_USERS_LOCATION" envThingsLocation = "MF_PROVISION_THINGS_LOCATION" envMfUser = "MF_PROVISION_USER" diff --git a/docker/addons/provision/docker-compose.yml b/docker/addons/provision/docker-compose.yml index 0e4a830d..663be12a 100644 --- a/docker/addons/provision/docker-compose.yml +++ b/docker/addons/provision/docker-compose.yml @@ -25,11 +25,9 @@ services: MF_PROVISION_LOG_LEVEL: ${MF_PROVISION_LOG_LEVEL} MF_PROVISION_HTTP_PORT: ${MF_PROVISION_HTTP_PORT} MF_PROVISION_CONFIG_FILE: ${MF_PROVISION_CONFIG_FILE} - MF_PROVISION_LOG_LEVEL: ${MF_PROVISION_LOG_LEVEL} MF_PROVISION_ENV_CLIENTS_TLS: ${MF_PROVISION_ENV_CLIENTS_TLS} MF_PROVISION_SERVER_CERT: ${MF_PROVISION_SERVER_CERT} MF_PROVISION_SERVER_KEY: ${MF_PROVISION_SERVER_KEY} - MF_PROVISION_MQTT_URL: ${MF_PROVISION_MQTT_URL} MF_PROVISION_USERS_LOCATION: ${MF_PROVISION_USERS_LOCATION} MF_PROVISION_THINGS_LOCATION: ${MF_PROVISION_THINGS_LOCATION} MF_PROVISION_USER: ${MF_PROVISION_USER} diff --git a/provision/README.md b/provision/README.md index b9da3ad5..9622a35f 100644 --- a/provision/README.md +++ b/provision/README.md @@ -17,35 +17,28 @@ The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values. -| Variable | Description | Default | -| ----------------------------------- | ------------------------------------------------- | -------------------------------- | -| MF_PROVISION_USER | User (email) for accessing Mainflux | user@example.com | -| MF_PROVISION_PASS | Mainflux password | user123 | -| MF_PROVISION_API_KEY | Mainflux authentication token | | -| MF_PROVISION_CONFIG_FILE | Provision config file | config.toml | -| MF_PROVISION_HTTP_PORT | Provision service listening port | 8091 | -| MF_PROVISION_ENV_CLIENTS_TLS | Mainflux SDK TLS verification | false | -| MF_PROVISION_SERVER_CERT | Mainflux gRPC secure server cert | | -| MF_PROVISION_SERVER_KEY | Mainflux gRPC secure server key | | -| MF_PROVISION_SERVER_KEY | Mainflux gRPC secure server key | | -| MF_PROVISION_MQTT_URL | Mainflux MQTT adapter URL | http://localhost:1883 | -| MF_PROVISION_USERS_LOCATION | Users service URL | http://locahost | -| MF_PROVISION_THINGS_LOCATION | Things service URL | http://localhost | -| MF_PROVISION_LOG_LEVEL | Service log level | http://localhost | -| MF_PROVISION_HTTP_PORT | Service listening port | 8091 | -| MF_PROVISION_USER | Mainflux user username | test@example.com | -| MF_PROVISION_PASS | Mainflux user password | password | -| MF_PROVISION_BS_SVC_URL | Mainflux Bootstrap service URL | http://localhost/things/configs | -| MF_PROVISION_BS_SVC_WHITELIST_URL | Mainflux Bootstrap service whitelist URL | http://localhost/things/state | -| MF_PROVISION_CERTS_SVC_URL | Certificats service URL | http://localhost/certs | -| MF_PROVISION_X509_PROVISIONING | Should X509 client cert be provisioned | false | -| MF_PROVISION_BS_CONFIG_PROVISIONING | Should thing config be saved in Bootstrap service | true | -| MF_PROVISION_BS_AUTO_WHITELIST | Should thing be auto whitelisted | true | -| MF_PROVISION_BS_CONTENT | Bootstrap service configs content, JSON format | {} | -| MF_PROVISION_CERTS_CA | Mainflux CA cert for generating certificates | "" | -| MF_PROVISION_CERTS_CA_KEY | Mainflux CA cert private key | "" | -| MF_PROVISION_CERTS_RSA_BITS | Certificate RSA bits parameter | 4096 | -| MF_PROVISION_CERTS_HOURS_VALID | Number of days that certificate is valid | "2400h" | +| Variable | Description | Default | +| ----------------------------------- | ------------------------------------------------- | --------------------------------------| +| MF_PROVISION_LOG_LEVEL | Service log level | debug | +| MF_PROVISION_USER | User (email) for accessing Mainflux | user@example.com | +| MF_PROVISION_PASS | Mainflux password | user123 | +| MF_PROVISION_API_KEY | Mainflux authentication token | | +| MF_PROVISION_CONFIG_FILE | Provision config file | config.toml | +| MF_PROVISION_HTTP_PORT | Provision service listening port | 8190 | +| MF_PROVISION_ENV_CLIENTS_TLS | Mainflux SDK TLS verification | false | +| MF_PROVISION_SERVER_CERT | Mainflux gRPC secure server cert | | +| MF_PROVISION_SERVER_KEY | Mainflux gRPC secure server key | | +| MF_PROVISION_USERS_LOCATION | Users service URL | http://users:8180 | +| MF_PROVISION_THINGS_LOCATION | Things service URL | http://things:8182 | +| MF_PROVISION_BS_SVC_URL | Mainflux Bootstrap service URL | http://bootstrap:8202/things | +| MF_PROVISION_BS_SVC_WHITELIST_URL | Mainflux Bootstrap service whitelist URL | http://bootstrap:8202/things/state | +| MF_PROVISION_CERTS_SVC_URL | Certificates service URL | http://certs:8204/certs | +| MF_PROVISION_X509_PROVISIONING | Should X509 client cert be provisioned | false | +| MF_PROVISION_BS_CONFIG_PROVISIONING | Should thing config be saved in Bootstrap service | true | +| MF_PROVISION_BS_AUTO_WHITELIST | Should thing be auto whitelisted | true | +| MF_PROVISION_BS_CONTENT | Bootstrap service configs content, JSON format | {} | +| MF_PROVISION_CERTS_RSA_BITS | Certificate RSA bits parameter | 4096 | +| MF_PROVISION_CERTS_HOURS_VALID | Number of days that certificate is valid | "2400h" | By default, call to `/mapping` endpoint will create one thing and two channels (`control` and `data`) and connect it. If there is a requirement for different provision layout we can use [config](docker/configs/config.toml) file in addition to environment variables. @@ -115,12 +108,12 @@ docker-compose -f docker/addons/provision/docker-compose.yml up For the case that credentials or API token is passed in configuration file or environment variables, call to `/mapping` endpoint doesn't require `Authentication` header: ```bash -curl -s -S -X POST http://localhost:8888/mapping -H 'Content-Type: application/json' -d '{"external_id": "33:52:77:99:43", "external_key": "223334fw2"}' +curl -s -S -X POST http://localhost:/mapping -H 'Content-Type: application/json' -d '{"external_id": "33:52:77:99:43", "external_key": "223334fw2"}' ``` In the case that provision service is not deployed with credentials or API key or you want to use user other than one being set in environment (or config file): ```bash -curl -s -S -X POST http://localhost:8091/mapping -H "Authorization: " -H 'Content-Type: application/json' -d '{"external_id": "", "external_key": ""}' +curl -s -S -X POST http://localhost:/mapping -H "Authorization: " -H 'Content-Type: application/json' -d '{"external_id": "", "external_key": ""}' ``` Or if you want to specify a name for thing different than in `config.toml` you can specify post data as: diff --git a/provision/config.go b/provision/config.go index 05740342..b42fabe0 100644 --- a/provision/config.go +++ b/provision/config.go @@ -26,7 +26,7 @@ type ServiceConf struct { MfPass string `toml:"mf_pass"` MfAPIKey string `toml:"mf_api_key"` MfBSURL string `toml:"mf_bs_url"` - MfWhiteListURL string `toml:"mf_whit_list"` + MfWhiteListURL string `toml:"mf_white_list"` MfCertsURL string `toml:"mf_certs_url"` } diff --git a/provision/configs/config.toml b/provision/configs/config.toml index c78ec8aa..44183fb4 100644 --- a/provision/configs/config.toml +++ b/provision/configs/config.toml @@ -10,13 +10,13 @@ file = "config.toml" [server] LogLevel = "info" ca_certs = "" - http_port = "8091" + http_port = "8190" mf_api_key = "" mf_bs_url = "http://localhost:8202" mf_certs_url = "http://localhost/certs" mf_pass = "" mf_user = "" - mf_whit_list = "http://localhost:8202/things/state" + mf_white_list = "http://localhost:8202/things/state" mqtt_url = "" port = "" server_cert = ""