drogue-iot / drogue-cloud

Cloud Native IoT
https://drogue.io
Apache License 2.0
113 stars 30 forks source link

Allow to send arbitrary extension attributes #376

Open ctron opened 1 year ago

ctron commented 1 year ago

Summarizing the chat discussion with @rmja …

It would be good to allow devices (protocol endpoints) to send arbitrary header fields, which translate into CloudEvents (CE) extension attributes.

As some extension attributes cannot be allowed to be set by external actors (like the id value, the "partition key" , or distributed tracing information) such fields need to be either filtered out, or rejected. An alternative would be to simply prefix everything with e.g. drogue-, which would scope/namespace such attributes and prevent any collision.

While the core attributes of CE are known (at this point), the full set of attributes (including all extensions) is not. So using a prefix makes the implementation much easier.

The proposed solution is:

For HTTP this could simply mean adding every query parameter that starts with attr. (or meta. or ext.) to the extension attributes. Like:

?attr.foo=bar

Resulting in:

drogue-foo: bar
ctron commented 1 year ago

Additional thought: For HTTP, we could allow translating all Drogue-Attr- prefixed headers as extension attributes too.