valiquette / homebridge-rachio-irrigation

Provides Homebridge support for Rachio controller
MIT License
17 stars 4 forks source link

Question about webhook basic auth #52

Closed stevehoek closed 9 months ago

stevehoek commented 1 year ago

I am trying to get basic auth to work with the webhook but it seems to not work. At first I was using my Rachio account credentials, but after reading here it seems that it can be any random username/password (eg: 1234/5678)? Either way the webhook test URL never resolves. If I turn off basic auth, it is working.

With webhook debugging turned on, when I use basic auth I see this in the logs [29/04/2023, 09:41:53] [Rachio] Expecting webhook authentication

What am I missing?

valiquette commented 1 year ago

try using strings, like user/pass I think number are fine but I would have to check. most likely you have some extra web hooks being sent, try clearing them out, check the box to delete web hooks "extra stuff" in the config

stevehoek commented 1 year ago

yeah I tried just a basic user of my name 'stevehoek' and password of 'cottage' but it does not resolve

http://stevehoek:cottage@hoeknet-cottage.ddns.net:12453/test

I've tried with the IP instead of the DDNS address and it doesn't work either.

When I turn off Basic Auth, it works fine

I did check the box to clear existing webhooks

valiquette commented 1 year ago

I did confirm 1234/5678 works fine

stevehoek commented 1 year ago

Could my router be stripping the authentication? It just doesn't work even with 1234/5678

I suppose it is not necessary... kcharwood's plugin worked for years for me without it ;) I just like to use recommended settings, especially if it brings more security.

valiquette commented 1 year ago

You should see something in you Log (debug on) like this when using 1234/5678 [4/29/2023, 7:59:26 AM] [Rachio-Dev] webhook request authorization header=Basic MTIzNDo1Njc4 [4/29/2023, 7:59:26 AM] [Rachio-Dev] webhook expected authorization header=Basic MTIzNDo1Njc4 [4/29/2023, 7:59:26 AM] [Rachio-Dev] Webhook authentication passed [4/29/2023, 7:59:26 AM] [Rachio-Dev] Webhook match found for Front Yard Shrubs will update zone service [4/29/2023, 7:59:26 AM] [Rachio-Dev] Zone Status Update [4/29/2023, 7:59:26 AM] [Rachio-Dev] Front Yard Shrubs Completed, completed after 3 minutes. [4/29/2023, 7:59:26 AM] [Rachio-Dev] Front Yard Shrubs completed watering at 07:59 AM (MDT) for 3 minutes.

valiquette commented 1 year ago

keep in mind if your trying to use http://stevehoek:cottage@hoeknet-cottage.ddns.net:12453/test to test you can not be on the same network. Try testing from a device on a cell only network

stevehoek commented 1 year ago

Yeah I have tried the test from a cell phone with wifi off. Does that test URL work for you?

With basic auth configured, and the Test URL not resolving, I can control the sprinklers but see this in the logs

[29/04/2023, 10:23:00] [Rachio-Cottage] Expecting webhook authentication
[29/04/2023, 10:23:36] [Rachio-Cottage] Expecting webhook authentication
[29/04/2023, 10:24:37] [Rachio-Cottage] Starting zone-2 Front Pathway Sprays for 5 mins
[29/04/2023, 10:24:38] [Rachio-Cottage] <simulated-webhook> Front Pathway Sprays Started, started for duration 5 minutes.
[29/04/2023, 10:24:40] [Rachio-Cottage] <homebridge-Rachio-Cottage> Front Pathway Sprays Started, started for duration 5 minutes.
[29/04/2023, 10:24:49] [Rachio-Cottage] Stopping Zone Front Pathway Sprays
[29/04/2023, 10:24:50] [Rachio-Cottage] <simulated-webhook> Front Pathway Sprays Stopped, stopped after 12 seconds.
[29/04/2023, 10:24:53] [Rachio-Cottage] <homebridge-Rachio-Cottage> Front Pathway Sprays Stopped, stopped after 12 seconds.

I don't see anything like you pasted above. I have your plugin's debug flag set, but not the global Homebridge debug flag. Do I need that?

valiquette commented 1 year ago

you do need to enable homebridge logging.

The test url ma not work if your browser will not pass the basic auth, this seems to common now, but you should see it come in and fail in the log.

stevehoek commented 1 year ago

I never could get it to work, either at home (Ubiquiti router) or cottage (eero router).

