Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

feat: ✨ e2ee support #147

Merged
merged 47 commits into from
Aug 20, 2022
Merged

feat: ✨ e2ee support #147

merged 47 commits into from
Aug 20, 2022

Conversation

HarHarLinks
Copy link
Contributor

@HarHarLinks HarHarLinks commented Jul 27, 2022

supersedes #79

I rebased this on current-ish (~ last week's) master because the situation got a bit messy with half a year of changes

todos transfered from original PR:

  • warn when message can't be decrypted
    • ignore messages older than joining
    • notify + log when the crypto session broke incl hint to reset access_token and crypto store: compare access_token -> session ID -> crypto db not sure how to detect this broken state
  • prefer (loaded) access_token over password login, to keep session. necessary since session must correspond to e2e session
  • settings to handle unverified devices
  • expose some config options to user/config file
    • test coverage
    • encryption enabled
    • emoji verify
    • store path
    • ignore unverified devices
  • include safeguards: must create a new session to use e2ee, i.e. can't log in with access token when not already owning the session and associated e2e data
  • add simplematrixbotlib[e2e] extra which pulls in matrix-nio[e2e] poetry currently can't specify extras to pull in extras Change dependency's extras through own extras python-poetry/poetry#6053
  • don't modify poetry/dependency stuff
  • update docs with the above and
    • install libolm (as per nio docs!) and simplematrixbotlib[e2e] to enable e2e support
    • mention on main readme + doc page that e2e is supported

HarHarLinks and others added 15 commits July 21, 2022 23:12
this way sessions are reused if possible.
it is especially necessary to keep e2e sessions.
it can be imported from callbacks.py and added to callbacks manually if
user wants to enable it:

```python
async def verify(event):
    await emoji_verification(bot.async_client, event)

bot.async_client.add_to_device_callback(verify, KeyVerificationEvent)
```
can be activated by config option
@HarHarLinks
Copy link
Contributor Author

How do you want to handle the dependency problem in the CI?

@imbev
Copy link
Owner

imbev commented Jul 27, 2022

We should check if encryption dependencies are installed either through something involving https://github.com/poljar/matrix-nio/blob/20ac350d015b9fb1363482661a1d9d26e28914c1/nio/crypto/__init__.py#L41, or through an try-except ImportError check.

@imbev
Copy link
Owner

imbev commented Jul 27, 2022

If that check is false, then changes such as setting https://github.com/HarHarLinks/simple-matrix-bot-lib/blob/182f30e608ac379eacb64e14e6b57904eda88000/simplematrixbotlib/api.py#L56 to false should be made.

@HarHarLinks
Copy link
Contributor Author

Don't we need to adapt the CI to also run with e2e deps installed as to properly test the e2e stuff just the same? At this point I'm not familiar with how to do that.

@imbev
Copy link
Owner

imbev commented Jul 28, 2022

I"m not familiar either. Perhaps we could create an e2e-specific github action test.

@imbev
Copy link
Owner

imbev commented Jul 28, 2022

pip install python-olm --extra-index-url https://gitlab.matrix.org/api/v4/projects/27/packages/pypi/simple

This might be a convenient way to install olm (from the maubot docs)

@HarHarLinks
Copy link
Contributor Author

HarHarLinks commented Aug 6, 2022

From https://docs.mau.fi/maubot/usage/encryption.html to be precise, although there is a warning

However, this method has not been tested properly, so it might not work at all.

I don't think this should be the preferred option, because the distro-packaged library would (maybe automatically) get updated if and when a security patch releases

@HarHarLinks HarHarLinks mentioned this pull request Aug 12, 2022
1 task
@imbev
Copy link
Owner

imbev commented Aug 13, 2022

HarHarLinks#1

@HarHarLinks HarHarLinks marked this pull request as ready for review August 17, 2022 16:41
@imbev imbev merged commit 9bd5c70 into imbev:master Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants