Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
219 stars 37 forks source link

links which needs a authentication with user and password #7

Closed 420Dope closed 6 years ago

420Dope commented 6 years ago

Hi, i don´t can use http links which needs a authentication with user and password. I have tried to put the user and password in the links like http://user:password@192.168.178.100 http://192.168.178.100?user=username&pass=password but nothing works.

How can i use links which needs a authentication? Or if this is not possible yet, maybe you can implement this?

Thank you for your great plugin!

Supereg commented 6 years ago

Hello, as of RFC 1738 you should be able to use the format you have already mentioned: http://username:password@example.com What device are you trying to connect to?

However I could also implement authentication over the HTTP Authentication Header.

420Dope commented 6 years ago

Hi, thanks for your fast answer. I use your plugin to controll my Enigma2 receiver over the OpenWebIF. With specific link i can change the channel, change vol. or turn on or off the receiver. { "accessory": "HTTP-SWITCH", "name": "Channel ProSieben", "switchType": "stateless", "timeout": 1000, "onUrl": "http://192.168.0.23/web/zap?sRef=1:0:19:EF75:3F9:1:C00000:0:0:0:" } With this Url the receiver switch the channel to "ProSieben".

It would be nice if you implement authentication over the HTTP Authentication Header.

Thanks again!

Supereg commented 6 years ago

I published a new version v0.4.10 which includes a config option to specify credentials for basic http authentication. Would be great if you can try that one. For configuration please refer to the README

420Dope commented 6 years ago

I have tried it. But homebridge don´t start.

C:\Users\Administrator>homebridge [2018-8-15 22:57:57] Loaded config.json with 1 accessories and 0 platforms. [2018-8-15 22:57:57] --- [2018-8-15 22:57:58] Loaded plugin: homebridge-http-switch [2018-8-15 22:57:58] Registering accessory 'homebridge-http-switch.HTTP-SWITCH' [2018-8-15 22:57:58] --- [2018-8-15 22:57:58] Loading 1 accessories... [2018-8-15 22:57:58] [Switch] Initializing HTTP-SWITCH accessory... C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge-http-switch\index.js:52 this.auth.username = config.auth.username; ^ TypeError: Cannot set property 'username' of undefined at new HTTP_SWITCH (C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge-http-switch\index.js:52:32) at Server._loadAccessories (C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge\lib\server.js:296:29) at Server.run (C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge\lib\server.js:86:38) at module.exports (C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge\lib\cli.js:43:10) at Object. (C:\Users\Administrator\AppData\Roaming\npm\node_modules\homebridge\bin\homebridge:17:22) at Module._compile (module.js:643:30) at Object.Module._extensions..js (module.js:654:10) at Module.load (module.js:556:32) at tryModuleLoad (module.js:499:12) at Function.Module._load (module.js:491:3) C:\Users\Administrator>

This is my config.json

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:30", "port": 50983, "pin": "031-45-154" }, "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.", "accessories": [ { "accessory": "HTTP-SWITCH", "name": "Switch", "switchType": "stateless", "timeout": 1000, "onUrl": "http://192.168.0.23/web/zap?sRef=1:0:19:283D:3FB:1:C00000:0:0:0:", "auth": { "username": "myusername", "password": "mypassword" } }
] }

Supereg commented 6 years ago

Okay, sorry that was my fault. Pushed another update.

420Dope commented 6 years ago

Now it works!

Thank you very much for your work!

Supereg commented 6 years ago

Great to hear. If you use the switch plugin also in instances where you have no authentication consider updating again (to version v0.4.12). Messed up the request mechanism for plugins who do not use the auth property 😅 everything fine again on v0.4.12 👍