owntracks / ios

OwnTracks' iPhone App
http://owntracks.org
Other
315 stars 90 forks source link

Question: Is it possible to configure the iOS app to send custom http headers? #761

Closed marceloaf closed 5 months ago

marceloaf commented 5 months ago

Hi. Hope this finds you well.

My Home Assistant installation is behind Cloudflare with Service Token. When I access the webhook url in my HA I need to pass the clientid and clientsecret as headers. Is it possible to configure the iOS app to use such custom http headers?

Thanks in advance, Marcelo

jpmens commented 5 months ago

This is currently not possible, but is probably a good idea, as custom HTTP headers can be useful in a multitude of situations.

ckrey commented 5 months ago

Text settings parameter contains extra HTTP headers.

jpmens commented 5 months ago

An upcoming version will have a new setting httpHeaders which allows us to specify any number of headers which will be transmitted along with the HTTP request.

The following example configures three distinct headers (note the newline separator):

rabbit-10615

which arrive at the HTTP endpoint as:

Content-Type: application/json
CF-Access-Client-Secret: 3e2blabla
CF-Access-Client-Id: bd.access.owntracks.org
myname: JP
User-Agent: OwnTracks/17.1.0 CFNetwork/1410.0.3 Darwin/22.6.0
X-Limit-D: http-i3
X-Limit-U: jpm
ckrey commented 5 months ago

@marceloaf here is the link to a public beta of the new version. It would be highly appreciated if you test to connect to your backend via Cloudflare and leave your feedback here.

https://testflight.apple.com/join/k2iqRtjH

marceloaf commented 5 months ago

Very cool guys! Apparently, it's working perfectly! ☺

Just sent a manual update at 16:19 my time and HA received it correctly! I'll leave now to do some errands and to do some further tests. Thank you very much!

I had done a small donation earlier today, but as I was not used to the platform it apparently split the value throughout the year... :-( My intent was to do it immediately! Anyways...

Owntracks update

image
jpmens commented 5 months ago

Much appreciated, thank you!