如何使用Orion在传出通知中添加自定义标头? [英] How to add a custom header in outgoing notifications with Orion?
问题描述
我阅读了 NGSIv2规范中的自定义通知部分我仍然怀疑如何使这项工作。
I read the "Custom notifications" section in the NGSIv2 specification and I still have doubts in how to make this work.
我是否必须将以下代码作为有效负载放入我的订阅POST中?
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"
}
对于具有身份验证/授权的订阅,具有httpCustom的完整有效负载如何?
How would be a complete payload with a httpCustom for a subscribe with Authentication/Authorization?
最后,确实需要使用 Rush ,如 Rush Relayer ?在这种情况下,我们必须使用大约3年前更新的第三方软件。 Orion为什么不提供这个?我也很感激有关这方面的一些帮助。
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.
推荐答案
以下 httpCustom
可以使用:
"httpCustom": {
"url": "http://example.com/some/path",
"headers": {
"X-Auth-Token": "n5u43SunZCGX0AbnD9e8R537eDslLM"
}
}
令牌将不时到期。因此,应该定期更新它,使用新令牌修改 httpCustom
元素(使用 PATCH / v2 / subscriptions /< id>
操作,请参阅 NGSIv2规范详细信息)。
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).
关于Rush,如果您可以使用某些等效软件实现HTTP到HTTPS,则不一定要这样做。 Orion的原生HTTPS通知已被识别为感兴趣的主题,甚至还有是一个拉取请求,其中包含代码实现。目前不是优先事项,但欢迎与此相关的贡献:)
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 :)
编辑:以上 httpCustom
配置将使Orion发送包括 X-Auth-Token
标头的通知。因此,假设在 url
端点(例如 http://example.com/some/path
in上面的示例)能够处理 X-Auth-Token
标头的认证元素将被监听(通常是策略执行点-PEP-代理)。
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).
更新:自版本1.7.0以来,Orion实现本机HTTPS通知(即不需要Rush)。
UPDATE: since verion 1.7.0, Orion implements native HTTPS notifications (i.e. without needing Rush).
这篇关于如何使用Orion在传出通知中添加自定义标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!