NGSI Go supports Keystone (part of the OpenStack project) as IDM. More in detail, the security framework in this case is:
Note this is the stack used by ThinkingCities platform.
This tutorial describes how to use NGSI Go in this scenario.
- Orion PEP is running at endpoint
http://orion-pep:1026 - Keystone IDM is running at endpoint
http://idm:5001 - A service named
smartgondoris created in Keystone IDM - A subservice named
/irrigationis created within servicesmartgondor - A subservice named
/watermeteris created within servicesmartgondor - The user
admin_smartgondorwith passwordadmin1234has permissions on/irrigationand/watermetersubservices
If you are unfamiliar with the service and subservice concepts this reference can be useful.
Create the broker using the following command:
ngsi broker add \
--host mybroker \
--ngsiType v2 \
--brokerHost http://orion-pep:1026 \
--idmType ThinkingCities \
--idmHost http://idm:5001/v3/auth/tokens \
--username admin_smartgondor \
--password admin1234 \
--service smartgondor \
--path /irrigationYou can now use the mybroker broker to do any NGSIv2 operation. For instance, to create an entity in the /irrigation subservice:
ngsi create --host mybroker entity --data '{"id":"E", "type": "T", "A": {"value": 1, "type": "Number"}}'The key point is that NGSI Go will deal transparently with all security aspects (i.e. get a token from IDM, renew token when it expires, etc.) for the user.
More detail on NGSIv2 operations in this side tutorial.
As alternative, you can omit --path parameter in the ngsi broker add command. This way:
ngsi broker add \
--host mybroker \
--ngsiType v2 \
--brokerHost http://orion-pep:1026 \
--idmType ThinkingCities \
--idmHost http://idm:5001/v3/auth/tokens \
--username admin_smartgondor \
--password admin1234 \
--service smartgondor \This allow you to use the same broker specification (mybroker) for several subservices, eg:
ngsi create --host mybroker --path /irrigation entity --data '{"id":"E", "type": "T", "A": {"value": 1, "type": "Number"}}'
ngsi create --host mybroker --path /watermeter entity --data '{"id":"E", "type": "T", "A": {"value": 1, "type": "Number"}}'If you don't specify --path then / is used as default.