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

feat(bridge-api): switch from hashed tokens to encrypted tokens #85

Merged
merged 5 commits into from
Nov 12, 2022

Conversation

pree
Copy link
Contributor

@pree pree commented Oct 24, 2022

fixes #84

@pschmitt
Copy link
Owner

Thanks for implementing this! I wonder though if this works with older bridge (software) versions, I'm assuming it doesn't - right?

If that's the case we should make this pynuki 2.0 release, rather than a simple patch bump.

@pree
Copy link
Contributor Author

pree commented Oct 25, 2022

As for the docs it seems to be compatible even with older bridges:

Bridge 1.0: ≥1.22.1
Bridge 2.0: ≥2.14.0

That's why I decided to replace the hash_token instead of adding to it :)
In their release notes for the public releases it seems to not be released yet (should have been in july), but maybe they just forgot to post it. As my bridge is in the beta channel I cannot confirm the current release.

I guess the only bridge that won't be supported anymore by pynuki would be the software bridge, which isn't supported by nuki anymore since nearly two years.

I can of course change the version to 1.6.0, as this is somewhat of a breaking change, or even 2.0.0 if you wish.

@pree
Copy link
Contributor Author

pree commented Oct 28, 2022

If you don't mind, I'd love if you can add the hacktoberfest-accepted label to this PR :)

@pschmitt
Copy link
Owner

This seems to break the discovery feature:

python -c "from pynuki import NukiBridge; NukiBridge.discover()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pschmitt/devel/private/pynuki.git/pynuki/bridge.py", line 62, in discover
    return [
  File "/home/pschmitt/devel/private/pynuki.git/pynuki/bridge.py", line 63, in <listcomp>
    NukiBridge(hostname=x.get("ip"), port=x.get("port"))
  File "/home/pschmitt/devel/private/pynuki.git/pynuki/bridge.py", line 45, in __init__
    self.token = token
  File "/home/pschmitt/devel/private/pynuki.git/pynuki/bridge.py", line 78, in token
    self.__tokendigest = sha256sum(token)
  File "/home/pschmitt/devel/private/pynuki.git/pynuki/utils.py", line 15, in sha256sum
    return hashlib.sha256(text.encode("utf-8")).digest()
AttributeError: 'NoneType' object has no attribute 'encode'

@pschmitt pschmitt merged commit a5b9159 into pschmitt:main Nov 12, 2022
@pree
Copy link
Contributor Author

pree commented Nov 12, 2022

Thanks for the review and the fixes! :)

@pree pree deleted the feat/crypted-tokens branch November 12, 2022 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for crypted tokens
2 participants