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
This commit is contained in:
parent
f74e555c23
commit
d9f5f4c8f8
1 changed files with 5 additions and 8 deletions
|
|
@ -37,7 +37,7 @@ from sat.core.log import getLogger
|
|||
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 @@ class PubsubSigning:
|
|||
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 @@ class PubsubSigning:
|
|||
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 @@ class PubsubSigning:
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue