giejay / domoticz-gbridge-plugin

Domoticz plugin for the Kappelt gBridge
16 stars 4 forks source link

Add support for password protected Domoticz installations. #2

Closed TheReptile closed 5 years ago

TheReptile commented 5 years ago

Is seems the current plugin doesn't support password authentication for the Domoticz installation. When the plugin starts, I see this in the log:

2018-12-09 17:11:04.203 Status: (gBridge) Entering work loop.
2018-12-09 17:11:04.204 Status: (gBridge) Initialized version 0.0.14
2018-12-09 17:11:04.476 Error: (gBridge) 'onStart' failed 'HTTPError'.
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 139 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onStart
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 70 in '/home/pi/domoticz/plugins/gbridge/plugin.py', function onStart
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 17 in '/home/pi/domoticz/plugins/gbridge/domoticz_client.py', function fetchDevicesFromDomoticz
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 163 in '/usr/lib/python3.5/urllib/request.py', function urlopen
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 472 in '/usr/lib/python3.5/urllib/request.py', function open
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 582 in '/usr/lib/python3.5/urllib/request.py', function http_response
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 510 in '/usr/lib/python3.5/urllib/request.py', function error
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 444 in '/usr/lib/python3.5/urllib/request.py', function _call_chain
2018-12-09 17:11:04.476 Error: (gBridge) ----> Line 590 in '/usr/lib/python3.5/urllib/request.py', function http_error_default 
giejay commented 5 years ago

Hi, did you exclude localhost from authentication in the settings? Thats under: Local Networks (no username/password). Add 'localhost'.

TheReptile commented 5 years ago

Yes, I already had localhost excluded, but it didn't work. I tested the getting the url with wget. However I noticed localhost resolved to ::1. Afterwards I disabled ipv6 on my pi. In the end I had to add 127.0.0.1 before it started working.

giejay commented 5 years ago

Ah good catch, should add that to the Readme:) I also just added error logging whenever a call to Domoticz or gBridge fails, 'onStart' failed 'HTTPError'.' doesnt give you a whole lot of information, now it logs the status + reason.

TheReptile commented 5 years ago

Yeah, I noticed that, a nice addition. But maybe it's better to change the url from localhost to 127.0.0.1? Otherwise people would have to disable ipv6 or edit the hosts file to remove the ::1 alias. adding ::1 to the Local networks doesn't seem to work.

giejay commented 5 years ago

Yes, thanks for the feedback, I will change localhost to 127.0.0.1 tomorrow when I do the sync change, shall we close this issue?

TheReptile commented 5 years ago

Sure, thanks for your efforts!

AciDCooL commented 5 years ago

Not my intention to reopen old issues, but isn't that a workaround for local installations. I have a domoticz setup in the "cloud" and rather don't want authentication to be disabled for my external ip. Even multiuser systems wil have some issue with this. Easiest would be some kind of Domoticz username password field in the option's. I know it's getting kind of bloated with all the fields, but one could put the definition to "optional".

And to top it of maybe a security warning if your using http, but that just my internal tin foiled hat syndrome. https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Authorization

giejay commented 5 years ago

Well, I had refactored it that you could pass in the full URL plus port of your Domoticz system but I stumbled upon the issue that I have no more config vars to store it in. Domoticz has the idiot limit of being able to store something like 6 extra vars. Replacing the port with the full address is not possible because the port always renders to a number.

But why dont you configure the plugin in your remote domoticz? That should just work right? No need of whitelisting ips afaik.

AciDCooL commented 5 years ago

That makes sense, ill edit the url and make a git ignore for future updates, or a sed command, ill figure something out, will be static but serves the purpose. Thanks for clearing that up 👍

giejay commented 5 years ago

Hmm I don't think we completely understand each other. What is your current setup, you have a local domoticz running in your home network, and a remote domoticz on a VPS?

AciDCooL commented 5 years ago

Since I have multiple devices coming from different external ip's i'm running a remote domoticz with authentication for mqtt. As a sort of workaround I'm using a mqtt bridge with two domoticz installations 1x Pi local and 1x VM external over a site-to-site tunnel which is working for my purposes.