It is working without auth, but I see references to "simulated webhook" like this [29/04/2023, 10:24:38] [Rachio-Cottage] Front Pathway Sprays Started, started for duration 5 minutes.

And no logs of "actual" webhooks. What is the simulate-webhook doing?

valiquette commented 1 year ago

The way the plugin works, when you start/stop a zone there is a PUT call to the Rachio API, if there is a positive response 204 then I simulate the same response that would be received from a web hook message, that way the there is just routine keep track off all the updates, regardless of where the originated from. If you see the plugin created that message. When you see this is a webhook message directly from Rachio. This tells me that your routers forwarding is working correctly.

I would be interested to know what Rachio thinks it needs to send. If you have homebridge debug logging on you enable show api and show web hooks in the plugin settings. you should see something like this message. If you are using basic auth then you should see the user:password. If you are trying to use basic auth and you do not see that in the url it would generate the error you seeing

[4/30/2023, 3:31:25 PM] [Rachio-Dev] configured webhooks response [ { "id": "6793be8e-7ef6-40d2-aa37-6d1a8881ff06", "url": "http://user:password@76.25.xxx.xxx:12456", "eventTypes": [ { "name": "ZONE_STATUS", "type": "WEBHOOK" }, { "name": "RAIN_DELAY", "type": "WEBHOOK" }, { "name": "SCHEDULE_STATUS", "type": "WEBHOOK" }, { "name": "DEVICE_STATUS", "type": "WEBHOOK" }, { "name": "WEATHER_INTELLIGENCE", "type": "WEBHOOK" } ], "externalId": "homebridge-Rachio" }, { "id": "196e40c1-5430-473c-a9c2-d54cd789998a", "url": "http://username:password@76.25.xxx.xxx:12453", "eventTypes": [ { "name": "SCHEDULE_STATUS", "type": "WEBHOOK" }, { "name": "WEATHER_INTELLIGENCE", "type": "WEBHOOK" }, { "name": "ZONE_STATUS", "type": "WEBHOOK" }, { "name": "DEVICE_STATUS", "type": "WEBHOOK" }, { "name": "RAIN_DELAY", "type": "WEBHOOK" } ], "externalId": "homebridge-Rachio-Dev-2" },

snippet when I start a zone [4/30/2023, 3:19:02 PM] [Rachio-Dev] Starting zone-4 Back Yard for 1 mins [4/30/2023, 3:19:02 PM] [Rachio-Dev] Starting Zone b88886ac-6e63-47d0-b1e5-bc8410a8f05e [4/30/2023, 3:19:02 PM] [Rachio-Dev] start response 204 [4/30/2023, 3:19:02 PM] [Rachio-Dev] Simulating webhook for Back Yard will update services [4/30/2023, 3:19:02 PM] [Rachio-Dev] Zone Status Update [4/30/2023, 3:19:02 PM] [Rachio-Dev] Back Yard Started, started for duration 1 minutes. [4/30/2023, 3:19:02 PM] [Rachio-Dev] Back Yard began watering at 3:19:02 PM [4/30/2023, 3:19:04 PM] [Rachio-Dev] webhook request authorization header=Basic dXNlcjpwYXNzd29yZA== [4/30/2023, 3:19:04 PM] [Rachio-Dev] webhook expected authorization header=Basic dXNlcjpwYXNzd29yZA== [4/30/2023, 3:19:04 PM] [Rachio-Dev] Webhook authentication passed [4/30/2023, 3:19:06 PM] [Rachio-Dev] webhook request authorization header=Basic dXNlcjpwYXNzd29yZA== [4/30/2023, 3:19:06 PM] [Rachio-Dev] webhook expected authorization header=Basic dXNlcjpwYXNzd29yZA== [4/30/2023, 3:19:06 PM] [Rachio-Dev] Webhook authentication passed [4/30/2023, 3:19:06 PM] [Rachio-Dev] Webhook match found for Back Yard will update zone service [4/30/2023, 3:19:06 PM] [Rachio-Dev] Zone Status Update [4/30/2023, 3:19:06 PM] [Rachio-Dev] Back Yard Started, started for duration 1 minutes. [4/30/2023, 3:19:06 PM] [Rachio-Dev] Back Yard began watering at 03:19 PM (MDT).

valiquette commented 1 year ago

I am used a number of different router and high no I am using an Amplifi which is essentially Ubiquiti

valiquette commented 1 year ago

I would think the debug logs would hold the key to what is going on, I do not log the headers for the incoming message, but I could get you a build to see that if needed.