changeset 3961:a15c171836bb

plugin pubsub signing: fix `gpg_provider` instanciation: the instance was set at the class level while it is client dependant, resulting in the instance being overwritten on each client connexion. rel 381
author Goffi <goffi@goffi.org>
date Sun, 30 Oct 2022 01:06:35 +0200
parents 4836b81c5f31
children 2d9d0b77e82b
files sat/plugins/plugin_sec_pubsub_signing.py
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_sec_pubsub_signing.py	Sun Oct 30 01:06:32 2022 +0200
+++ b/sat/plugins/plugin_sec_pubsub_signing.py	Sun Oct 30 01:06:35 2022 +0200
@@ -37,7 +37,7 @@
 from sat.tools import utils
 from sat.tools.common import data_format
 
-from .plugin_xep_0373 import get_gpg_provider, VerificationFailed
+from .plugin_xep_0373 import VerificationFailed
 
 
 log = getLogger(__name__)
@@ -87,9 +87,6 @@
     def getHandler(self, client):
         return PubsubSigning_Handler()
 
-    async def profileConnecting(self, client):
-        self.gpg_provider = get_gpg_provider(self.host, client)
-
     def get_data_to_sign(
         self,
         item_elt: domish.Element,
@@ -176,11 +173,11 @@
         signature = base64.b64decode(signature_data["signature"])
         verification_keys = {
             k for k in await self._ox.import_all_public_keys(client, signer)
-            if self.gpg_provider.can_sign(k)
+            if client.gpg_provider.can_sign(k)
         }
         signed_data = self.get_data_to_sign(item_elt, service, timestamp, signer.full())
         try:
-            self.gpg_provider.verify_detached(signed_data, signature, verification_keys)
+            client.gpg_provider.verify_detached(signed_data, signature, verification_keys)
         except VerificationFailed:
             validated = False
         else:
@@ -281,12 +278,12 @@
             sign_elt = signature_elt.addElement((NS_PUBSUB_SIGNING_OPENPGP, "sign"))
             signing_keys = {
                 k for k in self._ox.list_secret_keys(client)
-                if self.gpg_provider.can_sign(k.public_key)
+                if client.gpg_provider.can_sign(k.public_key)
             }
             # the base64 encoded signature itself
             sign_elt.addContent(
                 base64.b64encode(
-                    self.gpg_provider.sign_detached(to_sign, signing_keys)
+                    client.gpg_provider.sign_detached(to_sign, signing_keys)
                 ).decode()
             )
             return signature_elt