How to add a custom header in outgoing notifications with Orion?

僤鯓⒐⒋嵵緔 提交于 2019-12-01 10:39:21

问题


I read the "Custom notifications" section in the NGSIv2 specification and I still have doubts in how to make this work.

Do I have to put in my subscribe POST the following code as a payload?

"httpCustom": {
  "url": "http://foo.com/entity/${id}",
  "headers": {
    "Content-Type": "text/plain"
  },
  "method": "PUT",
  "qs": {
    "type": "${type}"
  },
  "payload": "The temperature is ${temperature} degrees"
}

How would be a complete payload with a httpCustom for a subscribe with Authentication/Authorization?

Lastly, is really necessary to use Rush, as stated at Rush Relayer? In this case, we have to use a "third-party" software that was updated almost 3 years ago. Why not Orion provides this? I would appreciate some help regarding this too.


回答1:


The following httpCustom could be used:

"httpCustom": {
  "url": "http://example.com/some/path",
  "headers": {
    "X-Auth-Token": "n5u43SunZCGX0AbnD9e8R537eDslLM"
  }
}

The token will expire from time to time. Thus, it should be renewed at a regular interval, modifying the httpCustom element with the new token (using PATCH /v2/subscriptions/<id> operation, see NGSIv2 specification for details).

Regarding Rush, it is not necesary if you can achieve the HTTP-to-HTTPS with some equivalent software. Native HTTPS notifications at Orion has been identified as a topic of interest and even there was a pull request with code implementation in that line. Currently it isn't a priority, however contributions related with this are welcomed :)

EDIT: the above httpCustom configuration will make Orion sending notifications including that X-Auth-Token header. Thus, it is supposed that at the url endpoint (e.g. http://example.com/some/path in the example above) the authentication elements able to process the X-Auth-Token header will be listening (typically, a Policy Enforcement Point -PEP- Proxy).

UPDATE: since verion 1.7.0, Orion implements native HTTPS notifications (i.e. without needing Rush).



来源:https://stackoverflow.com/questions/41128616/how-to-add-a-custom-header-in-outgoing-notifications-with-orion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!