From ec85cbb20002d9c6ead1029fcc151b3ad4710563 Mon Sep 17 00:00:00 2001 From: Bady <bady@disroot.org> Date: Fri, 1 Nov 2024 16:29:04 +0000 Subject: [PATCH] Remove deprecated user registration and email authentication methods --- README.rst | 57 ------------------------------------ diaspora_auth_provider.py | 61 --------------------------------------- 2 files changed, 118 deletions(-) diff --git a/README.rst b/README.rst index ab3544a..b424a10 100644 --- a/README.rst +++ b/README.rst @@ -92,60 +92,3 @@ Then run these queries: And you will be good to go! - -Email Authentication -~~~~~~~~~~~~~~~~~~~~ - -While this module helps in authenticating with diaspora, we need to set up mxisd_ for supporting -authentication through email. - -Installation -^^^^^^^^^^^^ - -Follow the instructions `here <https://github.com/kamax-io/mxisd/blob/master/docs/getting-started.md#install>`_ - -Configuration & Setup -^^^^^^^^^^^^^^^^^^^^^ - -Follow `this <https://github.com/kamax-io/mxisd/blob/master/docs/getting-started.md#configure>`_. - -Basically, if you used the debian package, you just need to set up the ``matrix.domain`` first. - -And then, add these lines to ``mxisd.yaml``: - -.. code:: yaml - - sql: - enabled: true - type: mysql - connection: "//<HOST>/<DATABASE>?user=<USERNAME>&password=<PASSWORD>" - identity: - type: 'uid' - query: "select (case when ?='email' then username else null end) as uid from users where email=?" - -Where ``<HOST>``, ``<DATABASE>``, ``<USERNAME>`` and ``<PASSWORD>`` are your database host, diaspora database, user and password you created when you set up database for synapse-diaspora-auth - -Now follow the steps `given here <https://github.com/kamax-io/mxisd/blob/master/docs/features/authentication.md#advanced>`_. ie, forward the ``/_matrix/client/r0/login`` endpoint to mxisd and add - -.. code:: yaml - - dns.overwrite.homeserver.client: - - name: '<DOMAIN>' - value: 'http://localhost:8008' - -where ``<DOMAIN>`` is your matrix server name. - -An Apache2 reverse proxy example is already `provided here <https://github.com/kamax-io/mxisd/blob/master/docs/features/authentication.md#apache2>`_. An example nginx configuration would be this: - -.. code:: - - location /_matrix/client/r0/login { - proxy_pass http://localhost:8090/_matrix/client/r0/login; - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - -Make sure to put this above other matrix reverse proxy directives. And Congrats! You now have a competely integrated synapse - diaspora setup! :D - -.. _mxisd: https://github.com/kamax-io/mxisd \ No newline at end of file diff --git a/diaspora_auth_provider.py b/diaspora_auth_provider.py index 6690a80..d845d3b 100644 --- a/diaspora_auth_provider.py +++ b/diaspora_auth_provider.py @@ -109,70 +109,9 @@ class DiasporaAuthProvider: ) ) defer.returnValue(False) - self.register_user(local_part, email) logger.info("Confirming authentication request.") defer.returnValue(True) - @defer.inlineCallbacks - def check_3pid_auth(self, medium, address, password): - logger.info(medium, address, password) - if medium != "email": - defer.returnValue(None) - logger.debug("Searching for email {} in diaspora db.".format(address)) - users = yield self.exec_query( - "SELECT username FROM users WHERE email=%s", address - ) - if not users: - defer.returnValue(None) - username = users[0][0] - logger.debug("Found username! {}".format(username)) - logger.debug("Registering user {}".format(username)) - self.register_user(username, address) - logger.debug("Registration complete") - defer.returnValue(username) - - @defer.inlineCallbacks - def register_user(self, local_part, email): - if (yield self.account_handler.check_user_exists(local_part)): - yield self.sync_email(local_part, email) - defer.returnValue(local_part) - else: - user_id = yield self.account_handler.register_user( - localpart=local_part, emails=[email] - ) - defer.returnValue(user_id) - - @defer.inlineCallbacks - def sync_email(self, user_id, email): - logger.info("Syncing emails of {}".format(user_id)) - email = email.lower() - store = self.account_handler._store # Need access to datastore - threepids = yield store.user_get_threepids(user_id) - if not threepids: - logger.info("No 3pids found.") - yield self.add_email(user_id, email) - for threepid in threepids: - if not threepid["medium"] == "email": - logger.debug("Not an email: {}".format(str(threepid))) - pass - address = threepid["address"] - if address != email: - logger.info( - "Existing 3pid doesn't match {} != {}. Deleting".format( - address, email - ) - ) - yield self.auth_handler.delete_threepid(user_id, "email", address) - yield self.add_email(user_id, email) - break - logger.info("Sync completed.") - - @defer.inlineCallbacks - def add_email(self, user_id, email): - logger.info("Adding 3pid: {} for {}".format(email, user_id)) - validated_at = self.account_handler._hs.get_clock().time_msec() - yield self.auth_handler.add_threepid(user_id, "email", email, validated_at) - @staticmethod def parse_config(config): class _Conf: -- GitLab