Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-auth if a new nonce is received #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wagnerand
Copy link

@wagnerand wagnerand commented Jun 2, 2023

Fix alexryd/homebridge-shelly-ng#37.
Fix alexryd/homebridge-shelly-ng#53.
Fix alexryd/homebridge-shelly-ng#59.

According to the documentation, auth for websockets should never expire, but it seems it does. This checks if a new nonce was returned by the server. If so, don't fail but re-generate the auth.

@wagnerand
Copy link
Author

@alexryd could you take a look at this, please?

@vowchr
Copy link

vowchr commented Jun 20, 2023

Is this project still alive? Many people are waiting for this fix here....

@1onar
Copy link

1onar commented Dec 8, 2023

This issue persists.

@wagnerand you did edit "src/rpc/auth.ts" which doesn't exist in the original code. Does it work if i insert your "auth.ts" in the latest release or do i need to do other adjustments?

@wagnerand
Copy link
Author

This issue persists.

@wagnerand you did edit "src/rpc/auth.ts" which doesn't exist in the original code. Does it work if i insert your "auth.ts" in the latest release or do i need to do other adjustments?

It does exist in the original code, as you can see from the patch view. I edited an existing file, no new files were added.

@1onar
Copy link

1onar commented Dec 8, 2023

It does exist in the original code, as you can see from the patch view. I edited an existing file, no new files were added.

Yes it does in node-shellies-ng but you did answer in an issue homebridge-shelly-ng that you fixed it. But the homebridge code doesnt contain the „auth.ts“ file.

@wagnerand
Copy link
Author

wagnerand commented Dec 8, 2023

Please see the pull request diff view: https://github.com/alexryd/node-shellies-ng/pull/3/files. node-shellies-ng is a dependency of homebdrige-shelly-ng and the fix for alexryd/homebridge-shelly-ng#37 is this PR.

@1onar
Copy link

1onar commented Dec 8, 2023

Sorry, now i get it and found it in the homebridge files. Thank you!

@7baumann
Copy link

7baumann commented Dec 11, 2023

Have you thought about opening a pull request on one of the active forks of the plugin like homebridge-shelly-ng-ul, homebridge-shelly-ng-infister, homebridge-linusne-shelly-ng or @lukyer/homebridge-shelly-ng, as none of them seem to have included the fix?

It would be nice to be able to use the plugin with authentification.

@asameli
Copy link

asameli commented Dec 22, 2023

Gents, is anyone capable to fix this. Or did anyone find another project with this fix included?

@7baumann
Copy link

7baumann commented Dec 22, 2023

Gents, is anyone capable to fix this. Or did anyone find another project with this fix included?

Well, I think for the time being you have 4 options:

  • Don't use a password in your shellys until this fix is merged
  • Fork this and then open your own PR on one of the more active forks
  • Start your own fork as a new plugin, i.e. publish your fork as a npm package
  • hard-fix this in your prod-environment

For my part, I did the latter. My homebridge is running on my synology NAS, so I ssh-ed into it and updated the source by hand. This is quite dirty, but seemed to be the most viable option. As new versions of the plugin are not to be expected, and if so hopefully with this fix, overwriting of the change should not be a problem. But I see the point that this only works for me and doesn't solve it for the community and is problematic in its nature as I am tempering with my prod-environment, so I am not recommending it. It is just what I thought for me was the best short-time solution.

EDIT: Oh, and I checked the other forks beforehand: None is including this fix.

@nscheffer
Copy link

hi @7baumann,
Sorry I am a beginner, how do you hard-fix in your prod-environment ?
Many thanks in advance and merry Christmas ...

@7baumann
Copy link

@nscheffer Sorry, but it is probably not feasable and/or wise for you to try to fix this by hand, if you do not know how to open a shell on the machine you are running homebridge on as well as update the file by hand. This is specific to your homebridge installation and so for you I think there is only one useful option:

Remove the password of your shelly for the time being. Additionally, check if it is possible to block internet access for your shelly on your router. If your network is trustworthy, this might be a viable option.

@nscheffer
Copy link

nscheffer commented Dec 23, 2023

@7baumann ,
Beginner as a developer but I know how to compile my own kernel on my raspberry to fine tune my Homebridge...
I am just lost regarding which file to edit to apply the patch on my current homebridge instance.

I don't set any password on my shelly-ng and they are on their own vlan, but if I am blocking internet access I will loose the Shelly Control, I got more than 60 Shelly devices....

@7baumann
Copy link

7baumann commented Dec 23, 2023

First of all: If you don't have a password set for your shellys, this issue shouldn't concern you. The problem occurs only if you are connecting to your shellys with authentification.

Nevertheless, I will try to give you and others some hints. Hopefully this sets you on the right path: homebridge plugins are npm packages, running on a nodejs server. Nodejs can execute Javascript, but this plugin is written in Typescript. Therefore, the source code you can find on your machine is a compiled version, you must look for a file called auth.js.

This file is part of an npm package called shellies-ng, which is used by the node-shelly-ng plugin. Therefore, when you found your homebridge installation, there should be a node-modules-folder where your plugins live. Navigate to the node-shelly-ng plugin and find the node_modules folder in there. This should contain a folder shellies-ng, and there under rpc/auth.js you find the file you need to edit.

Thankfully, there is nothing typescript-specific to the changes of this commit, so you can just copy-paste those new lines from the commit. Be aware that the whole file is typescript-specific, so you cannot overwrite the whole file. Find those lines and edit them by hand.

I hope this helps a little.

EDIT: Concerning the internet connection: I assumed that you are using homekit to remotly control your shellys, as I do. So no direct internet connection is needed (homekit connects locally in your network to your homebridge and then to your shellys).

@wagnerand
Copy link
Author

Can you please use a different communication channel? This PR contains more than enough off-topic "spam" already. Thanks!

@cubi1337
Copy link

hi,
added Fix to

https://github.com/cubi1337/homebridge-shelly-ds9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants