1

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.

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60

1 Answers1

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).

fgalan
  • 11,732
  • 9
  • 46
  • 89
  • I will try as soon as possible. While this, @fgalan what do you suggest for DELETE operation be allowed only after authentication/authorization process? I tried to do a DELETE operation passing an X-Auth-Token, but I got this: The status of this operation is: 400 Some error occurred! {"error":"BadRequest","description":"Orion accepts no payload for GET/DELETE requests. HTTP header Content-Type is thus forbidden"} – Dalton Cézane Dec 19 '16 at 22:44
  • In order not mixing topics, I'd suggest you ask your new question as an idependent post a stackoverflow, please. Thanks! – fgalan Dec 20 '16 at 07:37
  • Hi, @fgalan . I did what you said, registering some subscriptions with the httpCustom like this: ` "notification": { "httpCustom": { "url": "http://myapp:1028", "headers": { "X-Auth-Token": "u2ljrNrf0zNDmITX7Dyyx347DLKa4c" } } ` But I did not understand how this works. I registered a subscription passing a valid token. When this token will be validated in the moment some notification will be sent? Apparently, the x-auth-token in the httpCustom does not work, because I tested creating a subscription with an invalid token and the notification was sent. – Dalton Cézane Dec 20 '16 at 19:59
  • 1
    Orion will not validate the `X-Auth-Token`, but will include it in notifications so others (i.e. the element listening at the URL) can validate. I have edited my original answer in order to make this clearer. – fgalan Dec 22 '16 at 11:08
  • Answer has been edited, to include relevant information regarding HTTPS notification native support in Orion 1.7.0 (to be released by the beginning of February 2017) – fgalan Jan 31 '17 at 14:18
  • Very good, @fgalan . I will test it as soon as possible. Thanks. – Dalton Cézane Jan 31 '17 at 14:39
  • Hi, @fgalan . Could you help me with the Orion setup for https notifications? We are trying to start the service with -https, -cert and -key params. When we try to test https connection with a curl, we receive "connection refused" message. – Dalton Cézane Apr 03 '17 at 18:52
  • Let's move that new issue to a new question post, in order not mixing with the present one. Could you create a new question post with all the details (i.e. how do you start Orion, which exact command do you use and which result do you get, etc.), using "fiware-orion" label, please? Thanks! – fgalan Apr 03 '17 at 19:06